I am trying to read mavlink messages from my pixhawk with an arduino, i have the code shown below, which as far as i can tell just 'listens' to the pixhawk. It works nice and everything but i only get the heartbeat, raw_imu, and vff_hud mavlink messages. how do i get other mavlink messages (such as the rc_scaled_channels)? do i need to send request to the pixhawk? Thanks!

#include <SoftwareSerial.h>
SoftwareSerial MavlinkSerial= SoftwareSerial(2, 3);

int buffidx;
int c;
int buffer[256];
#define BUFFSIZ 240
///////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup()
{
Serial.begin(9600);
MavlinkSerial.begin(57600);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
void loop()
{
readline();
for(buffidx = 0; buffidx<(buffer[1]+8); buffidx++)
{
Serial.print(buffer[buffidx], HEX);
Serial.print(",");
}
Serial.println(" ");
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
void readline(void) {
buffidx = 0;
while (1)
{
c=MavlinkSerial.read();
if (buffidx == BUFFSIZ-1)
{
buffer[buffidx] = 0;
return;
}
buffer[buffidx++]= c;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • Beautiful. Can't wait to try this out myself.

    Looking forward to some responses to this.

This reply was deleted.

Activity