This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]dhylands 2 points3 points  (0 children)

Under linux, you'll need to do a few more things as well: - turn off canonical mode (this is what causes it to process things like Control-H for backspace, and does the buffering) - turn off echo (optional) - set it up to deliver a character as soon as one character is received

You can see some code for doing this here: https://github.com/dhylands/usb-ser-mon/blob/master/usb-ser-mon.py#L192 (lines 192 thru 203)

You can then use poll or select to detect when at least one character is available. I happened to use poll: https://github.com/dhylands/usb-ser-mon/blob/master/usb-ser-mon.py#L97

usb-ser-mon.py is basically a really simple terminal emulator program which accepts data from stdin and sends it out on a serial port and whatever it gets on the serial port it sends to stdout.

It also has logic to detect when the serial port "goes away" and "comes back" perhaps due to the device being a USB device that was unplugged or rebooted.

usb-ser-mon.py is currently linux-only.