ethz-asl / ethzasl_xsens_driver

Driver for xsens IMUs
BSD 2-Clause "Simplified" License
102 stars 111 forks source link

Suggest handling exceptions when killing node #85

Closed ghost closed 6 years ago

ghost commented 6 years ago

Currently when we kill this node, we see

Traceback (most recent call last):
  File "/opt/ros/kinetic/lib/xsens_driver/mtnode.py", line 726, in <module>
    main()
  File "/opt/ros/kinetic/lib/xsens_driver/mtnode.py", line 722, in main
    driver.spin()
  File "/opt/ros/kinetic/lib/xsens_driver/mtnode.py", line 131, in spin
    [seabed/gps_to_utm-7] killing on exit
self.spin_once()
  File "/opt/ros/kinetic/lib/xsens_driver/mtnode.py", line 638, in spin_once
    data = self.mt.read_measurement()
  File "/opt/ros/kinetic/lib/xsens_driver/mtdevice.py", line 628, in read_measurement
    mid, data = self.read_msg()
  File "/opt/ros/kinetic/lib/xsens_driver/mtdevice.py", line 131, in read_msg
    if ord(self.waitfor()) != 0xFA:
  File "/opt/ros/kinetic/lib/xsens_driver/mtdevice.py", line 81, in waitfor
    buf.extend(self.device.read(size-len(buf)))
  File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 511, in read
    raise SerialException('read failed: %s' % (e,))
serial.serialutil.SerialException: read failed: (4, 'Interrupted system call')

It would be nice to handle these exceptions so that the code exits more gracefully.

fcolas commented 6 years ago

You're right. At some point serial changed its exception and I didn't update. Fixed in 6f770b3