Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 04-15-2005, 02:21 PM   #1
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...

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

st4=serial_write (st1,ip,size);

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

if (st3>0)
st5=serial_read (st2, op,size);
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


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, 02: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:


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.


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 06:20 AM
serial port communication vidyaraj Linux - Software 2 03-14-2004 11:32 PM
communication with serial port vidyaraj Linux - Hardware 0 03-09-2004 08:32 PM
serial port communication vidyaraj Linux - Software 6 03-02-2004 06:46 PM
communication via serial port perdesiz Linux - Software 0 11-13-2003 06:23 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:22 AM.

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