Mavlink message length value

I’m trying to manually parse some Mavlink messages that I’m getting on serial port 2 of my Pixhawk. I’m getting hung up right from the start because the message lengths don’t match the reported value. For example, here are two consecutive messages that I captured. Values are in hexidecimal.

FE 09 A0 01 01 02 03 59 03 03 7A
FE 12 A1 01 01 FC 41 01 34 01 41 52 4D 4D 41 53 4B 54 72 37 84

From what I understand, the first byte (0xFE) is the message start, followed by a 6 byte header, payload, and two CRC bytes. So the first message should be 9 bytes and the second should be 18 bytes. Furthermore, they should be 9 and 18 bytes in addition to the 6 byte header. But the actual message lengths don’t seem to line up with that. Am I misunderstanding the length value?

Thanks!

Your packets don’t look valid as you are not reading enough bytes for the first one which is a heartbeat message. you have only read 9 + 2 bytes = 11, and not the required 9 (payload) + 8 = 17

Scroll down the page to see a Packet Anatomy picture which is helpful qgroundcontrol.org/mavlink/start

Thank you for the reply. I have the serial output of the Pixhawk feeding directly into a terminal emulator on my computer (minicom on Linux), so I’m capturing every single byte without prejudice. Any reason why the messages are coming in incomplete like that? They’re all like that. I can’t find even one that seems to have the correct length.

And just to reiterate, I’m capturing all the data indiscriminately and then passing them after the fact, so I’m not cutting off any messages.