Usb can адаптер linux

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

gsmcmullin/usbcan

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README

README for USBCAN ~~~~~~~~~~~~~~~~~ This project aims to create an open-source USB-CAN adapter which works with the Linux SocketCAN infrastructure. Currently only the first hardware prototype has been designed, based on the STM32F105RC device for a direct implementation in contrast to the number of FT232 based designs out there. Firmware development will proceed when the prototypes have been build, but the first step will be USB support for this device in libopenstm32. Licensing ~~~~~~~~~ The hardware design is licensed under the Creative Commons Attributionr-ShareAlike 3.0 Unported license. The firmware will be licensed under the GNU General Public License, version 3. The Linux driver will be licensed under the GNU General Public License, version 2.

Источник

Overview

The CANable 2.0 is a small low-cost open source USB to CAN adapter. The CANable enumerates as a virtual serial port on your computer and acts as a serial-line to CAN bus interface. With the alternative candleLight firmware, the CANable enumerates as a native CAN interface on Linux. CANable 2.0 supports both standard CAN and CAN-FD.

CANable adapters are compatible with ARM-based embedded platforms such as the Raspberry Pi, Raspberry Pi Zero, ODROID, BeagleBone, etc. and are well suited for integration into OEM products.

CANable 2.0 USB to CAN Adapter

CANable 2.0 Features

  • Supports CAN2.0A and B, baud rates up to 1M
  • Initial slcan support for CAN-FD (beta, 2M/5Mbaud)
  • Compatible with socketcan through slcand
  • USB-C Connector and breakaway mounting holes
  • 4-pin screw terminal: CANH, CANL, 5v (output), GND
  • Button for entering bootloader
  • Switch to enable/disable onboard termination
  • Simple cross-platform Python library
  • Manufactured in the USA
  • Available for purchase at Openlight Labs
Читайте также:  Переключение между мониторами линукс

For more information on getting up and running with a CANable device, refer to the getting started page.

Questions or comments? Email us at support@canable.io.

Software Support

The CANable is supported by several software applications:

  • Cangaroo (Windows, Linux): Send/receive tandard and FD frames, decode messages from DBC files
  • SocketCAN (Linux) Native Linux support using slcand
  • python-can (Windows, Linux, Mac) Easily interface with the CAN bus using your CANable and Python scripts

Archived Products

CANable USB to CAN Adapter

CANable (Original)

  • Supports CAN2.0A and B, baud rates up to 1M
  • Compatible with socketcan through slcand
  • Native socketcan support with candleLight firmware
  • 4-pin screw terminal: CANH, CANL, 5v (output), GND
  • Jumper to enter bootloader for firmware updates
  • Jumper to enable/disable termination
  • PTC-fused 5v output
  • Simple cross-platform Python library
  • Manufactured in the USA
  • Purchase now on the Openlight Labs store

CANable USB to CAN Adapter

CANable Pro

  • All features of the standard CANable
  • 2.5kV galvanic isolation between USB and CAN bus
  • Additional ESD protection/clamping on CAN bus
  • Additional ESD protection/clamping on USB
  • Breakaway mounting holes
  • Button to enter bootloader for firmware updates
  • Purchase now on the Openlight Labs store

Stock slcan firmware

CANables ship with slcan firmware. This firmware enumerates as a standard serial device on Linux, Mac, and Windows for easy interfacing. The CANable can be easily re-flashed with the candlelight firmware which enumerates as a native CAN device in Linux and a generic USB device in Windows.

On Linux the CANable works natively with slcand, so you can use all of the standard can-utils command-line utilities and even Wireshark to interact with the bus.

On Windows and Linux, the CANable works with Cangaroo which allows transmission/reception of standard and FD frames as well as decoding of messages from loaded DBC files.

candlelight Firmware

If you update to the candlelight firmware, the CANable shows up as a native CAN device with socketcan—no slcand required! Performance is higher than the serial-line firmware as slcand is bypassed entirely. With Linux and socketcan you can use all of the standard can-utils command-line utilities and even Wireshark to interact with the bus. Note: candlelight firmware for CANable 2.0 currently does not support FD frames

Python Support

For even more flexibility, the python-can library allows you to directly talk to the CAN bus from Python. The library is cross-platform and can connect directly to a CANable’s virtual serial port interface or native socketcan interface. With only a couple lines of code you can decode traffic on the bus, send messages, and more.

Check out the getting started page for more information.

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Читайте также:  Linux where is log file

Device to connect to a CAN bus from a Linux / Windows / macOS device

License

bmc-labs/usb-can

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

usb-can , a simple and cost effective CAN link

bmc::labs usb-can

Rendering of usb-can , our version of the USBtin by Thomas Fischl

Be it for automation, development or debugging, one often needs a way to inspect a CAN bus. This device allows to connect to a CAN bus via a standard USB type C cable. It is based on the USBtin by Thomas Fischl — there are many great resources behind this link, and we encourage you to buy Thomas’ version from him!

All examplatory output comes from a 2013 MacBook Pro running Debian.

Start by adding yourself to the dialout group if you aren’t already in it:

» sudo usermod -aG dialout $USER

You’ll need can-utils for Linux. If you’re on something Debian-based, you’re best off installing them like so:

» sudo apt install can-utils

If you’re on a different distro, you may find the can-utils in your respective package management; if not go get them from GitHub. Good, now you’re all set.

CAN support via socketcan is upstream in Linux, but it is not necessarily loaded by default. Execute load like so:

» sudo modprobe can » sudo modprobe can-raw » sudo modprobe slcan

You can use the lsmod utility to verify everything has worked:

» lsmod | grep can slcan 16384 0 can_raw 20480 0 can 24576 1 can_raw

You output may look slightly different, but you should see the modules loaded.

Check which serial device is the CAN device

There are a number of ways to do this. First off, you may want to check that the usb-can is actually recognized via lsusb (which you may have to install):

» lsusb . Bus 002 Device 015: ID 04d8:000a Microchip Technology, Inc. CDC RS-232 Emulation Demo .

If the device shows up here, you can look which serial port it is bound to:

» sudo tail /var/log/kern.log Apr 18 14:53:17 rzrgrl kernel: [64635.125815] usb 2-2: new full-speed USB device number 15 using xhci_hcd Apr 18 14:53:17 rzrgrl kernel: [64635.276572] usb 2-2: New USB device found, idVendor=04d8, idProduct=000a, bcdDevice= 1.00 Apr 18 14:53:17 rzrgrl kernel: [64635.276580] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0 Apr 18 14:53:17 rzrgrl kernel: [64635.276583] usb 2-2: Product: USBtin Apr 18 14:53:17 rzrgrl kernel: [64635.276585] usb 2-2: Manufacturer: Microchip Technology, Inc. Apr 18 14:53:17 rzrgrl kernel: [64635.277670] cdc_acm 2-2:1.0: ttyACM0: USB ACM device

In this case, it is ttyACM0 , which should be similar for you.

Читайте также:  Linux sh скрипт ssh

Attach the device to a socket-capable interface

The following commands come from can-utils , so if you haven’t installed those so far, do that now.

Next, you should select the bus speed of the CAN you’re trying to connect to. The available speeds are:

Baudrate (kBaud) Number encoding Command paramete
1.000 8 -s8
800 7 -s7
500 6 -s6
250 5 -s5
125 4 -s4
100 3 -s3
50 2 -s2
20 1 -s1
10 0 -s0

Setting up a 500 kBaud CAN interface at serial port ttyACM0 is done like so:

» sudo slcan_attach -f -s6 -o /dev/ttyACM0 attached tty /dev/ttyACM0 to netdevice slcan0 » sudo slcand ttyACM0 slcan0 » sudo ip link set slcan0 up

Congratulations, you’ve done it!

Now you can send and receive CAN messages on the socket interface slcan0 . For example, to dump all incoming messages to the terminal:

The candump utility also allows you to filter for CAN IDs, set up the byte order, and a number of other useful things it will tell you about if you as it nicely ( candump -h ).

Sending a frame to CAN is similarly easy:

» cansend slcan0 7ff#deadbeef

The cansend utility is also very vocal about its capabilities if asked.

Further useful components of can-utils :

    the canplayer utility, which lets you play CAN messages from a log file that looks like this:

(0.100) slcan0 5D1#0000 (0.200) slcan0 271#0100 (0.300) slcan0 289#72027000 (0.400) slcan0 401#081100000000 

Both utilities will also happily tell you about themselves with -h .

Last but not least, here is a snippet for sending the current time in the format to the CAN on ID 0x7ff , i.e. the last and therefore least priority ID, every 5 seconds:

while true do cansend slcan0 7ff#$(printf '%02x%02x' $(date +"%I") $(date +"%M")) sleep 5 done

Please find hints for Windows on Thomas Fischl’s website.

For macOS, there is code floating around the web for socketcan and for can-utils , and once you have those working the above guide for Linux should mostly apply. No idea if it works, though — we don’t do macOS right now.

The contents of this repository which are our original work are released into the public domain unter The Unlicense (see LICENSE). We build heavily on the work of others here and recommend you pay them tribute first if you like the material you’ve found here.

  • 1x usb-can_housing-lower (3d print)
  • 1x usb-can_housing-lower-clean or -icon version (3d print)
  • 4x Socket screw M3x8mm
  • 4x Thread insert M3x4.78mm
  • 1x usb-can PCB board

About

Device to connect to a CAN bus from a Linux / Windows / macOS device

Источник

Оцените статью
Adblock
detector