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 EmbededDebug or EmbededConfig 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.

Usage: use port or URL[@baurate] to open the device. For example use /dev/ttyUSB0@115200 or COM4@9600 for local serial ports and socket://192.168.254.254:5000 or rfc2217://192.168.254.254:5000 for remote ports.

Supported devices

Todo

Document this.

Bus

class can.interfaces.robotell.robotellBus(channel, ttyBaudrate=115200, bitrate=None, rtscts=False, **kwargs)[source]

Bases: can.bus.BusABC

robotell interface

Parameters:
  • 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(timeout)[source]

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.
send(msg, timeout=None)[source]

Transmit a message to the CAN bus.

Override this method to enable the transmit path.

Parameters:
  • 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.
Raises:

can.CanError – if the message could not be sent

set_auto_bus_management(auto_man)[source]
Parameters:auto_man (bool) – Enable/disable automatic bus management
set_auto_retransmit(retrans_flag)[source]
Parameters:retrans_flag (bool) – Enable/disable automatic retransmission of unacknowledged CAN frames
set_bitrate(bitrate)[source]
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)[source]
Raises:

ValueError – if filterid is not between 1 and 14

Parameters:
  • 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
set_serial_rate(serial_bps)[source]
Parameters:serial_bps (int) – Set the baud rate of the serial port (not CAN) interface
shutdown()[source]

Called to carry out any interface specific cleanup required in shutting down a bus.

Internals

Todo

Document the internals of robotell interface.