Serial.py woes

John Hunter jdhunter at ace.bsd.uchicago.edu
Tue Nov 26 20:35:40 EST 2002


I am using Roger Burnhams SioModule22 to interface with a RS232
medical device.  I can do a basic handshake with the device and
nothing more.  All other commands that I attempt are ignored (no data
sent back).  The basic handshake is: I send a CR, it sends back a
'*'.  

I have read the damned manual 20 times and running out of guesses.  I
thought if I posted some of the parameters of the device and port, and
some of my code, a more experienced veteran of serial device
programming under win32 would have some suggestions for me.

The device is configured in the windows control panel as COM1 with
19200 baud, 8 data bits, 1 stop bit, no parity.  I checked the baud
setting on the machine board and it is at 19200.  The manual says
regarding baud:

  All speeds have

  1 start bit
  8 data bits
  1 stop bit

I am not sure if I should be using the 1 start bit info in the
configuration of my port or code below. Please enlighten me here.  I'm
hoping that this indicates I have set something improperly, cause I
really want to fix this and move on.

I am using this module because it was recommended in Python
Programming for Win32, but would be happy to try another on someone's
recommendation.  

Here is my sample program

import sys, traceback
from Serial import Serial

config = Serial.PortDict()
config['port'] = Serial.COM1
config['baud'] = Serial.Baud19200
config['stopBits'] = Serial.OneStopBit
config['parity'] = Serial.NoParity
config['dataBits'] = Serial.WordLength8

port = Serial.Port(config)
port.open()
try:
    port.write('\r')    # attention
    print 'Open: ', port.read(1, timed=4000)
    port.write('R at 1,0,1000,1\r')  # ask for a 1000 bytes from array 1
    print 'Data: ', port.read(1000, timed=4000)
    port.write('X\r')  # release the interface
    port.close()
except:
    port.write('X\r')
    port.close()
    traceback.print_exc()


And the exception
#d:\jdh\neurostar\python>d:\python22\python allinone.py
#d:\python22\python allinone.py
#Open:  *
#Data: 
#Traceback (most recent call last):
#  File "allinone.py", line 17, in ?
#    print 'Data: ', port.read(1000, timed=4000)
#  File "D:\PYTHON22\Serial\Serial.py", line 469, in read
#    raise SioError, \
#SioError: Timed out waiting for input chr 0 of 1000, read ''.


Any and all advice much appreciated.

For the old-timers, the device is a Neurostar Ms92B.

John Hunter

python2.2




More information about the Python-list mailing list