Open BronWang opened 2 years ago
In 15th line, ''iostream = &Serial'' is revised to ''iostream = &Serial2'', which is right or not?
Hi @BronWang
The ros::NodeHandle
class has a getHardware()
method here:
https://github.com/ros-drivers/rosserial/blob/c169ae2173dcfda7cee567d64beae45198459400/rosserial_client/src/ros_lib/ros/node_handle.h#L130-L133
And the ArduinoHardware
class has a setPort()
method here:
https://github.com/ros-drivers/rosserial/blob/c169ae2173dcfda7cee567d64beae45198459400/rosserial_arduino/src/ros_lib/ArduinoHardware.h#L88-L90
So you should be able to change the port used by rosserial by adding this line as the first line of your setup()
function:
nh.getHardware()->setPort(&Serial2);
class ArduinoHardware { public: ArduinoHardware(SERIALCLASS* io , long baud= 57600){ iostream = io; baud = baud; } ArduinoHardware() {
if defined(USBCON) and !(defined(USE_USBCON))
elif defined(USE_TEENSY_HW_SERIAL) or defined(USE_STM32_HW_SERIAL)
else
endif
if defined(USE_USBCON)
endif
protected: SERIALCLASS* iostream; long baud; };