Serial Read 3 GPS on Orange Cube

Hello there,
I’m using Ardupilot with an Orange Cube and I would like to add an additional sensor using the GPS 1 port. All other ports are, unfortunately, already occupied.

So I modified the UserCode.cpp and added below’s code. Unfortunately, hal.serial(3)->available() is never available. Baudrate and connections of the sensor have already been check.

Can you give any advice what else could be the culprit here?

Thanks!

#ifdef USERHOOK_MEDIUMLOOP
void Copter::userhook_MediumLoop()
{
    // put your 10Hz code here
    // Serial 3 is supposed to work in Full Duplex:
    mavlink_message_t rec_msg;
    mavlink_status_t mav_status;
    uint8_t byte = 0;
    
    // gcs().send_text(MAV_SEVERITY_CRITICAL, "TEST\n");
    hal.serial(3)->begin(115200);
    
    while(hal.serial(3)->available() > 0){      // simple Arduino-like implementation
       byte = hal.serial(3)->read();
       gcs().send_text(MAV_SEVERITY_CRITICAL, "Byte received");
       
       if(mavlink_parse_char(MAVLINK_COMM_0 , byte, &rec_msg, &mav_status) == 1){  // decode incoming bytes to mavlink

        gcs().send_text(MAV_SEVERITY_CRITICAL,"Message received\n");
        printf("Message\n");
        }
    } 

}
#endif

What SERIAL3* parameters have you got set? Could these be stopping your other serial communications?
GPS_TYPE parameters tie in with serial ports set to PROTOCOL = 5 too, so could potentially affect your GPS config too.

I’m not sure why you would modify the code just to connect another serial device - you could probably use LUA scripting to at least test everything before adding a driver (if needed) without modifying any base code. I could be misunderstanding something though.

Hmm I’m not sure. My serial parameters are set to:

SERIAL3_BAUD 115
SERIAL3_OPTIONS 8
SERIAL3_PROTOCOL 2

I use MavLink v2 as communication protocol. Interestingly sending appears to work. Right, Lua could be another track. But as far as I understood the UserCode.cpp is exactly for bringing in your own mods. But Lua might be worth a try.