[Lazarus] Serial communication??

steveg steveg at nevets.com.au
Tue Sep 28 21:50:48 CEST 2010


Bo Berglund wrote:
> I asked about serial communications in my thread about embedded development 
> and I was told to look at the serial unit, which I have done now.
> 
> I also looked at the Lazarus wiki about hardware interfaces where there is
> a section about serial communications, which actually points to the
> SynaSer system.
> (http://wiki.lazarus.freepascal.org/Hardware_Access#Serial_Communication)
> There were also replies with brief discussions about AsyncPro clone
> development etc.
> 
> Now after having a deeper look at the two suggseted comm systems serial
> and syanaser I am not very comfortable....
> 
> It looks like the  serial.pp unit implements a blocking system even though
> it is not clearly written as such. But the synaser unit is definitely
> blocking.
> 
> Since I am used to having event driven serial communication my question
> is really twofold:
> 
> 1) Is serial communication with events not possible in FPC on Linux?
> 
> 2) How can one use blocking reads when there is no way to know exactly when
> data will arrive? Everything else will stop when waiting for data, right?

Synapse works very well for Tcp and serial comms. Use threads to wait 
for the data. It also supplies an event on data rx'd which you can use 
to call yourself when necessary

> 
> Additionally I have another nonrelated question:
> 
> 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







More information about the Lazarus mailing list