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

Graeme Geldenhuys graemeg.lists at gmail.com
Thu Dec 13 08:22:19 CET 2007


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?

3.  Does my 'hangup the phone' string look correct?

---------------------[ Start ]----------------------------------
      s := ComPortToString;
      serialhandle := SerOpen(s);
      s := 'ATDT' + FNumberToDial + #13+#10;   //Create a string to
send to modem.
      writecount := 0;
      status := SerWrite(serialhandle, s, writecount);

      // The next line is for debugging only!
      writeln('status: ', status, '   writecount: ', writecount);

      if status > 0 then  // What am I supposed to test for???
        ShowMessage('Pick up the phone.' + #13 + 'Click OK after
dialing has completed.');
        s := 'ATH^M^J';
        status := SerWrite(serialhandle, s, writecount);
        ShowMessage('Unable to dial number.');
---------------------[ END ]----------------------------------

  - Graeme -

fpGUI - a cross-platform Free Pascal GUI toolkit

More information about the fpc-pascal mailing list