[fpc-pascal] One experience with the unit serial

Holger Bruns holger.bruns at gmx.net
Wed Nov 18 14:16:04 CET 2009


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[0], 1);
 recdata := inbuffer[0]

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?

Best regards, Holger

More information about the fpc-pascal mailing list