Mavlink "Fix type" showing with delay on serial monitor

Hi!

Hardware details: Pixhawk, Teensy (Arduino)
Query:
Below I attached a fragment of my code and there is an issue that the fix type is displaying with delay on the serial monitor. All over my code there is no delay and I just print “millis()” to check the delay and it is varying between 1 to 3 seconds. So, I also get the GPS raw data with the same delay. Is there any solution to fix it?


while (Serial1.available()) {
uint8_t c = Serial1.read();

//Get new message
if (mavlink_parse_char(MAVLINK_COMM_0, c, &msg, &status)) {

  //Handle new message from autopilot
  switch (msg.msgid) {

    case MAVLINK_MSG_ID_GPS_RAW_INT:
      {
        mavlink_gps_raw_int_t packet;
        mavlink_msg_gps_raw_int_decode(&msg, &packet);

        gps_raw_lat = packet.lat;
        // Serial.println(gps_raw_lat);
        gps_lat1 = gps_raw_lat * 0.0000001L;
        //Serial.println(gps_lat1, 5);
        gps_raw_lon = packet.lon;
        gps_lon1 = gps_raw_lon * 0.0000001L;
        fix = packet.fix_type;
        Serial.println(millis()):

}

hi
how did you execute this mavlink code. Did you place this code in some directory on the sd card.

1 Like

No SD card. Just uploading on teensy 4.0.

1 Like

How do you know exactly that there is a delay? How are you comparing the timestamps?

I just print the millis() and observed that the seconds value is displayed after every 1 to 3 seconds interval. e.g 1004, 2004, 5026 and so on.

So this isn’t a delay between your flight controller and your Teensy then but rather that the message doesn’t arrive often or regular enough?

So is it a GPS antenna slow receiving capacity?

Any idea about the potential cause?

No, I think the message containing GPS information is not sent at a higher rate. What you see has probably nothing to do with what the GPS sends to PX4.

How are you connecting with PX4 and what configuration are you using for the telemetry there? E.g. Telem1 with baudrate 57600 and a certain rate and a mode such as “Normal”. Can you share your settings, e.g. the params that you set. Or you can also type mavlink status in the MAVLink shell in QGC which tells you what is configured.