opening a serial port at a given baudrate. How?

Jim Richardson warlock at eskimo.com
Tue Apr 4 22:08:39 EDT 2000


On 04-Apr-2000 David Arnold wrote:
> -->"Jim" == Jim Richardson <warlock at eskimo.com> writes:
> 
>   Jim> I can't seem to find any info on opening a serial port in
>   Jim> python!. (I am using linux for developement, but would like to
>   Jim> be able to use the app on any python system, it is text only,
>   Jim> no gui, at least for now. )
> 
> there is no portable way to open a serial port.  this is not least
> because there is no portable way to name your serial ports, but goes
> further than that.
> 
> on unix (including linux), just open the device special file
> corresponding to the serial port of interest (ie. /dev/ttyS0) and you
> can then control it using fcntl.ioctl() function and otherwise read
> from and write to it like a normal file object.
>

I have been using open('/dev/ttyS0','r+')
but need to control baud rate. fcntl.ioctl() will do this? 
 I can't seem to find (on machine, haven't checked on-line yet
how to do this, but thanks for the pointer! Knowing where to look is at
least half the battle.



> on win32 there is a serial I/O module (serialmodule?) that a quick
> deja search will locate for you.
> 
> i'd recommend the POSIX serial programming guide (any search engine
> should find it) as a good primer for Unix serial programming ...
> 

OK, will do, thanks again.

Jim Richardson
        Anarchist, pagan and proud of it
WWW.eskimo.com/~warlock
        Linux, because life's too short for a buggy OS.





More information about the Python-list mailing list