mikelbrady
11-21-2002, 11:28 AM
Hi folks, first time post. I did a search on this, but could not find what I needed. I am trying to use the serial port to log the data coming in to a file. This is connected to a device that outputs a line of data every couple seconds. I am able to grab a line of data, which is what I want, but I am have to manually hit Ctrl C to end the script. I want to have the script end after a line of data is recieved from the device. Here is what my script looks like right now:
#!/bin/bash
stty -F /dev/ttyS0 quit \012
cat /dev/ttyS0 >> logfile.txt
Using this script it will listen to the serial port and write the input to the text file, bit then it just sit's there waiting. I thought by adding the quit \012 to the stty line I would be telling it to quit when it recieves a carriage return. If I hit enter on the keyboard it does end the script, but when connected to my device, or even a terminal, hitting enter on the terminal does not end the script. How do a I get this to end the CAT command or the script based on imput from the serial port? I feel like I am almost there.....
#!/bin/bash
stty -F /dev/ttyS0 quit \012
cat /dev/ttyS0 >> logfile.txt
Using this script it will listen to the serial port and write the input to the text file, bit then it just sit's there waiting. I thought by adding the quit \012 to the stty line I would be telling it to quit when it recieves a carriage return. If I hit enter on the keyboard it does end the script, but when connected to my device, or even a terminal, hitting enter on the terminal does not end the script. How do a I get this to end the CAT command or the script based on imput from the serial port? I feel like I am almost there.....