MSP icon indicating copy to clipboard operation
MSP copied to clipboard

MSP update rate is slow and sporadic

Open K-Space909 opened this issue 4 years ago • 0 comments

Hi, I'm not an expert in Betaflight serial communication, but I thought I could request my attitude data at a much faster rate. Right now it seems like my communication is bottlenecked in some way. It only updates 2-3x per second, and it inevitably halts with no further updates. Whwn it does update, I get anywhere from 5x to 30x updates all at once. So it comes in randomly-sized spurts, but only 2-3x per second. I'd like to pull all of my GPS, altitude, and attitude data around 100Hz if possible.

I tried going into the CLI and increasing the serial update rate, but that did not seem to affect anything.

#include <MSP.h>
#include <SoftwareSerial.h>

SoftwareSerial MSPSerial(2, 3); // RX, TX



MSP msp;

void setup()
{
    Serial.begin(115200);
    while (!Serial) {
        ; // wait for serial port to connect. Needed for Native USB only
    }
    delay(200);
    Serial.println("init");

    MSPSerial.begin(115200);

    msp.begin(MSPSerial);




}

void loop()
{
    msp_attitude_t att;
    if (msp.request(MSP_ATTITUDE, &att, sizeof(att))) {

        int16_t roll = att.roll;
        int16_t pitch = att.pitch;
        int16_t yaw = att.yaw;

        float roll_f = roll / 10.0;
        float pitch_f = pitch / 10.0;

        Serial.print(yaw);
        Serial.print(" ");
        Serial.print(pitch_f);
        Serial.print(" ");
        Serial.println(roll_f);
    }

  }

K-Space909 avatar Jan 19 '21 08:01 K-Space909