https://github.com/go-daq/canbus
CAN-bus interface
https://github.com/go-daq/canbus
can-bus canbus go golang
Last synced: 5 months ago
JSON representation
CAN-bus interface
- Host: GitHub
- URL: https://github.com/go-daq/canbus
- Owner: go-daq
- License: bsd-3-clause
- Created: 2016-11-23T12:44:42.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2022-09-07T07:26:27.000Z (almost 4 years ago)
- Last Synced: 2024-06-18T23:13:29.790Z (about 2 years ago)
- Topics: can-bus, canbus, go, golang
- Language: Go
- Homepage:
- Size: 20.5 KB
- Stars: 31
- Watchers: 5
- Forks: 13
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# canbus
[](https://github.com/go-daq/canbus/releases)
[](https://github.com/go-daq/canbus/actions)
[](https://codecov.io/gh/go-daq/canbus)
[](https://godoc.org/github.com/go-daq/canbus)
[](https://github.com/go-daq/canbus/blob/main/LICENSE)
`canbus` provides high-level facilities to interact with `CAN` sockets.
## can-dump
```
can-dump prints data flowing on CAN bus.
Usage of can-dump:
sh> can-dump [options]
(use CTRL-C to terminate can-dump)
Examples:
can-dump vcan0
```
```sh
$> can-dump vcan0
vcan0 080 00000000 00 DE AD BE EF |.....|
vcan0 080 00000000 01 DE AD BE EF |.....|
vcan0 080 00000000 02 DE AD BE EF |.....|
vcan0 080 00000000 03 DE AD BE EF |.....|
vcan0 080 00000000 04 DE AD BE EF |.....|
vcan0 080 00000000 05 DE AD BE EF |.....|
vcan0 080 00000000 06 DE AD BE EF |.....|
vcan0 080 00000000 07 DE AD BE EF |.....|
vcan0 080 00000000 08 DE AD BE EF |.....|
vcan0 080 00000000 09 DE AD BE EF |.....|
vcan0 712 00000000 11 22 33 44 55 66 77 88 |."3DUFW.|
vcan0 7fa 00000000 DE AD BE EF |....|
[...]
```
## can-send
```
can-send sends data on the CAN bus.
Usage of can-send:
sh> can-send [options]
where is of the form: #.
Examples:
can-send vcan0 f12#1122334455667788
can-send vcan0 ffa#deadbeef
```
```sh
$> can-dump vcan0 &
$> can-send vcan0 f12#1122334455667788
vcan0 712 00000000 11 22 33 44 55 66 77 88 |."3DUFW.|
$> can-send vcan0 ffa#deadbeef
vcan0 7fa 00000000 DE AD BE EF |....|
```
## References
```sh
$> modprobe can
$> modprobe can_raw
$> modprobe vcan
## setup vcan network devices
$> ip link add type vcan
$> ip link add dev vcan0 type vcan
$> ip link set vcan0 up
```
- https://www.kernel.org/doc/Documentation/networking/can.txt
- https://en.wikipedia.org/wiki/CAN_bus
- https://en.wikipedia.org/wiki/SocketCAN
- https://godoc.org/golang.org/x/sys/unix#SocketaddrCAN
- http://www.computer-solutions.co.uk/info/Embedded_tutorials/can_tutorial.htm
- http://elinux.org/Bringing_CAN_interface_up
- http://inst.cs.berkeley.edu/~ee249/fa08/Lectures/handout_canbus2.pdf
- https://chemnitzer.linux-tage.de/2012/vortraege/folien/1044_SocketCAN.pdf