The dockerfile creates a CANopen master with gateway functionality. Using the commands interface one can control a CANopen network. The gateway is exposed at port 6000.
This project is based upon CANopenSocket and CANopenNode.
This project should build with the default Docker build engine, but also buildx is supported for creating cross-platform container images. Considering you're targetting embedded devices I'd guess you're cross building, so let's demonstrate docker buildx here.
$ docker buildx create --name crossbuilder
$ docker buildx use crossbuilder
$ docker login
$ docker buildx build --platform linux/arm,linux/arm64,linux/amd64 -t geoffreyvl/canopensocket . --push
$ docker buildx imagetools inspect geoffreyvl/canopensocket
Name: docker.io/geoffreyvl/canopensocket:latest
MediaType: application/vnd.docker.distribution.manifest.list.v2+json
Digest: sha256:bd24fa61e43427f1113027e299b63c455510bb5d0fe9e2600d7db3fdde7ea58a
Manifests:
Name: docker.io/geoffreyvl/canopensocket:latest@sha256:8d953afb62cd220e44c45abb0247c6ce6726b43bfe2b825475672e14e1996684
MediaType: application/vnd.docker.distribution.manifest.v2+json
Platform: linux/arm/v7
Name: docker.io/geoffreyvl/canopensocket:latest@sha256:388e652c8e7796f6746fa45afedbb0c1fd8d2ad29d28d4c3c6228084b549b98c
MediaType: application/vnd.docker.distribution.manifest.v2+json
Platform: linux/arm64
Name: docker.io/geoffreyvl/canopensocket:latest@sha256:6bfeb074195e93e4f4774bc08f9539c6f4f34042e124805485af0930d51e4ceb
MediaType: application/vnd.docker.distribution.manifest.v2+json
Platform: linux/amd64
On your native host machine make sure that your CAN interface is up and running. We will use that interface within the Docker container.
$ ip link set can0 type can bitrate 250000
$ ip link set can0 up
If you don't own a can interface can create a virtual can device:
$ sudo modprobe vcan
$ sudo ip link add dev vcan0 type vcan
$ sudo ip link set up vcan0
Verify using ifconfig:
$ ifconfig
vcan0: flags=193<UP,RUNNING,NOARP> mtu 72
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 1000 (UNSPEC)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Either you build your own Docker image using the provided Dockerfile, or you use a 3rd party provided Docker image. Following guidelines assume the latter.
To run the container software you must pass the can interface into the container using the -e CAN=<if>
option.
To run the process in background/detached mode pass the -d
option.
Run the container as following:
$ docker run --rm --network host -d -e CAN=can0 "geoffreyvl/canopensocket:latest"
Verify that the container is running:
$ docker container ls
On your host system make sure to have the canopencomm
application.
It's part of the CANopenSocket sources, but you need to compile it from source.
To send commands through your gateway, use syntax according to the example below:
$ canopencomm -t localhost -p 6000
For more examples visit the CANopenSocket repo.
You can use a second terminal to dump the traffic at your can0 interface:
$ candump can0
...
can0 701 [1] 7F
can0 000 [2] 01 01
can0 181 [2] 00 00
can0 701 [1] 05
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。