[Lazarus] Portable way to enumerate serial ports?

Paul Breneman list2010 at BrenemanLabs.com
Sat Nov 27 15:12:53 CET 2010

Bo Berglund wrote:
> Is there a way that one can use to list the actual serial ports
> available on a system that will work on both Windows and Linux?
> That is, is there a class/method or such already coded to give me a
> list of com ports when called?
> The com ports are differently named in Windows and Linux, but it
> should be possible to get a list of ports actually available.
> But not using a listing of dev with ttys in the name, because I have
> found that in my test Linux systems there are always 4 of these even
> though there is only hardware for a single port...

I haven't found a very good way for Linux.  I modified the SynaSer Linux 
code for the GetSerialPortNames function in the code on this page:

Here is what I scan on Linux:
     ScanForPorts( '/dev/ttyS*');
     ScanForPorts( '/dev/ttyUSB*');
     ScanForPorts( '/dev/ttyAM*'); // for ARM board

More information about the Lazarus mailing list