python - Debugging pySerial write timeout -


how determine caused pyserial write time out? having problem pyserial begins throwing write timeout exceptions after running variable amount of time. can run fine few minutes (at approx. 200 bytes/sec) , fail.

all handshaking disabled.

prior write timeout, have observed no more data presented on tx data pin. few seconds later timeouts begin. if disable writetimeout, code runs continually no new data sent out on tx pin.

i see in pyserial code passes written data os.write() call. cause reliably timeout? cause not timeout, not present data on output pin?


specific information application below:


i sending data out on ftdi adapter arduino board (which emulates dynamixel servos). monitoring rx/tx lines logic analyzer, can see making through ftdi adapter.

i running on ubuntu 14.04 in vm.

the code dynamixel controller node ros. have been making small changes in order debug problem.

write method, print statements added debugging:

def __write_serial(self, data):     print "tx"      if self.ser none:         print "not open"      self.ser.flushinput()     self.ser.flushoutput()     try:         n = self.ser.write(data)         print n     except exception e:         print e 

read method:

def __read_response(self, servo_id):     data = []     print "rx"      try:         data.extend(self.ser.read(4))         print data         if not data[0:2] == ['\xff', '\xff']:              print "rx err1"             raise exception('wrong packet prefix %s' % data[0:2])         data.extend(self.ser.read(ord(data[3])))         data = array('b', ''.join(data)).tolist() # [int(b2a_hex(byte), 16) byte in data]     except exception, e:         print "rx err2"         raise droppedpacketerror('invalid response received motor %d. %s' % (servo_id, e))      # verify checksum     checksum = 255 - sum(data[2:-1]) % 256     if not checksum == data[-1]: raise checksumerror(servo_id, data, checksum)      return data 

and serial port declaration. handshaking off.

def __init__(self, port, baudrate, readback_echo=false):     """ constructor takes serial port , baudrate arguments. """     try:         self.serial_mutex = lock()         self.ser = none         self.ser = serial.serial(port)         #self.ser.settimeout(0.015)         self.ser.settimeout(0.05)         self.ser.baudrate = baudrate         self.ser.xonxoff = false         self.ser.rtscts = false         self.ser.dsrdtr = false         self.ser.writetimeout = 1         self.port_name = port         self.readback_echo = readback_echo     except serialopenerror:        raise serialopenerror(port, baudrate) 

the program begins running expected. @ point (happens sooner @ higher packet rate), no more data appears on tx output of ftdi adapter. here output last packet , first bad packet:

tx 8 rx ['\xff', '\xff', '\x15', '\x13'] tx 8 rx [] rx err1 rx err2 

the self.ser.write(data) call returns 8 (for 8-byte packet) both times, data appears on output of ftdi adapter first call.

after 3 sec of trying send data (at approx. 200 byte/sec), write timeout exceptions thrown.

tx write timeout rx [] rx err1 rx err2 

in summary:

  • code runs fine many seconds/minutes
  • data ceases output on tx pin of ftdi, no exceptions raised
  • after few seconds, code begins raising write timeout exceptions

how can debug problem?


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -