LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-15-2005, 03:21 PM   #1
prems
LQ Newbie
 
Registered: Mar 2005
Posts: 9

Rep: Reputation: 0
serial port communication


I amtrying to send a set of specific strings thro my serial port...
string1="123Sm0"
string2="12345SMr"
string3="2"

The strings are sent to a device which returns them back .
I do this as follows


st4=serial_write (st1,ip,size);
sleep(5);

st3=serial_bytes_waiting(st2 );
printf("number of bytes in in buffer is %d and out buffer is %d\n",
st3,st4);


if (st3>0)
{
st5=serial_read (st2, op,size);
tcdrain(st2);
}
printf("\nnumber of bytes in reader buffer %d ",st5);
printf("\nRecieved word is %s\n",op);

It is important that my connection remain throughout . my out but for recieved string is

123Sm0
12345Smr
22345Smr

It seems like when I send a new write comman either the write buffer, read buffer or both do not get cleared( probably more importantly the write ause my device is not behaving)

How do I clear my buffer without having to cut my connetion....both file descriptors are rd,wr........and i tried tcdrain...doesnt work
 
Old 04-17-2005, 03:31 AM   #2
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
have you tried:

http://www.tldp.org/HOWTO/Serial-HOWTO.html#toc16

???

While you are obviously not totally new, there is a lot of discussion of buffers and so on. I gather that the serial buffer is cleared by a command to the driver. But I only skimmed.
 
  


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
gtk serial port communication prems Programming 11 02-29-2016 07:20 AM
serial port communication vidyaraj Linux - Software 2 03-15-2004 12:32 AM
communication with serial port vidyaraj Linux - Hardware 0 03-09-2004 09:32 PM
serial port communication vidyaraj Linux - Software 6 03-02-2004 07:46 PM
communication via serial port perdesiz Linux - Software 0 11-13-2003 07:23 AM


All times are GMT -5. The time now is 07:14 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration