Subject of the issue
I am trying to retrieve OBD variables through python script running on a Autopi Dongle. I imported and installed the py-obd library, but unfortunately a broken pipe message is showing.
I’ve found on the community that someone else had the same problem but they couldn’t found a solution so i’m trying to propose again the question.
Steps to reproduce
I’m trying to use the following code in order to obtain data from the OBD port:
#!/usr/bin/python
import obd
connection = obd.OBD() # auto-connects to USB or RF port
cmd = obd.commands.SPEED # select an OBD command (sensor)
response = connection.query(cmd) # send the command, and parse the response
print(response.value) # returns unit-bearing values thanks to Pint
print(response.value.to(“mph”)) # user-friendly unit conversions
Expected behaviour
Print on the terminal the SPEED value in mph
Actual behaviour
Traceback (most recent call last):
File “test.py”, line 5, in
connection = obd.OBD() # auto-connects to USB or RF port
File “/usr/local/lib/python2.7/dist-packages/obd/obd.py”, line 62, in init
self.__connect(interface_cls, portstr, baudrate, timeout=timeout, protocol=protocol, status_callback=status_callback)
File “/usr/local/lib/python2.7/dist-packages/obd/obd.py”, line 82, in __connect
portnames = scan_serial()
File “/usr/local/lib/python2.7/dist-packages/obd/utils.py”, line 191, in scan_serial
if try_port(port):
File “/usr/local/lib/python2.7/dist-packages/obd/utils.py”, line 155, in try_port
s = serial.Serial(portStr)
File “/usr/local/lib/python2.7/dist-packages/serial/serialutil.py”, line 240, in init
self.open()
File “/usr/local/lib/python2.7/dist-packages/serial/serialposix.py”, line 286, in open
self._update_dtr_state()
File “/usr/local/lib/python2.7/dist-packages/serial/serialposix.py”, line 634, in _update_dtr_state
fcntl.ioctl(self.fd, TIOCMBIS, TIOCM_DTR_str)
IOError: [Errno 32] Broken pipe