# Serial Proxy (MITM) A small Python app that sits between the Arduino IDE and a real COM device. It creates (or uses) a **virtual COM port** that you open in the Arduino IDE, while it talks to the **real device** on another port. All traffic is **recorded** both ways and **passed through unchanged**. ## What it does 1. **CLI** — Lists connected COM ports; you choose the real device (e.g. your Arduino). 2. **Virtual port** — Tries to create a virtual COM pair with [com0com](https://sourceforge.net/projects/com0com/); if that fails, you pick one end of an existing pair. 3. **Relay** — Data from Arduino IDE → virtual port → this app → real device, and the reverse. No modification, only copying. 4. **Logging** — Every byte in both directions is logged to `serial_log.txt` (and optionally to the console) with timestamps and hex. ## Requirements - Python 3.10+ - [pyserial](https://pypi.org/project/pyserial/): `pip install -r requirements.txt` - **Virtual COM pair** (for “create virtual port” to work): install [com0com](https://sourceforge.net/projects/com0com/) and, if you want the app to create pairs automatically, run the script (or `setupc.exe`) with **Administrator** rights so it can create port pairs. ## Usage 1. Install dependencies: ```bash pip install -r requirements.txt ``` 2. (Optional) Install com0com and, if needed, run the app as Administrator so it can create a virtual pair. 3. Run the proxy: ```bash python serial_proxy.py ``` 4. Select the **real device** COM port (e.g. the actual Arduino). 5. If the app created a virtual pair, it will tell you which port to select in the Arduino IDE (e.g. COM252). Otherwise, select the end of the pair that **this app** will use; in the Arduino IDE you must select the **other** end of that pair. 6. Enter baud rate (default 115200) or press Enter. 7. In the Arduino IDE, choose the indicated virtual port and use Serial Monitor / upload as usual. All traffic is logged to `serial_log.txt`. Stop with **Ctrl+C**. ## Log file - Path: `serial_log.txt` in the same folder as `serial_proxy.py`. - Each line has timestamp, direction (`IDE->device` or `device->IDE`), byte count, hex dump, and a raw repr of the bytes. ## Without com0com If you don’t install com0com, the app cannot create a virtual pair. You’ll need another way to get a **pair** of linked virtual ports (e.g. another null-modem/virtual serial driver). Then run the app, select the **real** device port, and when asked, select the port that **this app** should open (one end of the pair). Use the **other** end of that pair in the Arduino IDE. ## Summary | You select in the app | You select in Arduino IDE | |------------------------|----------------------------| | Real device (e.g. COM3) | — | | Virtual port “for this app” (e.g. COM251) | The **other** end of the pair (e.g. COM252) | Traffic flows: **Arduino IDE ↔ virtual pair ↔ this app ↔ real device**, with full logging both ways.