TX2 can 通信測試開機啓動項

問題背景:在測試tx2 can通信時,每次開機需要單獨運行兩條命令

sudo ip link set can0 type can bitrate 500000(意思是設置CAN0通道波特率爲500kb/s)

sudo ip link set up can0(意思是將CAN0通道開啓)

但是我們用tx2肯定是希望每次開機程序跑起來以後直接將運算得到的CAN信號傳輸給車輛底層的啊,每次開機再來開啓CAN通道、設置波特率啥的豈不是開玩笑!!!

基於上述原因,要設置開機自啓腳本,具體參考了這篇博客:https://blog.csdn.net/qq_19004627/article/details/80661468

這篇博客中提到有A、B兩種方法,經過多次嘗試,本人用的TX2上第二種方法不成功,因此採用了A方法:

/etc/rc.local腳本是一個ubuntu16.04及其以前的系統中自帶的開機腳本,在沒有修改之前裏面內容如下:


#!/bin/sh -e  
#  
# rc.local  
#  
# This script is executed at the end of each multiuser runlevel.  
# Make sure that the script will "exit 0" on success or any other  
# value on error.  
#  
# In order to enable or disable this script just change the execution  
# bits.  
#  
# By default this script does nothing.  
    
exit 0  

那麼我要加入CAN的開機啓動項以後的效果是啥樣的呢,看下面這段代碼

#!/bin/sh -e  
#  
# rc.local  
#  
# This script is executed at the end of each multiuser runlevel.  
# Make sure that the script will "exit 0" on success or any other  
# value on error.  
#  
# In order to enable or disable this script just change the execution  
# bits.  
#  
# By default this script does nothing.  

sudo ip link set can0 type can bitrate 500000

sudo ip link set up can0
    
exit 0  

接下來重啓就生效了,ok,解決,問題不一樣可能具體解決方案不一樣啊,此方法僅用於記錄個人學習過程中遇到及解決的問題!

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章