[Lazarus] Usage of Serial in a testing program?
Bo Berglund
bo.berglund at gmail.com
Sun Sep 23 10:01:45 CEST 2018
On Sun, 23 Sep 2018 08:39:52 +0200, Bo Berglund via Lazarus
<lazarus at lists.lazarus-ide.org> wrote:
>I have now come as far in my application as I can test the way the
>Serial unit opens and closes com ports.
>It turns out that on Windows there are two port name syntaxes:
>
>Ports 1..9: COM1 to COM9 will work
>Ports 10..255: Only \\.\COM10 to \\.\COM255 will work
>
>But one does not need to use different naming depending on the port
>number, the second syntax \\.\COMx works also for ports 1..9
Forgot to add a question regarding making this a cross-platform
program:
If I add a check for the platform inside my program, how sghould it
look like to work on both Windows and Linux?
Something like this:
function TWiFiCommTester.ConnectSerial(Port: byte; Baud: integer):
boolean;
var
ComportName: string;
Flags: TSerialFlags;
begin
FLastError := '';
{$IFDEF WINDOWS}
ComPortName:= '\\.\COM' + IntToStr(Port);
{$ENDIF}
{$IFDEF UNIX}
//What goes here?
ComPortName := ????
{$ENDIF}
FSerial := SerOpen(ComPortName);
....
--
Bo Berglund
Developer in Sweden
More information about the Lazarus
mailing list