Crystal CAN adds the ability to read from a Linux SocketCAN interface.
-
Add the dependency to your
shard.yml
:dependencies: crystal_can: github: zaben903/crystal_can
-
Run
shards install
require "crystal_can"
client = CrystalCan::Client.new
response = client.receive
Returned from the receive action is a LibC::CanFrame struct using the struct from /linux/can.h
setting up vcan0
interface:
sudo ip link add dev vcan0 type vcan
sudo ifconfig vcan0 up
Testing reading CAN packets can be done using:
apt install can-utils
cansend vcan0 "01a#11223344"
- Fork it (https://github.com/zaben903/crystal_can/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- Zach Bensley - creator and maintainer