LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-21-2009, 02:53 PM   #1
linux_chris
LQ Newbie
 
Registered: Dec 2008
Posts: 18

Rep: Reputation: 0
Problem reading serial port


Hi, I have a server which is listening to multiple sources (tty0, tty1 and parport0). I am using select() with a timeout and I am able to get the data from all sources. But read() is not able to catch all the data which is coming from the COM (tty0, tty1) sources. I mean, it is able to read only 16-20 bytes at a time. If I use usleep(), before the read(), I am able to get all data. Do we have any mechanism to wait till all the data arrives except sleep()/usleep()?

Thanks in advance.

-Chris
 
Old 01-21-2009, 05:10 PM   #2
vladmihaisima
Member
 
Registered: Oct 2002
Location: Delft, Netherlands
Distribution: Gentoo
Posts: 196

Rep: Reputation: 33
As the serial has a very slow speed, obviously the data will arrive 'slower'. You should use read() in a while, until all the data has arrived. Of course, this means you have a protocol - a way of determining when you have transferred all the data that you need. Without further information I do not know what would be best for your case.
 
Old 02-04-2009, 08:55 PM   #3
linux_chris
LQ Newbie
 
Registered: Dec 2008
Posts: 18

Original Poster
Rep: Reputation: 0
Vlad-Mihai Sima,

I have resoved the issue by adding a string terminator after each command.

Thank you,
Chris
 
  


Reply


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
Reading and Writing to a Serial Port without SU Steef223 Programming 2 06-16-2008 10:16 AM
reading from serial port IC009562 Linux - Software 2 11-09-2007 12:25 AM
Having trouble reading from serial port glo Linux - Newbie 0 02-09-2007 11:42 AM
help reading data from a serial port skydemon Linux - General 1 08-10-2006 09:48 AM
reading data from a serial port mchitrakar Linux - Networking 3 12-04-2004 02:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:28 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration