Example code how to transfer data over serial communication on Linux, both read and write.
sudo apt install socat
pip install pyserial
pip install pyserial-asyncio# All
make
# Single file
g++ -o <output file name> <file to compile>.cppcd rust
cargo run --bin <file to run>All programs accept the serial port path as a command-line argument.
You can run a full cross-test of all C++, Rust, and Python implementations using the provided script:
python3 test_all.pyThis script will set up virtual ports using socat and verify communication across all reader/writer combinations (ensure C++ programs are compiled first).
socat -d -d pty,raw,echo=0 pty,raw,echo=0It will create 2 addresses (e.g., /dev/pts/12 and /dev/pts/13).
# C++
./cpp/read_sync /dev/pts/12
# Python
python3 python/read.py /dev/pts/12
# Rust
cd rust
cargo run --bin read_sync -- /dev/pts/12# C++
./cpp/write_sync /dev/pts/13
# Python
python3 python/write.py /dev/pts/13
# Rust
cd rust
cargo run --bin write_sync -- /dev/pts/13- Forth
- Rexx
- Focal
- Rapira
- Modula
- Prolog
- Cobol
- Ruby
- ASM X86