[fpc-pascal] Access to RS232 ports with fpc

Jonas Maebe jonas.maebe at elis.ugent.be
Mon Nov 2 09:38:12 CET 2009


Holger Bruns wrote on Mon, 02 Nov 2009:

> Martin schrieb:
>> you can do:
>> var buffer: Array of byte;
>>
>> SetLength(Buffer, 1000);
>> SerRead(Handle, Buffer[0], 1000);
>
> I checked this out. It works not reliable. Sometimes I get real  
> data, sometimes the data are corrupted. I have no idea to rule out  
> corrupted data.

You have to check the result of the serread routine. Since it returns  
the result of the fpread call, "man 2 read" will tell you what those  
results mean. In short,
a) result >= 0: actual number of bytes read (the 1000 you pass is just  
a maximum)
b) result < 0: an error occurred


Jonas

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.




More information about the fpc-pascal mailing list