# cdleonard/pyt32 architecture

> Architecture diagram of the GitHub repository cdleonard/pyt32, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cdleonard/pyt32
- Repository: https://github.com/cdleonard/pyt32

## Overview

pyt32 is a small Python library for controlling Lauterbach TRACE32. Its main workflow is to obtain an interface, send TRACE32 commands, and optionally parse returned values; users can start this through the CLI or use the library directly. The ctypes API is the default interface, with t32rem and GDB monitor alternatives. The README gives little detail beyond the product purpose, so the graph follows the sampled runtime code and omits undocumented capabilities.

Main entry points: [`t32/ctypes.py`](https://github.com/cdleonard/pyt32/blob/main/t32/ctypes.py) (ctypes transport), [`t32/__main__.py`](https://github.com/cdleonard/pyt32/blob/main/t32/__main__.py) (CLI commands), [`t32/t32remcmd.py`](https://github.com/cdleonard/pyt32/blob/main/t32/t32remcmd.py) (t32rem transport), [`t32/gdb.py`](https://github.com/cdleonard/pyt32/blob/main/t32/gdb.py) (GDB commands)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_cli["CLI commands<br/>[__main__.py]"]
  node_gdb_commands["GDB commands<br/>[gdb.py]"]
end

subgraph group_interfaces["Interfaces"]
  node_ctypes["ctypes transport<br/>[ctypes.py]"]
  node_remcmd["t32rem transport<br/>[t32remcmd.py]"]
end

subgraph group_shared["Shared API"]
  node_factory["Interface factory<br/>[__init__.py]"]
  node_contract["Interface contract<br/>[base.py]"]
  node_echo_parser["Echo parser<br/>[__init__.py]"]
end

node_user(("User"))
node_gdb_user(("GDB user"))
node_trace32["TRACE32"]
node_t32rem_tool["t32rem tool"]
node_gdb_monitor["GDB monitor"]

node_user -->|"runs commands"| node_cli
node_cli -->|"gets interface"| node_factory
node_factory -->|"creates default"| node_ctypes
node_cli -->|"invokes methods"| node_contract
node_ctypes -->|"implements"| node_contract
node_remcmd -->|"implements"| node_contract
node_gdb_commands -->|"dispatches commands"| node_cli
node_gdb_user -->|"invokes commands"| node_gdb_commands
node_gdb_commands -->|"executes monitor"| node_gdb_monitor
node_gdb_monitor -->|"sends commands"| node_trace32
node_ctypes -->|"calls C API"| node_trace32
node_remcmd -->|"runs subprocess"| node_t32rem_tool
node_t32rem_tool -.->|"forwards commands"| node_trace32
node_ctypes -->|"parses echo"| node_echo_parser
node_remcmd -->|"parses echo"| node_echo_parser

click node_cli "https://github.com/cdleonard/pyt32/blob/main/t32/__main__.py"
click node_gdb_commands "https://github.com/cdleonard/pyt32/blob/main/t32/gdb.py"
click node_factory "https://github.com/cdleonard/pyt32/blob/main/t32/__init__.py"
click node_contract "https://github.com/cdleonard/pyt32/blob/main/t32/base.py"
click node_echo_parser "https://github.com/cdleonard/pyt32/blob/main/t32/__init__.py"
click node_ctypes "https://github.com/cdleonard/pyt32/blob/main/t32/ctypes.py"
click node_remcmd "https://github.com/cdleonard/pyt32/blob/main/t32/t32remcmd.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_gdb_commands,node_user,node_gdb_user toneBlue
class node_ctypes,node_remcmd toneAmber
class node_factory,node_contract,node_echo_parser toneMint
class node_trace32,node_t32rem_tool,node_gdb_monitor toneIndigo
```

## Components

### Entry points

- [CLI commands](https://github.com/cdleonard/pyt32/blob/main/t32/__main__.py): `t32/__main__.py`
- [GDB commands](https://github.com/cdleonard/pyt32/blob/main/t32/gdb.py): `t32/gdb.py`

### Interfaces

- [ctypes transport](https://github.com/cdleonard/pyt32/blob/main/t32/ctypes.py): `t32/ctypes.py`
- [t32rem transport](https://github.com/cdleonard/pyt32/blob/main/t32/t32remcmd.py): `t32/t32remcmd.py`

### Shared API

- [Interface factory](https://github.com/cdleonard/pyt32/blob/main/t32/__init__.py): `t32/__init__.py`
- [Interface contract](https://github.com/cdleonard/pyt32/blob/main/t32/base.py): `t32/base.py`
- [Echo parser](https://github.com/cdleonard/pyt32/blob/main/t32/__init__.py): `t32/__init__.py`

### Other components

- **User**
- **GDB user**
- **TRACE32**
- **t32rem tool**
- **GDB monitor**

## Connections

- User → CLI commands: runs commands (evidence: `t32/__main__.py`)
- CLI commands → Interface factory: gets interface (evidence: `t32/__main__.py`)
- Interface factory → ctypes transport: creates default (evidence: `t32/__init__.py`)
- CLI commands → Interface contract: invokes methods (evidence: `t32/__main__.py`)
- ctypes transport → Interface contract: implements (evidence: `t32/ctypes.py`)
- t32rem transport → Interface contract: implements (evidence: `t32/t32remcmd.py`)
- GDB commands → CLI commands: dispatches commands (evidence: `t32/gdb.py`)
- GDB user → GDB commands: invokes commands (evidence: `t32/gdb.py`)
- GDB commands → GDB monitor: executes monitor (evidence: `t32/gdb.py`)
- GDB monitor → TRACE32: sends commands
- ctypes transport → TRACE32: calls C API (evidence: `t32/ctypes.py`)
- t32rem transport → t32rem tool: runs subprocess (evidence: `t32/t32remcmd.py`)
- t32rem tool → TRACE32: forwards commands
- ctypes transport → Echo parser: parses echo (evidence: `t32/ctypes.py`)
- t32rem transport → Echo parser: parses echo (evidence: `t32/t32remcmd.py`)
