LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Reading serial using BASH (https://www.linuxquestions.org/questions/linux-hardware-18/reading-serial-using-bash-792591/)

Dan.b 03-02-2010 06:49 AM

Reading serial using BASH
 
Hello,

I am having a problem reading serial with bash. I just want it to read a single response (two ints send in the form 15 21\n) then exit.
So far the code closest to working is but that prints forever. The second code does not return the values.

[dan.b@dan-laptop bin]$ cat /dev/ttyUSB1 | while read i j LINE; do echo -n "$i,";echo $j; done
15,21
15,21
15,21
15,21
15,21
15,21
^C
[dan.b@dan-laptop bin]$ cat /dev/ttyUSB1 | read i j LINE;echo -n "$i,";echo $j
,
[dan.b@dan-laptop bin]$

Thanks

Dan.b

Dan.b 03-02-2010 06:31 PM

If anyone else has the same problem I just used

head -n 1 instead and outputted a newline char when sending


All times are GMT -5. The time now is 09:05 AM.