Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32265
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Subject | Re: How to set 250000 baud rate in pyserial ? |
| Date | 2012-10-27 00:43 -0400 |
| Organization | > Bestiaria Support Staff < |
| References | <d5871091-63c8-4582-9485-138195cf6d36@googlegroups.com> <mailman.2858.1351188682.27098.python-list@python.org> <10b2bbd7-c2b5-409e-be83-bd11948e16a8@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2930.1351312998.27098.python-list@python.org> (permalink) |
On Fri, 26 Oct 2012 15:01:43 -0700 (PDT), kurabas@gmail.com declaimed
the following in gmane.comp.python.general:
> Error is like cannot set special baud rate.
> But as I said pyserial set this speed without problem for ttyUSB0
> So it seems pyserial uses diefferent code depending of port type.
Did you look at the source file?
It doesn't know about "port type" -- it only differs by the OS in
use. Given the OS, the same system calls are invoked regardless of what
the device port "name" is.
-=-=-=-=- serialposix.py (extract)
if plat[:5] == 'linux': # Linux (confirmed)
def device(port):
return '/dev/ttyS%d' % port
ASYNC_SPD_MASK = 0x1030
ASYNC_SPD_CUST = 0x0030
def set_special_baudrate(port, baudrate):
import array
buf = array.array('i', [0] * 32)
# get serial_struct
FCNTL.ioctl(port.fd, TERMIOS.TIOCGSERIAL, buf)
# set custom divisor
buf[6] = buf[7] / baudrate
# update flags
buf[4] &= ~ASYNC_SPD_MASK
buf[4] |= ASYNC_SPD_CUST
# set serial_struct
try:
res = FCNTL.ioctl(port.fd, TERMIOS.TIOCSSERIAL, buf)
except IOError:
raise ValueError('Failed to set custom baud rate: %r' %
baudrate)
-=-=-=-=-=-
Practically all the other OS options (Mac, Sun, HP, Cygwin, etc.)
produce
def set_special_baudrate(port, baudrate):
raise ValueError("sorry don't know how to handle non standard
baud rate on this platform")
Windows has its own module...
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to set 250000 baud rate in pyserial ? kurabas@gmail.com - 2012-10-25 04:09 -0700
Re: How to set 250000 baud rate in pyserial ? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-10-25 14:11 -0400
Re: How to set 250000 baud rate in pyserial ? Grant Edwards <invalid@invalid.invalid> - 2012-10-25 21:14 +0000
Re: How to set 250000 baud rate in pyserial ? kurabas@gmail.com - 2012-10-26 15:01 -0700
Re: How to set 250000 baud rate in pyserial ? Michael Torrie <torriem@gmail.com> - 2012-10-26 16:08 -0600
Re: How to set 250000 baud rate in pyserial ? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-10-27 00:43 -0400
Re: How to set 250000 baud rate in pyserial ? kurabas@gmail.com - 2012-10-26 15:01 -0700
csiph-web