Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • This is very good because it automates the process! The only change I would make, which is totally optional, is to confirm the contents received is the same as sent - could be just a count or full on diff. Commented Feb 5, 2019 at 19:55
  • 2
    As I warp above code in bash function and call my entire script in loop by watch -n 0.2 ./send.sh I discover that after few calls or when send CTRL+C signal and re-execute it, my output data are printed in oddly way. The reason is about left cat-s process that have simulations access to my port. You can list that by lsof /dev/ttyUSB0 So I add lsof -t /dev/ttyUSB0 | xargs -r kill -9 at the beginning, to be sure that only one cat process exists in a given runtime of my function.
    – MrHetii
    Commented Feb 18, 2023 at 16:40
  • It might be better to switch the order of the first two commands — exec 3< and then stty.  Opening the device (with exec 3<) locks it into an “open” status, which should ensure that settings are persistent.  If you do the stty first, the device will be closed and the settings might be reset. Commented May 17, 2023 at 21:47