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
|