[Lazarus] Serial communication??

Paul Breneman list2010 at BrenemanLabs.com
Thu Sep 30 02:27:59 CEST 2010


Bo Berglund wrote:
...
>>> 3) How can one enumerate the existing com ports on Linux? 
>> In Windows I know
>>> how to do this and thus I can get a list of valid ports for 
>> the user to 
>>> select from. Is there some way also in Linux using FPC?
>>>
>> Quickest way I have found is to enumerate the device files in /dev 
>> extracting all 'ttyxx' (comports) and 'ttyU' (usb ports). 
>> This gives a 
>> list of 'probables'. Then try to connect (using SynaSer for 
>> example) to 
>> verify actual usable ports in the list
> 
> On my Ubuntu 10 virtual machine I get this result from ls /dev/t*:
> 
> /dev/tty    /dev/tty19  /dev/tty3   /dev/tty40  /dev/tty51  /dev/tty62
> /dev/tty0   /dev/tty2   /dev/tty30  /dev/tty41  /dev/tty52  /dev/tty63
> /dev/tty1   /dev/tty20  /dev/tty31  /dev/tty42  /dev/tty53  /dev/tty7
> /dev/tty10  /dev/tty21  /dev/tty32  /dev/tty43  /dev/tty54  /dev/tty8
> /dev/tty11  /dev/tty22  /dev/tty33  /dev/tty44  /dev/tty55  /dev/tty9
> /dev/tty12  /dev/tty23  /dev/tty34  /dev/tty45  /dev/tty56  /dev/ttyS0
> /dev/tty13  /dev/tty24  /dev/tty35  /dev/tty46  /dev/tty57  /dev/ttyS1
> /dev/tty14  /dev/tty25  /dev/tty36  /dev/tty47  /dev/tty58  /dev/ttyS2
> /dev/tty15  /dev/tty26  /dev/tty37  /dev/tty48  /dev/tty59  /dev/ttyS3
> /dev/tty16  /dev/tty27  /dev/tty38  /dev/tty49  /dev/tty6
> /dev/tty17  /dev/tty28  /dev/tty39  /dev/tty5   /dev/tty60
> /dev/tty18  /dev/tty29  /dev/tty4   /dev/tty50  /dev/tty61
> 
> I am absolutely certain there there is a maximum of 2 com ports avilable 
> to my virtual machine so where did all of the others come from?
> 
> Looks a bit hard to go around opening all these ports to check if
> they exist....

The "Simple Serial" zips use SynaSer and there is a SynaSer routine used 
by my programs to list the serial ports.

http://www.turbocontrol.com/simpleserial.htm




More information about the Lazarus mailing list