serial-comm-kit
日本語 README
A toolset for communicating with serial devices such as RS-232C instruments.
Each tool runs once per request (start → communicate → exit) with no resident process, designed to be called from Excel VBA via WScript.Shell.Exec.
| Tool |
Type |
Role |
serial_request.exe |
Go CLI |
Sends a command and prints the response to stdout |
serial_receiver.exe |
Go CLI |
Receives unsolicited data from a device (no sending) and prints it to stdout |
serial_debugger.exe |
Wails GUI |
Launches the two CLI tools and shows arguments, stdout, and exit codes |
Common behavior: errors are written to stdout with an ERR: prefix (exit code 1). Binary responses can be printed as uppercase hex strings (e.g. 023031037A) with -recv-format hex.
Download
Grab the zip from Releases. It contains:
serial_debugger.exe
bin\serial_request.exe, serial_receiver.exe ← console builds
noconsole\serial_request.exe, serial_receiver.exe ← no-console builds for Excel
Build
# CLI
go build -o bin/serial_request.exe ./cmd/serial_request
go build -o bin/serial_receiver.exe ./cmd/serial_receiver
# No-console builds for Excel integration
go build -ldflags="-H windowsgui" -o noconsole/serial_request.exe ./cmd/serial_request
go build -ldflags="-H windowsgui" -o noconsole/serial_receiver.exe ./cmd/serial_receiver
# GUI (requires Wails v2 / Node.js)
cd serial_debugger_wails
wails build -clean # → build/bin/serial_debugger.exe
Usage
# Send a command and read one line
serial_request.exe -port COM7 -baud 9600 -cmd SI -recv-mode first-line -timeout 2000
# Send a hex command, read 8 bytes, print as hex
serial_request.exe -port COM7 -cmd-hex "02 30 31 03" -send-term none -recv-mode bytes -bytes 8 -recv-format hex
# Keep receiving for 5 seconds (PRINT output, barcode readers, etc.)
serial_receiver.exe -port COM7 -recv-mode duration -duration 5
Run serial_request.exe -h / serial_receiver.exe -h for the full flag list.
Examples
Working samples for each caller are in example/:
Layout (when using the GUI)
serial_debugger.exe
bin\
├─ serial_request.exe
└─ serial_receiver.exe
The GUI auto-detects the CLI paths under bin\ at startup (editable on screen).
Notes
- The release zip targets Windows amd64 only.
serial_debugger.exe is built with Wails and requires the WebView2 runtime (preinstalled on Windows 10/11).
- The executables are unsigned, so SmartScreen may warn on first run.
- A COM port can be opened by only one application at a time —
ERR: open failed usually means the port name is wrong or another app holds the port.
License
MIT
评论