Skip to content

Error in first example scanning network #103

@ivomans

Description

@ivomans

I'm trying to get familiar with your library, but unfortunately I got stuck while trying the first example in an error I don't understand.

My code:

import time
import canopen

network = canopen.Network()
network.connect(bustype='serial', channel='/dev/ttyUSB0', bitrate=250000)
network.scanner.search()
time.sleep(2)
for node_id in network.scanner.nodes:
    print("Found node %d!" % node_id)

Resulting in error:

$ sudo python try-canopen.py
Exception in thread can.notifier for bus "Serial interface: /dev/ttyUSB0":
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "build/bdist.linux-armv7l/egg/can/notifier.py", line 69, in _rx_thread
    msg = bus.recv(self.timeout)
  File "build/bdist.linux-armv7l/egg/can/bus.py", line 77, in recv
    msg, already_filtered = self._recv_internal(timeout=time_left)
  File "build/bdist.linux-armv7l/egg/can/interfaces/serial/serial_can.py", line 138, in _recv_internal
    arb_id = (struct.unpack('<I', s))[0]
error: unpack requires a string argument of length 4

I've got 1 device in the network which is transmitting packages every second, that I can watch from my PC.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions