can utils 4 0 6使用方法

2021-08-14 18:38:21 字數 2214 閱讀 7849

前提:交叉編譯了can-utils 4.0.6的幾個重要工具。busybox的檔案系統還要移植ip命令。

1、首先配置can0

ip link set can0 type can tq 125 prop-seg 6  phase-seg1 7 phase-seg2 2 sjw 1

這時dmesg可以看到sja1000_fpga_pci 0000:07:04.0: setting btr0=0x01 btr1=0x1c

周立功的usbcan-2a測試模組裡,波特率250kbs時就是btr0=0x01 btr1=0x1c

2、ip -details link show can0 檢視一下

can0: mtu 16 qdisc pfifo_fast state unknown qlen 10

link/can 

can state error-active (berr-counter tx 0 rx 0) restart-ms 0 

bitrate 500000 sample-point 0.875 

tq 125 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1

sja1000: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..64 brp-inc 1

clock 16000000

3、接收測試,接收測試軟體傳送的幀:

# ./candump can0

inte***ce = can0, family = 29, type = 3, proto = 1

<0x00000002> [8] 70 01 02 03 04 05 06 07 

<0x00000002> [8] 70 01 02 03 04 05 06 07 

<0x00000002> [8] 70 01 02 03 04 05 06 07 

<0x00000002> [8] 70 01 02 03 04 05 06 07 

<0x00000002> [8] 70 01 02 03 04 05 06 07 

<0x00000002> [8] 70 01 02 03 04 05 06 07 

<0x00000002> [8] 70 01 02 03 04 05 06 07 

<0x00000002> [8] 70 01 02 03 04 05 06 07 

<0x00000002> [8] 70 01 02 03 04 05 06 07 

4、傳送測試

./cansend can0 -e 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88

inte***ce = can0, family = 29, type = 3, proto = 1

測試軟體上能看到接收的幀

5、重啟

使用核心文件說的ip link set can0 type can restart-ms 100 會報

rtnetlink answers: device or resource busy

使用ifconfig can0 down ;ip link set can0 up type can

即可4種常見波特率:

250kbps:

ip link set can0 type can tq 125 prop-seg 6  phase-seg1 7 phase-seg2 2 sjw 1   

125kbps:                                    

ip link set can0 type can tq 250 prop-seg 6  phase-seg1 7 phase-seg2 2 sjw 1                                       

500kbps:

ip link set can0 type can tq 75 prop-seg 6  phase-seg1 7 phase-seg2 2 sjw 1 

1000kbps:

ip link set can0 up type can bitrate 2000000

常見用法:

ip -details link show can0

ifconfig can0 down ;ip link set can0 up type can

./candump can0 

./cansend   can0 -e 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88

pythonpip使用方法 pip使用方法整理

匯出專案已安裝的pip包 pip list 檢視專案中安裝的包 pip freeze requirements.txt 將專案中所用到的第三方庫輸出到requirements.txt中 pip install 版本號 pip install i 本次使用清華源進行安裝 離線安裝第三方庫 一鍵安裝整個...

使用方法 離型劑使用方法

1 使用離型劑前必須確保模具乾淨,無粉塵 蠟垢 樹脂垢 油汙等殘留物質。可以使用專用的模具潔模劑進行清洗,不可用其他液體清洗,以免清洗不乾淨或損壞模具。另外,如果您的模具是新的,在清洗乾淨後,務必要對模具進行初步處理,用離型劑在模具表面噴 刷塗5 6次,之後方可正常投入生產。2 使用離型劑時,首先要...

使用方法 卡丁車輪胎使用方法

輪胎的使用方法很重要 卡丁車輪胎是卡丁車場日常執行中的主要易損件,但是輪胎的使用方法很重要。哪些情況下會縮短輪胎的使用壽命呢?一 跑道地面粗糙 有的跑道在鋪瀝青時,或者選錯了瀝青中石子的規格,或者碾壓得不夠平整,導致路面粗糙。有的跑道使用現成的水泥地,但表面粗糙或不平整。有的室內跑道,為了提高輪胎的...