/*************************************************************************
* CANopenSocket 测试
* 说明:
* 测试一下CANopenSocket的运行效果,效果还是不错的。
*
* 2017-3-23 深圳 南山平山村 曾剑锋
************************************************************************/
一、参考文档:
1. atmel9260上linux socketcan MCP2515调试笔记即CAN总线调试总结
http://velep.com/archives/348.html
二、遇到问题:
1. write: No buffer space available
echo 1000 > /sys/class/net/can0/tx_queue_len
三、测试步骤:
1. 设置波特率:
ip link set can0 type can bitrate 1000000 triple-sampling on
2. up can设备:
ifconfig can0 up
3. 测试数据发送:
cansend can0 111#1122334455667788
4. 测试canopend:
[zengjf@root ~]# ./canopend can0 -i 4 -c /tmp/CO_command_socket &
./canopend - starting CANopen device with Node ID 4(0x04), count=1 ...
./canopend - communication reset ...
./canopend - Command interface on socket '/tmp/CO_command_socket' started ...
./canopend - running ...
5. 测试canopencomm命令:
./canopencomm 4 stop # [1] OK
6. 测试index为1的设备心跳包:
./canopencomm [1] 1 write 0x1017 0 i16 5000 # [1] OK
7. 以上需要一个普通的无协议的设备来观察CAN总线上的数据。