> I have not completely understood the difference between this two functions
> (waitingdata/waitingdataex).
> In my understanding, the waitingdata function gives the number of bytes that
> are in the OS buffer, while waitingdataex gives the sum of bytes in the OS
> buffer + bytes in the HW buffer?
> Has anyone an advice in which case to use which function?

WaitingData working with OS level only. It return true if something 
is in OS buffers. Otherwise it waits until serial port receive some 
data.

WaitingDataEX returns true, if some data laying in Synaser internal 
buffer. Otherwise it call WaitingData.

In normal case you do not need WaitingData* at all! It is needed if 
you are using low-level access to serial port only. 
Better to use high-level reading functions (all with timeout 
parameter), they are calling waitingdata internally when it is 
needed.

> And a second question if I may:
> For the Recv. functions there is a timeout, example a:=RecvByte(50)
> What happens during thin 50ms timeout?
> When a byte is received during this 50ms, will it be contained in the
> function result?

50ms is not reasonable timeout for reading from the serial port. 
RecvByte is very simple case, because it waiting for one byte only. 
So, if byte is in buffers, it is readed immediately. If buffers are 
empty, Synaser waiting until byte is received. Because you can wait 
forever in some cases, you must define timeout. So, it is maximum 
time for device reaction. After this time you can consider device as 
non-functional. So, preffered timeouts are in seconds.

Look at stronger read function, like RecvString. It reading data in 
loop to Synaser internal buffer, until it found CRLF sequence. 
However all internal subsequent reads using your timeout again. So, 
it is "interpacket timeout", not "overall timeout". In other words, 
it is maximum time for silence on the wires.

Typical usage of Synaser is call command to device and wait for 
reply. AT modem command, for example. You send some command into 
device, and you wish to read response. But what to do when device is 
not connected or busy? How long you wish to wait for response? 3 
seconds? OK, then you call SendString with command, and next command 
will be RecvString with 3000ms timeout. It is all! You got response 
soon as possible, or timeout error after cca 3000ms and you know - 
device not responding.

It is very simple. With RecvString, RecvTerminated and RecvBufferEx 
you can implement high-level reading for any protocol.

Hope this help you.


-- 
Lukas Gebauer.

http://synapse.ararat.cz/ - Ararat Synapse - TCP/IP Lib.
https://www.geoget.cz/ - Geocaching solution



_______________________________________________
synalist-public mailing list
synalist-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synalist-public

Reply via email to