6 years, 3 months ago.

ROS serial (Buffered Serial) preventing other serial ports being used on mbed device Nucleo F303K8?

Hi,

I'm quite new to the Mbed OS and the STM32 so please bare with me.

I’m using ROS serial on a Nucleo F303K8 and want to use the extra serial port on the device. ROS serial uses the buffered serial library and I think the problem is to do with the interrupts it uses, but don't know enough about the architecture to work out the problem.

In the code whenever I try to initialize the extra serial object "BufferedSerial sBusSerial(PA_2,PA_3);", ROS serial stops working I have checked the pins I have requested don’t conflict with the ones ROS serial uses, but have had no luck. Please note ROS serial also uses Buffered serial and is is initialized by "nh.initNode();".

At the moment Im totally lost, any suggestions would be greatly appreciated?

Thanks in advance Joe

include the mbed library with this snippet

#include "mbed.h"
#include <ros.h>
#include <std_msgs/Int16.h>
#include "BufferedSerial.h"

BufferedSerial sBusSerial(PA_2,PA_3);
DigitalOut myled1(LED1);
DigitalOut myled2(LED2);

ros::NodeHandle nh;

void SetPitch (const std_msgs::Int16& PitchState)
{
    if(PitchState.data>0)
    {
        //SBUS_Build_Packet();
        myled1 = 1;
        //sBusSerial.write(SBUS_Packet_Data, 25);
    }
    else
    {
        myled1 = 0;
    }
}

void SetYaw (const std_msgs::Int16& YawState)
{
    if(YawState.data>0)
    {
        //SBUS_Build_Packet();
        //sBusSerial.write(SBUS_Packet_Data, 25);
    }
}

ros::Subscriber<std_msgs::Int16> SubSetPitch("Gimble_Pitch", SetPitch );
ros::Subscriber<std_msgs::Int16> SubSetYaw("Gimble_Yaw", SetYaw );

int main() {

    nh.initNode();
    nh.subscribe(SubSetPitch);
    nh.subscribe(SubSetYaw);

    while(1) {
        //myled1 = 1; // LED is ON
        //wait(0.05); // 200 ms
        //myled1 = 0; // LED is OFF
        //wait(0.05); // 1 sec
        nh.spinOnce();

    }
}

1 Answer

6 years, 3 months ago.

Hi

I am no sure, but you are using PA_2/PA_3 on UART_2

This UART is already used by the virtual COM used for debug printf (PA_2/PA_15)

Maybe you should use UART_1 pins.

Check https://os.mbed.com/users/mbed_official/code/mbed-dev/file/default/targets/TARGET_STM/TARGET_STM32F3/TARGET_STM32F303x8/TARGET_NUCLEO_F303K8/PeripheralPins.c/

You can slos check : https://os.mbed.com/teams/ST/wiki/STDIO