文章
cantest示例
cantest syntax
Syntax: "cantest test-number [net id-first id-last count
txbuf rxbuf txtout rxtout baud
testcount data0 data1 ... data8]"
If cantest is called without parameters all available can-devices and version-numbers will be shown and a short help-screen is printed!
parameter description default
---------------------------------------------------------------
net logical net-number(canOpen()) 0
id-first enabled can-id's start-id 0
id-last enabled can-id's stop-id 0
count count of CMSG-packets 1
txbuf tx-queue-size of handle(canOpen) 10
rxbuf rx-queue-size of handle(canOpen) 100
txtout tx-timeout of handle 1000
rxtout rx-timeout of handle 5000
baud baudrate-index 2 (500 kbit/s)
testcount count of ntcan-API-Calls 10 (-1 => forever)
databyte0 Up to 8 databytes for Test 0 or 1 8-Byte-Frames with 32-Bit Counters
.
.
databyte7
test description
---------------------------------------------------------------
0 sending can-frames without wait (canSend)
1 sending can-frames with wait (canWrite)
2 reading can-frames without wait (canTake)
3 reading can-frames with wait (canRead)
4 reading events (canReadEvent)
5 sending events (canSendEvent)
用canRead()方式读取所有29-bit ID的CAN消息
cantest 3 0 0x20000000 0x3fffffff 1 10 100 1000 5000 4 -1
3 -- canRead
0 -- net0
0x20000000 -- first-id 29-bit id 0x00000000
0x3fffffff -- last-id 29-bit id 0x1fffffff
1 -- count of CMSG-packets
10 -- txbuf (useless here)
100 -- rxbuf
1000 -- tx timeout every 1 second (useless here)
5000 -- rx timeout every 5 seconds
4 -- baud rate 250k bit/s, 2 for 500k bit/s, 0 for 1000k bit/s.
-1 -- count of ntcan-API-Calls, -1 is forever canRead the bus.
用canRead()方式读取所有11-bit ID的CAN消息
cantest 3 0 0 0x7ff 1 10 100 1000 5000 4 -1
3 -- canRead
0 -- net0
0 -- first-id 11-bit id 0x0
0x7ff -- last-id 11-bit id 0x7ff
1 -- count of CMSG-packets
10 -- txbuf (useless here)
100 -- rxbuf
1000 -- tx timeout every 1 second (useless here)
5000 -- rx timeout every 5 seconds
4 -- baud rate 250k bit/s, 2 for 500k bit/s, 0 for 1000k bit/s.
-1 -- count of ntcan-API-Calls, -1 is forever canRead the bus.
每隔50毫秒用canSend()方式发送29-bit ID 0x1f000606的CAN消息10次
cantest 0 0 0x3f000606 0x3f000606 1 10 100 50 5000 4 10 0x22 0x33
0 -- canSend
0 -- net0
0x3f000606 -- first-id 29-bit id 0x1f000606
0x3f000606 -- last-id 29-bit id 0x1f000606
1 -- count of CMSG-packets
10 -- txbuf
100 -- rxbuf(useless here)
50 -- tx timeout every 50 ms
5000 -- rx timeout every 5 seconds(useless here)
4 -- baud rate 250k bit/s, 2 for 500k bit/s, 0 for 1000k bit/s.
10 -- 10 times of ntcan-API-Calls (same msg send 10 times)
0x22 -- data 1
0x33 -- data 2
每隔50毫秒用canSend()方式发送CAN消息1条,共发送10次,每条消息的ID(11-bit)依次从0x1到0xA递增
cantest 50 0 0x1 0xA 0 10 100 50 5000 4 10 0x22 0x33
50 -- canSend() with incremeting ids
0 -- net0
0x1 -- first-id 11-bit id 0x1
0xA -- last-id 11-bit id 0xA
1 -- count of CMSG-packets
10 -- txbuf
100 -- rxbuf(useless here)
50 -- tx timeout every 50 ms
5000 -- rx timeout every 5 seconds(useless here)
4 -- baud rate 250k bit/s, 2 for 500k bit/s, 0 for 1000k bit/s.
10 -- 10 times of ntcan-API-Calls (same msg send 10 times)
0x22 -- data 1
0x33 -- data 2
total 10 can messages will be sent. 1 count of CMSG-packets multiplies
10 times of ntcan-API-Calls equal 10 CAN messages.
每隔50毫秒用canSend()方式发送CAN消息7条,共发送10次,每条消息的ID(11-bit)依次从0x1到0x7递增
cantest 50 0 0x1 0x7 7 10 100 50 5000 0 10 0x22 0x33
50 -- canSend() with incremeting ids
0 -- net0
0x1 -- first-id 11-bit id 0x1
0x7 -- last-id 11-bit id 0x7
7 -- count of CMSG-packets
10 -- txbuf
100 -- rxbuf(useless here)
50 -- tx timeout every 50 ms
5000 -- rx timeout every 5 seconds(useless here)
0 -- baud rate 1000k bit/s, 2 for 500k bit/s, 4 250k bit/s.
10 -- 10 times of ntcan-API-Calls (same msg send 10 times)
0x22 -- data 1
0x33 -- data 2
total 70 can messages will be sent. 7 count of CMSG-packets multiplies
10 times of ntcan-API-Calls equal 70 CAN messages.
用canReadX()方式读取所有11-bit ID的CAN FD消息
cantest 63 0 0x0 0x7ff 1 10 100 1000 5000 0:19 -1
63 -- canReadX()
0 -- net0
0 -- first-id 11-bit id 0x0
0x7ff -- last-id 11-bit id 0x7ff
1 -- count of CMSG-packets
10 -- txbuf(useless here)
100 -- rxbuf
50 -- tx timeout every 50 ms(useless here)
5000 -- rx timeout every 5 seconds
0:19 -- the nominal bit rate is 1000 KBit/s, and the data bit rate is 5000 KBit/s
-1 -- count of ntcan-API-Calls, -1 is forever canReadX the bus.
用canSendX()方式发送11-bit ID的CAN FD消息
cantest 60 0 0x1 0x1 1 10 100 50 5000 0:19 1
60 -- canSendX()
0 -- net0
0x1 -- first-id 11-bit id 0x1
0x1 -- last-id 11-bit id 0x7
1 -- count of CMSG-packets
10 -- txbuf
100 -- rxbuf(useless here)
50 -- tx timeout every 50 ms
5000 -- rx timeout every 5 seconds(useless here)
0:19 -- nominal bit rate is 1000k bit/s, data bit rate is 5000k bit/s.
1 -- once of ntcan-API-Calls
在此处没有输入任何CAN data, cantest会自动填充64 bytes的data来发送。
Send and receive CAN message using 2 CAN ports in a CAN-PCIe/402-B4.
Connect CAN cable between port can0 and port can1 of CAN-PCIe/402-B4 board.
cantest 3 0 0 0x7ff 1 10 100 1000 5000 4 -1 -- Use can0 to receive CAN messages.
cantest 50 1 0x1 0xA 0 10 100 50 5000 4 10 0x22 0x33 -- Use can1 to send CAN messages.