[fpc-pascal] One experience with the unit serial
brad at wasp.net.au
Thu Nov 19 09:20:06 CET 2009
Holger Bruns wrote:
> one more question regarding the unit serial. I use the following
> function to get one single byte form a serial port, which has been open
> before with seropen:
> function getdata(inhandle: tserialhandle; var recdata: char): longint;
> fillchar(inbuffer, sizeof(inbuffer), #0);
> getdata := serread(inhandle, inbuffer, 1);
> recdata := inbuffer
> I repeat this function as long as I need to read data from a serial
> port, byte by byte. One interesting error occurs at the 52478th byte:
> serread returns 0 instead of 1. How can I get it work properly?
The answer to that probably depends on a bit more information that you have provided in your question.
Is your port open blocking or non-blocking?
Are you checking the handle for readability using Select() prior to trying to read a byte from it?
Have you traced the program using strace to see what the syscall is actually returning from the kernel?
Are you sure you have data waiting for you?
Dolphins are so intelligent that within a few weeks they can
train Americans to stand at the edge of the pool and throw them
More information about the fpc-pascal