UAT 105 Digital Technology and Networks
Worksheet 1 Reading a drone's bits
Objective
Read and interpret the bytes of real MAVLink frames, build an adder from gates and check the CRC of a whole file
Equipment and materials
- Computer with Python and pymavlink
- telemetry_sample.tlog from UAT 104
- MAVLink common.xml documentation
- Module 1 example code
Safety
- Desk work only; no flying
Steps
- Read the first 40 bytes with open(..., "rb") and pick out the first frame's length, sequence, system ID and message ID by hand
- Write a function that turns base_mode into the names of all 8 flags from common.xml
- Build an 8-bit adder from full_adder
- Test the adder on every pair 0–255 against (x + y) % 256
- Get each message's CRC_EXTRA from pymavlink
- Check every frame's CRC with crc16_mcrf4xx and count the mismatches
Record of results
| Field | Byte position | Hex value | Decimal value | Meaning |
|---|---|---|---|---|
| Test | Input | Expected result | Result obtained | Match? |
|---|---|---|---|---|
| Message ID | Message name | CRC_EXTRA | Frames | Frames with bad CRC |
|---|---|---|---|---|
Questions
The first 8 bytes of the file come before 0xFD. What are they, what time do they give when read big-endian, and why are they not part of the MAVLink frame?
Which base_mode value appears most often in the file, which flags does it decode to, and what does that say about the drone's state while it was recorded?
How many of the 65,536 pairs gave a carry of 1 in your 8-bit adder? How does the sum in those pairs relate to (x + y) % 256, and how does this connect to MAVLink's 8-bit sequence counter?
If no frame had a bad CRC, can you conclude that nobody forged a message in the file? Explain using how a CRC works.
Check before you hand in
What to hand in
- Table of the first frame header
- Flag decoder and adder code with test results
- Number of bad-CRC frames with code