[Lazarus] Portable way to enumerate serial ports?

Sven Barth pascaldragon at googlemail.com
Sun Nov 28 10:49:32 CET 2010

On 28.11.2010 00:06, Bo Berglund wrote:
> On Sat, 27 Nov 2010 08:12:53 -0600, Paul Breneman
> <list2010 at BrenemanLabs.com>  wrote:
>> 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:
>>    http://www.turbocontrol.com/simpleserial.htm
>> Here is what I scan on Linux:
>>      ScanForPorts( '/dev/ttyS*');
>>      ScanForPorts( '/dev/ttyUSB*');
>>      ScanForPorts( '/dev/ttyAM*'); // for ARM board
> Are com ports on ARM based embedded Linux named 'ttyAM1', 'ttyAM2'
> etc?

It depends on the driver which the port uses. Besides ttyS*, ttyUSB* and 
ttyAM* I've also found ttyAMA*, ttyPSC*, ttySAC*, ttyUL*... (but I can 
only use the ttyAM* ones on my ARM board... the others where created by 
a static /dev creation)


More information about the Lazarus mailing list