Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.