Chinese CAN-USB interface (mfg. Robotell etc.)¶
An USB to CAN adapter sold on Aliexpress, etc. with the manufacturer name Robotell printed on the case.
There is also a USB stick version with a clear case. If the description or screenshots refer to
the device should be compatible with this driver.
These USB devices are based on a STM32 controller with a CH340 serial interface and use a binary protocol - NOT compatible with SLCAN
See https://www.amobbs.com/thread-4651667-1-1.html for some background on these devices.
This driver directly uses either the local or remote (not tested) serial port. Remote serial ports will be specified via special URL. Both raw TCP sockets as also RFC2217 ports are supported.
port or URL[@baurate] to open the device.
For example use
COM4@9600 for local serial ports and
rfc2217://192.168.254.254:5000 for remote ports.
robotellBus(channel, ttyBaudrate=115200, bitrate=None, rtscts=False, **kwargs)¶
- channel (str) – port of underlying serial or usb device (e.g. /dev/ttyUSB0, COM8, …) Must not be empty.
- ttyBaudrate (int) – baudrate of underlying serial or usb device
- bitrate (int) – CAN Bitrate in bit/s. Value is stored in the adapter and will be used as default if no bitrate is specified
- rtscts (bool) – turn hardware handshake (RTS/CTS) on and off
Get serial number of the slcan interface. :type timeout: int or None :param timeout:seconds to wait for serial number or None to wait indefinitely
:rtype str or None :return:None on timeout or a str object.
Transmit a message to the CAN bus.
Override this method to enable the transmit path.
- msg (Message) – A message object.
- timeout – If > 0, wait up to this many seconds for message to be ACK’ed or for transmit queue to be ready depending on driver implementation. If timeout is exceeded, an exception will be raised. Might not be supported by all interfaces. None blocks indefinitely.
can.CanError – if the message could not be sent
Parameters: auto_man (bool) – Enable/disable automatic bus management
Parameters: retrans_flag (bool) – Enable/disable automatic retransmission of unacknowledged CAN frames
Raises: ValueError – if bitrate is greater than 1000000 Parameters: bitrate (int) – Bitrate in bit/s
set_hw_filter(filterid, enabled, msgid_value, msgid_mask, extended_msg)¶
ValueError – if filterid is not between 1 and 14
- filterid (int) – ID of filter (1-14)
- enabled (bool) – This filter is enabled
- msgid_value (int) – CAN message ID to filter on. The test unit does not accept an extented message ID unless bit 31 of the ID was set.
- msgid_mask (int) – Mask to apply to CAN messagge ID
- extended_msg (bool) – Filter operates on extended format messages
Parameters: serial_bps (int) – Set the baud rate of the serial port (not CAN) interface
Called to carry out any interface specific cleanup required in shutting down a bus.
Document the internals of robotell interface.