[fpc-pascal] help with serial.pp unit please

Marc Santhoff M.Santhoff at t-online.de
Thu Dec 13 11:29:42 CET 2007


Am Donnerstag, den 13.12.2007, 09:22 +0200 schrieb Graeme Geldenhuys:
> Hi,
> 
> I'm trying to write a Phone Dialer feature in my application.  I
> managed to do this a long time ago in a Delphi app using Windows API
> calls, but now I need it for Linux and Windows.  Unfortunately the
> serial.pp unit is not documented and searching the FPC src directory
> didn't yield any examples either.
> 
> So the code below is a shot in the dark.  Could anybody familiar with
> the serial.pp unit comment please.  If I get this working, maybe it
> can serve as a simple example of using the serial.pp unit?
> 
> 
> A few notes and questions:
> 
> 1.  ComPortToString will create a string containing the selected com
> port of the OS.  eg Linux = '/dev/tty0'   or under Windows = 'COM1'
> 
> 2.  What status codes does SerWrite() return?  What are valid/invalid codes?

On Unix SerWrite and SerRead return the count of bytes written or read.
On Windows you've got to check yourself ...

So sth. like:

	status := SerWrite(serialhandle, s, Length(s));
	if (status <> Length(s)) then bark;

should be appropriate.

HTH,
Marc





More information about the fpc-pascal mailing list