In Cygwin, I am trying to read serial port input, filter it to remove nul characters, and save the output to a file. Something like the following, which results in an empty logfile:
cat /dev/ttyS1 | tr -d '\000' >myfile.log
This shows stdout on the terminal:
cat /dev/ttyS1 | tr -d '\000'
I tried using stdbuf -oL -eL
, per this post, to no avail.
Bonus points if you can get it to work with grep filtering stdout on the terminal (i.e., log everything to file, but only see filtered output on the terminal).
cat /dev/ttyS1 | tr -d '\000' | tee myfile.log | egrep --line-buffered "WARN|ERROR"
Note: The serial port I am using is an FTDI USB serial adapter.
/dev/ttyS1
exist ?/dev/ttyS1
as an example. The serial port I'm using on this particular machine is different and does exist (I can read input usingcat /dev/ttyS1
).cat /dev/ttyS1
works andcat /dev/ttyS1 | tr -d '\000'
produces nothing it seems your serial port is only producing nullcat /dev/ttyS1 > tempfile
andcat tempfile | tr -d '\000'
?