Closed GoogleCodeExporter closed 8 years ago
I apologize for not giving an appropriate title; I'm certain I did, but it
doesn't seem that way.
Original comment by avidspar...@gmail.com
on 2 Aug 2012 at 7:42
all packets have a 6 byte header and 2 byte checksum
Original comment by Meee...@gmail.com
on 3 Aug 2012 at 1:25
[deleted comment]
I understand that, and my dissector understands that. An example packet looks
like this:
0000 fe 19 46 01 01 16 00 00 00 00 ce 00 39 00 54 52
0010 49 4d 5f 50 49 54 43 48 5f 43 44 00 00 00 04 eb
0020 a1
"0xfe" is the start symbol, "0x19" is the payload length, "0x46" is the
sequence number, "0x01" is the system id, "0x01" is the component id, "0x16" is
the message id (PARAM_VALUE). The payload begins at byte 6 (after the first 6
bytes of the header, bytes 0-5). As you can see, there are four zeroes
starting the packet, looking suspiciously like the float field, param_value.
"ce 00" is the little-endian encoded total "count" of parameters, and "39 00"
is the little-endian encoded "index" of the current parameter. Then the actual
param_id starts at byte 14 of the whole packet. Wireshark's ASCII
interpretation of the packet is below:
0000 ..F.........9.TR
0010 IM_PITCH_CD.....
0020 .
As you can see, the param_id, "TRIM_PITCH_CD" doesn't start till byte 14 (since
each ASCII character represents a byte). And the last two bytes, you can see,
are the checksum.
My program copies every byte of the packet correctly and in order. So you can
see that my analysis does include the 6 byte header and the 2 byte checksum,
and yet the payload fields still seem to be out of order.
Original comment by avidspar...@gmail.com
on 3 Aug 2012 at 2:00
the param name is a fix length, padded with 0's aka "char[16]"
Original comment by Meee...@gmail.com
on 4 Aug 2012 at 12:40
Yes, I understand that the parameter name is a fixed length. What I'm saying
is the fields are out of order. From my analysis, the fields appear as follows:
param_value (float)
param_count (int16)
param_index (int16)
param_id (char[16])
The snippet of hex that I posted was an entire Mavlink packet, including the
6-byte header and 2-byte checksum. This is JUST the payload:
00 00 00 00 ce 00 39 00 54 52 49 4d 5f 50 49 54 43 48 5f 43 44 00 00 00 04
So the fields are as follows:
param_value: 00 00 00 00
param_count: ce 00
param_index: 39 00
param_id: 54 52 49 4d 5f 50 49 54 43 48 5f 43 44 00 00 00 (as you said, padded
with 0's)
But the common.xml file says that the fields are in the following order:
param_id
param_value
param_type (this is the one I couldn't find, based on my analysis)
param_count
param_index
What I see in actual packets and what I see in the common.xml packet
definitions are inconsistent.
Original comment by avidspar...@gmail.com
on 6 Aug 2012 at 12:13
ok, now im on the same page. The packets are reordered when converted from the
xml to be byte aligned.Typicaly you will find they go from the the largest,
32bit to the smallest (exluding arrays). you will need to look at the mavlink
generator code to see how that decided to reorganise the paramaters.
Original comment by Meee...@gmail.com
on 6 Aug 2012 at 11:11
Ah, thank you for the clarification--makes a lot more sense. Guess this thread
can be closed!
Original comment by avidspar...@gmail.com
on 7 Aug 2012 at 12:46
Quick question--are the majority of the commands in the .xml files already in
that byte order, or do they typically change (at least some)? That would
explain why I've been getting some interesting values for some of the payload
fields. I guess what I'm asking is if using the .xml to parse commands is
still optimal, or if I need to change a bunch of parameters around in the .xml
files.
Original comment by avidspar...@gmail.com
on 7 Aug 2012 at 12:50
if the packet was all int8's i dont think the packet would change. but if it
was int8,int8,int16, the int 16 would be moved.
Original comment by Meee...@gmail.com
on 9 Aug 2012 at 11:13
Original comment by Meee...@gmail.com
on 9 Aug 2012 at 11:13
Original issue reported on code.google.com by
avidspar...@gmail.com
on 2 Aug 2012 at 7:25