CANalyst II: Difference between revisions

No edit summary
No edit summary
 
(17 intermediate revisions by the same user not shown)
Line 1: Line 1:
The Canalyst II is an affordable, well-built piece of very Chinese equipment, exposing two [[CAN]] bus transceivers to a USB CAN adapter capable of 7k fps, and megabit CAN networks. There is very little English documentation. It appears as USB VendorID 04d8, ProductID 0053 (04d8:0053), the space of [https://www.microchip.com/ Microchip Technology, Inc.].
[[File:CANalystII-above.png|thumb|right|alt=Picture of the CANalyst II from above.|The CANalyst II, an enigma (for now).]]
The Canalyst II is an affordable, well-built piece of very Chinese equipment, exposing two [[CAN bus]] transceivers to a USB CAN adapter capable of 7k fps, and megabit CAN networks. There is very little English documentation. It appears as USB VendorID 04d8, ProductID 0053 (04d8:0053), the space of [https://www.microchip.com/ Microchip Technology, Inc.]. Both channels come equipped with independently-selectable 120Ω resistors necessary for ISO 11898-2 High-Speed CAN buses (such a resistor should not be used with ISO 11898-3 Reliable CAN buses). It also offers baud rate detection functionality.
 
Note that the manual refers to ohms as euros, which is pretty indicative of the documentation's quality overall.
 
I suspect there to be a 16MHz [https://www.nxp.com/products/analog/interfaces/in-vehicle-network/can-transceiver-and-controllers/stand-alone-can-controller:SJA1000T SJA1000] chip inside, but have not verified this.
 
==Hardware==
[[File:CANalystII-test-setup.png|thumb|left|alt=Wiring diagram for self-test|Wired thusly, the CANalyst II can self-test both channels.]]
The CANalyst II is powered entirely over its USB connection--there is no dedicated input for power.
Upon being powered on, the red PWR LED lights up. The blue SYS LED lights once whenever the OS makes a connection to the device. A self-test capability is included on the device, which will see the blue LED light twice in succession on a successful test. The wiring diagram for the self-test mode can be seen to the left. The CANalyst II presents a senary [https://en.wikipedia.org/wiki/Screw_terminal screw terminal] suitable for mating with a [https://en.wikipedia.org/wiki/D-subminiature DE-9] or [https://en.wikipedia.org/wiki/Data_link_connector_(automotive) ODB-II DLC].
 
{| class="wikitable sortable"
|-
!Port !! Pin !! Name !! Function
|-
| rowspan="6" | [[File:6screwterm.jpg|thumb]] || 1 || CAN_H || CAN_H signal wire, channel 0
|-
| 2 || SHIELD || Terminal resistance connector, channel 0
|-
| 3 || CAN_L || CAN_L signal wire, channel 0
|-
| 4 || CAN_H || CAN_H signal wire, channel 1
|-
| 5 || SHIELD || Terminal resistance connector, channel 1
|-
| 6 || CAN_L || CAN_L signal wire, channel 1
|-
|}
 
The Chinese manufacturer's site claims that the device is "similar to a [https://www.zlg.com/can/can/product/id/22.html ZLG USBCAN-II+]". What exactly is meant by "similar" here is not yet known. The USBCAN-II+ claims 14Kfps using both channels, which does match the claimed performance of the CANalyst II.


==Linux==
==Linux==
[[File:Canalystii-iface.png|thumb|right|alt=Hardware interfaces of the CANalyst II|Business ends of the CANalyst II.]]
The Linux kernel's preferred way to drive CAN adapters is via SocketCAN, which presents the device as a network interface. There does not appear to be a SocketCAN driver for the Canalyst II as of 2019-06-10. The <tt>mcba_usb</tt> driver, recompiled to use the Canalyst II's USB ID, definitely does *not* work. I'm planning to write a kernel driver; the GitHub project is [https://github.com/dankamongmen/CANalystII-SocketCAN CanalystII-SocketCAN]. The [https://python-can.readthedocs.io/ python-can] project contains a userspace driver, for which I've [https://github.com/hardbyte/python-can/pull/617 recently submitted patches] (it wasn't working when my Canalyst II arrived). This allows a Python program to use the device, which is nice, I guess.
The Linux kernel's preferred way to drive CAN adapters is via SocketCAN, which presents the device as a network interface. There does not appear to be a SocketCAN driver for the Canalyst II as of 2019-06-10. The <tt>mcba_usb</tt> driver, recompiled to use the Canalyst II's USB ID, definitely does *not* work. I'm planning to write a kernel driver; the GitHub project is [https://github.com/dankamongmen/CANalystII-SocketCAN CanalystII-SocketCAN]. The [https://python-can.readthedocs.io/ python-can] project contains a userspace driver, for which I've [https://github.com/hardbyte/python-can/pull/617 recently submitted patches] (it wasn't working when my Canalyst II arrived). This allows a Python program to use the device, which is nice, I guess.


If the <tt>usbserial</tt> kernel module is told to use the Canalyst II's USB IDs via <tt>sudo modprobe usbserial vendor=0x04d8 product=0x0053</tt>, it does appear to successfully bring up an SLCAN device, which can then be exposed as a network device using <tt>slcand</tt> or <tt>slcan_attach</tt>. The <tt>usbserial</tt> module will create 6(!) <tt>ttyUSB</tt> nodes for the CANalyst II. Only the first device seems to have any effect when used with SLCAN.
If the <tt>usbserial</tt> kernel module is told to use the Canalyst II's USB IDs via <tt>sudo modprobe usbserial vendor=0x04d8 product=0x0053</tt>, it does appear to successfully bring up an SLCAN device, which can then be exposed as a network device using <tt>slcand</tt> or <tt>slcan_attach</tt>. The <tt>usbserial</tt> module will create 6(!) <tt>ttyUSB</tt> nodes for the CANalyst II. Only the first device seems to have any effect when used with SLCAN. To create a 125Kbps adapter, use something like:
 
<nowiki>[schwarzgerat](0) $ sudo slcand -o -s4 -F ttyUSB0
[6] starting on TTY device /dev/ttyUSB0
[5] attached TTY /dev/ttyUSB0 to netdevice slcan0</nowiki>
 
The generated net device cannot have its bitrate set using <tt>ip</tt>, like native SocketCAN devices. Instead, the <tt>-s</tt> argument must be provided to <tt>slcand</tt>, using the following table:
 
{| class="wikitable sortable"
|-
!ASCII Command !! CAN Bitrate
|-
|s0 || 10 Kbit/s
|-
|s1 || 20 Kbit/s
|-
|s2 || 50 Kbit/s
|-
|s3 || 100 Kbit/s
|-
|s4 || 125 Kbit/s
|-
|s5 || 250 Kbit/s
|-
|s6 || 500 Kbit/s
|-
|s7 || 800 Kbit/s
|-
|s8 || 1000 Kbit/s
|}


==lsusb output==
==lsusb output==