Okay, this is my full code. I am trying to send the request command so that I can read the IMU values (without changing the mode).
#include <mavlink.h>
void setup() {
Serial.begin(57600);
Serial1.begin(57600);
}
void loop() {
mavlink_message_t message;
uint8_t msgReceived = false;
mavlink_status_t status;
uint8_t buf[MAVLINK_MAX_PACKET_LEN];
mavlink_msg_command_long_pack(1, 241, &message, 1, 1, MAV_CMD_SET_MESSAGE_INTERVAL, 1, 105, 0, 0, 0, 0, 0, 0);
uint16_t len = mavlink_msg_to_send_buffer(buf, &message);
Serial1.write(buf, len);
if (Serial1.available() > 0) {
uint8_t result = Serial1.read();
msgReceived = mavlink_parse_char(MAVLINK_COMM_1, result, &message, &status);
if (msgReceived) {
switch (message.msgid) {
case MAVLINK_MSG_ID_HEARTBEAT:
{
mavlink_heartbeat_t hb;
mavlink_msg_heartbeat_decode(&message, &hb);
Serial.print("\n");
Serial.println("Heartbeat Message");
Serial.print("Msgid: "); Serial.println(message.msgid);
Serial.print("Type: "); Serial.println(hb.type);
Serial.print("Autopilot type: "); Serial.println(hb.autopilot);
Serial.print("System mode: "); Serial.println(hb.base_mode);
Serial.print("Custom mode: "); Serial.println(hb.custom_mode);
Serial.print("System status: "); Serial.println(hb.system_status);
Serial.print("Mavlink version: "); Serial.println(hb.mavlink_version);
delay(1000);
}
case MAVLINK_MSG_ID_HIGHRES_IMU:
{
mavlink_highres_imu_t highres;
mavlink_msg_highres_imu_decode(&message, &highres);
Serial.print("HiRes IMU Msgid: "); Serial.println(message.msgid);
Serial.print("Xacc: "); Serial.println(highres.xacc);
Serial.print("Yacc: "); Serial.println(highres.yacc);
Serial.print("Zacc: "); Serial.println(highres.zacc);
Serial.print("Xgyro: "); Serial.println(highres.xgyro);
Serial.print("Ygyro: "); Serial.println(highres.ygyro);
Serial.print("Zgyro: "); Serial.println(highres.zgyro);
Serial.print("Xmag: "); Serial.println(highres.xmag);
Serial.print("Ymag: "); Serial.println(highres.ymag);
Serial.print("Zmag: "); Serial.println(highres.zmag);
Serial.print("Absolute Pressure: "); Serial.println(highres.abs_pressure);
Serial.print("Diff Pressure: "); Serial.println(highres.diff_pressure);
Serial.print("Pressure Alt : "); Serial.println(highres.pressure_alt);
Serial.print("Temperature : "); Serial.println(highres.temperature);
Serial.print("\n");
delay(1000);
}
default :
{
Serial.println(message.msgid);
}
}//switch
}//if msg
}//if serial 1
}//loop
However, I cannot get the HIGHRES_IMU message ID to go through the switch case even after sending the command. The switch case goes straight to default and prints some inconsistent message IDs like #77 and #30.