Erro, não é possível ligar à porta serial especificada / dev / ttyUSB0 durante a inicialização usando o systemd

0

Estou tentando executar um arquivo de inicialização durante a inicialização usando o systemd. O arquivo de lançamento lança o rplidar. Quando executo diretamente o arquivo .sh , ele está lançando o lidar.

$ systemctl status rosCore.service

● rosCore.service - start roscore
   Loaded: loaded (/etc/systemd/system/rosCore.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2018-04-15 09:31:13 CEST; 1min 5s ago
 Main PID: 710 (rosCoreService.)
   CGroup: /system.slice/rosCore.service
           ├─ 710 /bin/bash /usr/local/bin/rosCoreService.sh
           ├─ 940 /usr/bin/python /opt/ros/kinetic/bin/roslaunch rplidar_ros rplidar.launch
           ├─1029 /usr/bin/python /opt/ros/kinetic/bin/rosmaster --core -p 11311 -w 3 __log:=/root/.ros/log/fa4e9410-407e-11e8-acf8-f5f547bf4eb3/master.log
           └─1069 /opt/ros/kinetic/lib/rosout/rosout __name:=rosout __log:=/root/.ros/log/fa4e9410-407e-11e8-acf8-f5f547bf4eb3/rosout-1.log

Apr 15 09:31:13 PLRV1WB1 systemd[1]: Started start roscore.
Apr 15 09:31:14 PLRV1WB1 rosCoreService.sh[710]: Error, cannot bind to the specified serial port /dev/ttyUSB0.
Apr 15 09:31:15 PLRV1WB1 rosCoreService.sh[710]: RPLIDAR running on ROS package rplidar_ros
Apr 15 09:31:15 PLRV1WB1 rosCoreService.sh[710]: SDK Version: 1.5.7
Apr 15 09:31:15 PLRV1WB1 rosCoreService.sh[710]: [rplidarNode-2] process has died [pid 1072, exit code 255, cmd /home/plrv1wb1/catkin_ws/devel/lib/rplidar_ros/rpli
Apr 15 09:31:15 PLRV1WB1 rosCoreService.sh[710]: log file: /root/.ros/log/fa4e9410-407e-11e8-acf8-f5f547bf4eb3/rplidarNode-2*.log

O erro é

Apr 15 09:31:14 PLRV1WB1 rosCoreService.sh[710]: Error, cannot bind to the specified serial port /dev/ttyUSB0.

Meu serviço e arquivo .sh se parecem com isso.

/etc/systemd/system/
******* rosCore.service *************
Unit]
Description=start roscore
Restart=on-abort

[Service]
ExecStart=/usr/local/bin/rosCoreService.sh

[Install]
WantedBy=default.target
**********************************************
/usr/local/bin/
*******************rosCoreService.sh **********
#!/bin/bash
source /home/bc/.bashrc
source /opt/ros/kinetic/setup.bash
source /home/bc/catkin_ws/devel/setup.bash
roslaunch rplidar_ros rplidar.launch

***************************************************
    
por BhanuKiran 15.04.2018 / 14:53

1 resposta

2

Adicionar

After=dev-ttyUSB0.device

para o bloco [Unit] . Se isso não for suficiente, você terá que marcar o dispositivo em udev , consulte man systemd.device :

To tag a udev device, use "TAG+="systemd"" in the udev rules

    
por 15.04.2018 / 17:22