autowarefoundation / ros2_socketcan

A ROS2 wrapper around Linux SocketCAN
Apache License 2.0
110 stars 58 forks source link

Failed to set CAN socket name via ioctl() #30

Open wuxiaohua1011 opened 1 year ago

wuxiaohua1011 commented 1 year ago

Hi Thanks for writing this library.

I wanted to try out CAN for my project but am encountering the following error:

[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [socket_can_receiver_node_exe-1]: process started with pid [85606]
[socket_can_receiver_node_exe-1] [INFO] [1671057528.227663086] [socket_can_receiver]: interface: /dev/ttyUSB0
[socket_can_receiver_node_exe-1] [INFO] [1671057528.227695404] [socket_can_receiver]: interval(s): 0.010000
[socket_can_receiver_node_exe-1] [INFO] [1671057528.227701450] [socket_can_receiver]: use bus time: 0
[socket_can_receiver_node_exe-1] [ERROR] [1671057528.470725617] [socket_can_receiver]: Error opening CAN receiver: /dev/ttyUSB0 - Failed to set CAN socket name via ioctl()
[ERROR] [launch_ros.actions.lifecycle_node]: Failed to make transition 'TRANSITION_CONFIGURE' for LifecycleNode '/socket_can_receiver'
^C[WARNING] [launch]: user interrupted with ctrl-c (SIGINT)
[socket_can_receiver_node_exe-1] [INFO] [1671057530.174106048] [rclcpp]: signal_handler(signal_value=2)
[INFO] [socket_can_receiver_node_exe-1]: process has finished cleanly [pid 85606]

Physical setup: I have an Arduino Due with SEEED studio can bus.

I have the a USB to CAN connector plugged into the computer.

I believe the CAN port is showing up as /dev/ttyUSB0 because when I unplug it, it was the only one that disappeared.

Could you help me identifiy what is the possible issue?

Thanks! Best, Michael Wu

JWhitleyWork commented 1 year ago

If it is enumerated as /dev/ttyUSB0 then it is a serial interface, not SocketCAN. The module you link to is USB to RS485, which is not CAN. It does not look like the CAN adapter board is compatible with SocketCAN and must be programmed to interact with the CAN bus through the Arduino.