Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '[0]': 0.07; 'try:': 0.07; 'subject:How': 0.09; '32)': 0.09; 'ioerror:': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'res': 0.09; 'subject:set': 0.09; 'def': 0.10; "%r'": 0.16; '15:01:43': 0.16; 'cygwin,': 0.16; 'differs': 0.16; 'oct': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'windows': 0.19; 'import': 0.21; 'regardless': 0.21; 'flags': 0.22; 'os,': 0.22; 'seems': 0.23; 'raise': 0.24; 'device': 0.24; 'non': 0.24; 'linux': 0.24; 'options': 0.27; "doesn't": 0.28; 'header:X-Complaints-To:1': 0.28; 'array': 0.29; 'source': 0.29; "skip:' 10": 0.30; 'fri,': 0.30; 'subject: ?': 0.30; 'error': 0.30; 'code': 0.31; 'etc.)': 0.32; 'skip:~ 10': 0.33; 'url:home': 0.33; 'handle': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'received:org': 0.36; 'except': 0.36; 'but': 0.36; 'charset :us-ascii': 0.36; 'uses': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'is.': 0.62; 'email addr:gmail.com': 0.63; 'special': 0.73; '(confirmed)': 0.84; 'dennis': 0.91; 'received:108': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: How to set 250000 baud rate in pyserial ? Date: Sat, 27 Oct 2012 00:43:04 -0400 Organization: > Bestiaria Support Staff < References: <10b2bbd7-c2b5-409e-be83-bd11948e16a8@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-108-73-117-245.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 57 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351312998 news.xs4all.nl 6879 [2001:888:2000:d::a6]:59711 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32265 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/