Reputation: 61
I am trying to read data from a serial port on Raspberry Pi using the stty command like this.
stty -F /dev/ttyACM0 115200 min 0 time 10
cat < /dev/ttyACM0
What I'm expecting is that the cat command will read data only for 1s (referring to the man page of stty). But the cat command is reading data continuously. How can I read data only for 1 second?
Upvotes: 0
Views: 1830
Reputation: 61
I myself solved it after multiple attempts. I am posting the answer as it might help someone.
stty -F /dev/ttyACM0 115200 -xcase -icanon min 0 time 10
cat < /dev/ttyACM0
The timeout is N tenths of a second. So if you want to read data for N seconds set timeout to N*10 seconds
Upvotes: 4