LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices

Reply
 
Search this Thread
Old 03-02-2010, 06:49 AM   #1
Dan.b
LQ Newbie
 
Registered: Sep 2009
Posts: 6

Rep: Reputation: 0
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
 
Old 03-02-2010, 06:31 PM   #2
Dan.b
LQ Newbie
 
Registered: Sep 2009
Posts: 6

Original Poster
Rep: Reputation: 0
If anyone else has the same problem I just used

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


Reply

Tags
binary, read, serial


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Serial port reading jayadhanesh Linux - Newbie 3 05-19-2009 06:54 PM
Reading a bash variable in bash scripting problem freeindy Programming 3 11-27-2008 02:29 AM
reading from serial port IC009562 Linux - Software 2 11-08-2007 11:25 PM
Having trouble reading from serial port glo Linux - Newbie 0 02-09-2007 10:42 AM
Bash Sleep vs crontab and bash serial port nutthick Programming 4 06-01-2006 02:42 AM


All times are GMT -5. The time now is 12:29 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration