Slamtec / rplidar_sdk

Open source SDK for Slamtec RPLIDAR series products
BSD 2-Clause "Simplified" License
428 stars 262 forks source link

Error, cannot bind to the specified serial port /dev/ttyUSB0 (rplidar_sdk v2.0.0) #92

Closed acampbellb closed 1 year ago

acampbellb commented 1 year ago

Hi - I have what is most likely a fairly trivial issue running a simple RPLIDAR demo program.

Trying to run the RPLIDAR SDK sample program ultra_simple. I am trying to run it on a Jetson AGX Orin, with Jetpack 5.0.2 (Ubuntu 20.0.4). I'm using the fairly new RPLIDAR S2, and using the rplidar_sdk version 2.0.0.

Below is what is output when I try ro run the ultra_simple demo program:

jetson@jetson-agx-orin:~/rplidar_sdk/output/Linux/Release$ ./ultra_simple --channel --serial /dev/ttyUSB0 Ultra simple LIDAR data grabber for SLAMTEC LIDAR. Version: SL_LIDAR_SDK_VERSION Error, cannot bind to the specified serial port /dev/ttyUSB0.

I have verified the USB serial port is active:

$ usb-devices

Bus=01 Lev=02 Prnt=03 Port=03 Cnt=03 Dev#= 6 Spd=12 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=10c4 ProdID=ea60 Rev=01.00 S: Manufacturer=Silicon Labs S: Product=CP2102N USB to UART Bridge Controller S: SerialNumber=be0ce8e63713ec11b621f2ef7a109228 C: #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA I: If#=0x0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=cp210x

$ ls -l /dev | grep ttyUSB

crw-rw-rw- 1 root jetson 188, 0 Dec 28 13:25 ttyUSB0

I have tried changing permissions on the serial port:

$ sudo chmod 777 /dev/ttyUSB0

I have tried this recommendation from a post (My understanding of the best way to handle this, is to add your userid to the 'dialout' group. The dialout group allows access to the serial ports.)

$ sudo adduser $USER dialout

I have tried setting udev rules, by adding the following line to the file: etc/udev/rules.d/50-usb-serial.rules

SUBSYSTEM=="tty", MODE="0666"

I would greatly appreciate any recommendations, how I can solve or diagnose this problem.

acampbellb commented 1 year ago

Solved the problem, I was calling the demo program as,

./ultra_simple --channel --serial /dev/ttyUSB0

And it needed a baud rate parameter as well (even though the doc states the parameter is OPTIONAL).

Calling the program as such did the trick (Note: baud rate is specific to RPLIDAR version)

./ultra_simple --channel --serial /dev/ttyUSB0 1000000