# windywhu/serial_and_network_communication architecture

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

- Interactive diagram: https://gitdiagram.com/windywhu/serial_and_network_communication
- Repository: https://github.com/windywhu/serial_and_network_communication

## Overview

This is a Windows MFC communication utility with separate serial-port and TCP tabs. Users configure a serial port or run a TCP client/server, exchange text or binary/hex data, and view or clear communication records; the server can select a connected client. The serial library supplies a cross-platform API and platform-specific I/O. The graph follows the sampled UI and serial-library references; network internals and several serial implementation details were not sampled, so uncertain links are omitted.

Main entry points: [`CSerialPort/src/SerialPortWinBase.cpp`](https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/src/SerialPortWinBase.cpp) (Windows I/O), [`CSerialPort/src/SerialPort.cpp`](https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/src/SerialPort.cpp) (Serial API), [`CSerialPort/src/SerialPortUnixBase.cpp`](https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/src/SerialPortUnixBase.cpp) (Unix I/O), [`communication/CTabDlg1.cpp`](https://github.com/windywhu/serial_and_network_communication/blob/master/communication/CTabDlg1.cpp) (Serial Tab)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Application UI"]
  node_app["MFC Main Dialog"]
  node_serialtab["Serial Tab<br/>[CTabDlg1.cpp]"]
end

subgraph group_net["TCP Communication"]
  node_tcptab["TCP Tab<br/>[CTabDlg2.cpp]"]
  node_clientdlg["Client Selector<br/>[CConnectDlg.cpp]"]
end

subgraph group_serial["Serial Port"]
  node_serialapi["Serial API<br/>[SerialPort.cpp]"]
  node_serialbase["Serial Base<br/>[SerialPortBase.cpp]"]
  node_serialwin["Windows I/O"]
  node_serialunix["Unix I/O"]
  node_portinfo["Port Discovery<br/>[SerialPortInfo.cpp]"]
  node_wininfo["Windows Discovery"]
  node_unixinfo["Unix Discovery"]
end

subgraph group_support["Serial Runtime"]
  node_listener["Read Listener"]
  node_buffer["Ring Buffer<br/>[ibuffer.hpp]"]
  node_thread["Thread Primitives<br/>[ithread.hpp]"]
  node_timer["Read Timer<br/>[itimer.hpp]"]
  node_utils["Serial Utilities<br/>[iutils.hpp]"]
end

node_user(("Operator"))
node_peer(("TCP Peer"))
node_serialdevice(("Serial Device"))

node_user -->|"opens"| node_app
node_app -->|"creates tab"| node_serialtab
node_app -->|"creates tab"| node_tcptab
node_user -.->|"configures and uses"| node_serialtab
node_user -.->|"configures and uses"| node_tcptab
node_tcptab -->|"opens selector"| node_clientdlg
node_tcptab -.->|"exchanges data"| node_peer
node_serialtab -->|"uses"| node_serialapi
node_serialapi -.->|"delegates to"| node_serialbase
node_serialapi -->|"uses on Windows"| node_serialwin
node_serialapi -->|"uses on Unix"| node_serialunix
node_serialtab -.->|"communicates with"| node_serialdevice
node_serialapi -->|"uses"| node_timer
node_serialwin -->|"notifies"| node_listener
node_serialunix -->|"notifies"| node_listener
node_serialwin -.->|"buffers reads"| node_buffer
node_serialunix -.->|"buffers reads"| node_buffer
node_serialwin -->|"uses"| node_thread
node_serialunix -->|"uses"| node_thread
node_serialwin -->|"uses"| node_timer
node_serialunix -->|"uses"| node_timer
node_serialwin -->|"uses"| node_utils
node_portinfo -.->|"dispatches"| node_wininfo
node_portinfo -.->|"dispatches"| node_unixinfo
node_wininfo -->|"uses"| node_utils
node_unixinfo -->|"uses"| node_utils

click node_app "https://github.com/windywhu/serial_and_network_communication/blob/master/communication/communicationDlg.cpp"
click node_serialtab "https://github.com/windywhu/serial_and_network_communication/blob/master/communication/CTabDlg1.cpp"
click node_tcptab "https://github.com/windywhu/serial_and_network_communication/blob/master/communication/CTabDlg2.cpp"
click node_clientdlg "https://github.com/windywhu/serial_and_network_communication/blob/master/communication/CConnectDlg.cpp"
click node_serialapi "https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/src/SerialPort.cpp"
click node_serialbase "https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/src/SerialPortBase.cpp"
click node_serialwin "https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/src/SerialPortWinBase.cpp"
click node_serialunix "https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/src/SerialPortUnixBase.cpp"
click node_portinfo "https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/src/SerialPortInfo.cpp"
click node_wininfo "https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/src/SerialPortInfoWinBase.cpp"
click node_unixinfo "https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/src/SerialPortInfoUnixBase.cpp"
click node_listener "https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/include/CSerialPort/SerialPortListener.h"
click node_buffer "https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/include/CSerialPort/ibuffer.hpp"
click node_thread "https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/include/CSerialPort/ithread.hpp"
click node_timer "https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/include/CSerialPort/itimer.hpp"
click node_utils "https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/include/CSerialPort/iutils.hpp"

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_app,node_serialtab toneBlue
class node_tcptab,node_clientdlg toneAmber
class node_serialapi,node_serialbase,node_serialwin,node_serialunix,node_portinfo,node_wininfo,node_unixinfo toneMint
class node_listener,node_buffer,node_thread,node_timer,node_utils toneRose
class node_user,node_peer,node_serialdevice toneIndigo
```

## Components

### Application UI

- [MFC Main Dialog](https://github.com/windywhu/serial_and_network_communication/blob/master/communication/communicationDlg.cpp): `communication/communicationDlg.cpp`
- [Serial Tab](https://github.com/windywhu/serial_and_network_communication/blob/master/communication/CTabDlg1.cpp): `communication/CTabDlg1.cpp`

### TCP Communication

- [TCP Tab](https://github.com/windywhu/serial_and_network_communication/blob/master/communication/CTabDlg2.cpp): `communication/CTabDlg2.cpp`
- [Client Selector](https://github.com/windywhu/serial_and_network_communication/blob/master/communication/CConnectDlg.cpp): `communication/CConnectDlg.cpp`

### Serial Port

- [Serial API](https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/src/SerialPort.cpp): `CSerialPort/src/SerialPort.cpp`
- [Serial Base](https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/src/SerialPortBase.cpp): `CSerialPort/src/SerialPortBase.cpp`
- [Windows I/O](https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/src/SerialPortWinBase.cpp): `CSerialPort/src/SerialPortWinBase.cpp`
- [Unix I/O](https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/src/SerialPortUnixBase.cpp): `CSerialPort/src/SerialPortUnixBase.cpp`
- [Port Discovery](https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/src/SerialPortInfo.cpp): `CSerialPort/src/SerialPortInfo.cpp`
- [Windows Discovery](https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/src/SerialPortInfoWinBase.cpp): `CSerialPort/src/SerialPortInfoWinBase.cpp`
- [Unix Discovery](https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/src/SerialPortInfoUnixBase.cpp): `CSerialPort/src/SerialPortInfoUnixBase.cpp`

### Serial Runtime

- [Read Listener](https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/include/CSerialPort/SerialPortListener.h): `CSerialPort/include/CSerialPort/SerialPortListener.h`
- [Ring Buffer](https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/include/CSerialPort/ibuffer.hpp): `CSerialPort/include/CSerialPort/ibuffer.hpp`
- [Thread Primitives](https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/include/CSerialPort/ithread.hpp): `CSerialPort/include/CSerialPort/ithread.hpp`
- [Read Timer](https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/include/CSerialPort/itimer.hpp): `CSerialPort/include/CSerialPort/itimer.hpp`
- [Serial Utilities](https://github.com/windywhu/serial_and_network_communication/blob/master/CSerialPort/include/CSerialPort/iutils.hpp): `CSerialPort/include/CSerialPort/iutils.hpp`

### Other components

- **Operator**
- **TCP Peer**
- **Serial Device**

## Connections

- Operator → MFC Main Dialog: opens (evidence: `communication/communicationDlg.cpp`)
- MFC Main Dialog → Serial Tab: creates tab (evidence: `communication/communicationDlg.cpp`)
- MFC Main Dialog → TCP Tab: creates tab (evidence: `communication/communicationDlg.cpp`)
- Operator → Serial Tab: configures and uses
- Operator → TCP Tab: configures and uses
- TCP Tab → Client Selector: opens selector (evidence: `communication/CTabDlg2.cpp`)
- TCP Tab → TCP Peer: exchanges data
- Serial Tab → Serial API: uses
- Serial API → Serial Base: delegates to
- Serial API → Windows I/O: uses on Windows (evidence: `CSerialPort/src/SerialPort.cpp`)
- Serial API → Unix I/O: uses on Unix (evidence: `CSerialPort/src/SerialPort.cpp`)
- Serial Tab → Serial Device: communicates with
- Serial API → Read Timer: uses (evidence: `CSerialPort/src/SerialPort.cpp`)
- Windows I/O → Read Listener: notifies (evidence: `CSerialPort/src/SerialPortWinBase.cpp`)
- Unix I/O → Read Listener: notifies (evidence: `CSerialPort/src/SerialPortUnixBase.cpp`)
- Windows I/O → Ring Buffer: buffers reads
- Unix I/O → Ring Buffer: buffers reads
- Windows I/O → Thread Primitives: uses (evidence: `CSerialPort/src/SerialPortWinBase.cpp`)
- Unix I/O → Thread Primitives: uses (evidence: `CSerialPort/src/SerialPortUnixBase.cpp`)
- Windows I/O → Read Timer: uses (evidence: `CSerialPort/src/SerialPortWinBase.cpp`)
- Unix I/O → Read Timer: uses (evidence: `CSerialPort/src/SerialPortUnixBase.cpp`)
- Windows I/O → Serial Utilities: uses (evidence: `CSerialPort/src/SerialPortWinBase.cpp`)
- Port Discovery → Windows Discovery: dispatches
- Port Discovery → Unix Discovery: dispatches
- Windows Discovery → Serial Utilities: uses (evidence: `CSerialPort/src/SerialPortInfoWinBase.cpp`)
- Unix Discovery → Serial Utilities: uses (evidence: `CSerialPort/src/SerialPortInfoUnixBase.cpp`)
