Browse Source

新增udev规则命名mini_imu串口名

adam_zhuo 2 years ago
parent
commit
410b5338f3
2 changed files with 10 additions and 3 deletions
  1. 7 0
      initdev_mini_imu.sh
  2. 3 3
      serial_6dof_imu/src/serial_imu.cpp

+ 7 - 0
initdev_mini_imu.sh

@@ -0,0 +1,7 @@
+#!/bin/bash
+echo 'KERNEL=="ttyUSB*", SUBSYSTEMS=="usb",ATTRS{idVendor}=="1a86",ATTRS{idProduct}=="7523",SYMLINK+="mini_imu"' >  /etc/udev/rules.d/mini_imu_board.rules # Mini_Imu
+
+service udev reload
+sleep 2
+service udev restart
+

+ 3 - 3
serial_6dof_imu/src/serial_imu.cpp

@@ -27,13 +27,13 @@ void show_direction() {
 int main(int argc, char** argv)
 {
     
-    string imu_dev = "com1";
+    string imu_dev = "/dev/mini_imu";
     int order = 0;
     string input;
 
     while (true)
     {
-        cout << "输入串口号(例如:/dev/ttyUSB0):" << endl;
+        cout << "输入串口号(如果执行了initdev_mini_imu.sh则为:/dev/mini_imu,否则需要使用'ls /dev'查看串口号):" << endl;
         cin >> imu_dev;
         
         int ret = initSerialPort(imu_dev.c_str());
@@ -82,4 +82,4 @@ int main(int argc, char** argv)
 
     closeSerialPort(); //关闭与IMU模块的串口连接
     return 0;
-}
+}