Change baudrate HSerial

Hi, I want to change serial port’s baudrate but it ignores my value and the conection fails.

firmware:
void hMain()
{

	Serial.printf("init ROSbot\n");
	rosbot.initROSbot(sensor_type);
	Serial.printf("init with dvice\n");
		
	platform.begin(&RPi);
    RPi.setBaudrate(9600);
	nh.getHardware()->initWithDevice(&platform.LocalSerial);
	
	nh.initNode();

	initBatteryPublisher();
	initPosePublisher();
	initIMUPublisher();
	initDistanceSensorsPublisher();
	initCmdVelSubscriber();
	initResetOdomSubscriber();

ros-core2-client:

import rospy
from rosserial_python import SerialClient, RosSerialServer
from serial import SerialException, Serial
from time import sleep
import multiprocessing

import sys

if __name__=="__main__":

    rospy.init_node("serial_node")
    rospy.loginfo("ROS Serial Python Node")

    port_name = rospy.get_param('~port','/dev/ttyUSB0')
    baud = int(rospy.get_param('~baud','9600'))


   
    # TODO: should these really be global?
    tcp_portnum = int(rospy.get_param('/rosserial_embeddedlinux/tcp_port', '11411'))
    fork_server = rospy.get_param('/rosserial_embeddedlinux/fork_server', False)

    # TODO: do we really want command line params in addition to parameter server params?
    sys.argv = rospy.myargv(argv=sys.argv)
    if len(sys.argv) >= 2 :
        port_name  = sys.argv[1]
    if len(sys.argv) == 3 :
        tcp_portnum = int(sys.argv[2])

    if port_name == "tcp" :
        server = RosSerialServer(tcp_portnum, fork_server)
        rospy.loginfo("Waiting for socket connections on port %d" % tcp_portnum)
        try:
            server.listen()
        except KeyboardInterrupt:
            rospy.loginfo("got keyboard interrupt")
        finally:
            rospy.loginfo("Shutting down")
            for process in multiprocessing.active_children():
                rospy.loginfo("Shutting down process %r", process)
                process.terminate()
                process.join()
            rospy.loginfo("All done")

    else :          # Use serial port
        while not rospy.is_shutdown():
            rospy.loginfo("Connecting to %s at %d baud" % (port_name,baud) )
            try:
                if port_name == '/dev/ttyCORE2':
                    port = Serial(port_name, baud, timeout=2.5, rtscts=True, dsrdtr=True)
                else:
                    port = Serial(port_name, baud, timeout=2.5)
                client = SerialClient(port, 0)
                client.run()
            except KeyboardInterrupt:
                break
            except SerialException:
                sleep(1.0)
                continue
            except OSError:
                sleep(1.0)
                continue

Hi Diego,

I have read your post in this thread and I’m guessing that you’ve already found the answer to your question? :wink:

Regards,
Hubert

Yes, thank you for your patience.