We have set the timeout in the example above to 1000 milliseconds, or one second. If no data is available within the time limits set by 'SetCommTimeouts' the call will return zero bytes read and hence we will have a zero length string. Note that some conversion is required to get the data back to a Pascal style string because we pass a raw buffer to the function. The following is an example of using the 'ReadFile' function to read data from the serial port. This is achieved using the Win32 'CreateFile' function. Opening the serial portįirst step is to open the communications device for read/write. This document gives a brief introduction to serial communications under Delphi 2.0 - it does not cover event-driven applications. This varies considerably from 16-bit code as access to the communications ports is achieved through file handles. When writing Delphi 2.0 communications applications it is necessary to use the Win32 interface to the serial ports. Peter has written a number of articles, components and applications, unfortunately the web address we have is no longer valid, if you know where it is now please let us know. This article was written by Peter Johnson.
0 Comments
Leave a Reply. |