lock access to serial port

Grant Edwards grante at visi.com
Wed Mar 19 09:43:32 EDT 2008


On 2008-03-18, kkadrese at gmail.com <kkadrese at gmail.com> wrote:

> how to get ttyS0 serial port for exclusive access? I have a python
> script that uses this device with AT commands. I need that two
> instances can call simultaneosuly this python script but only one of
> them gets the device. I tried fcntl.flock, it was just ignored, put
> writtable file LCK..ttyS0 in /var/lock,

Using a lock file is the traditional method of providing
mutually exclusive access to a serial port.

> tried ioctl (but I may not know what are appropriate
> arguments), googled half a day for various phrases, error
> messages etc....without success.

It's unclear what "without success" means.  Lockfiles have been
used for decades, and they work fine as long as all of the
applications follow the rules.

-- 
Grant




More information about the Python-list mailing list