What is the cross-platform method of enumerating serial ports in Python (including virtual ports)?

This is what I’ve been using. It’s a mashup of the methods I posted above. I’d still like to see better solutions, though. # A function that tries to list serial ports on most common platforms def list_serial_ports(): system_name = platform.system() if system_name == “Windows”: # Scan for available ports. available = [] for i … Read more

Create a virtual serial port connection over TCP

Try socat. Possible scenario: socat pty,link=/dev/virtualcom0,raw tcp:192.168.254.254:8080& socat creates TCP connection to 192.168.254.254:8080, so that everything, that will be written to /dev/virtualcom0 will be forwarded to 192.168.254.254:8080 and vice versa. Another approach would be to use RFC2217 via ser2net on Linux sever side and RFC2217 driver on Windows side (for example http://www.hw-group.com/products/hw_vsp/index_en.html single port version). … Read more

How to toggle CR/LF in gnu screen?

onlcr is for translating outgoing newlines to carriage returns. stty -F /dev/ttyS0 inlcr will translate incoming newlines to carriage returns. You can run that from another terminal after starting screen to avoid any resetting that screen may do on startup. Unfortunately however, this will only change the problem. You’ll then get only returns and no … Read more

Linux Blocking vs. non Blocking Serial Read

The code you mention is IMO poorly coded and commented. That code does not conform to POSIX practices for portability as described in Setting Terminal Modes Properly and Serial Programming Guide for POSIX Operating Systems. That code does not mention that it uses non-canonical (aka raw) mode, and reuses the “blocking” and “nonblocking” terminology to … Read more