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