C12 Embedded systems in MicroPython and C · Practice
Commands over serial: parsing and protocols
Problems dealt one at a time, with new numbers every time. The kinds you miss come back more often, and you can keep going as long as you like.
Check
What's the 8-bit sum checksum (modulo 256) of the bytes 200, 100 and 180, in hex?
Check
A frame's bytes sum to 7F (mod 256). What checksum byte makes the total 0?
Check
A frame has 3 header bytes, an 8-byte payload and a 1-byte checksum. What fraction of it is payload?
Check
A reply of 20 characters goes out at 9600 baud. How long does it take?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
Check
A command's argument arrives as the characters '4', '0', '8' (ASCII codes 48 + digit). Accumulating n = n*10 + (c - '0') for each, what's n?
Check
A payload is the bytes A, B and C (170, 32, 99). Print its 8-bit sum checksum, then the byte that would make the frame's total zero (0 if the sum is already 0).
C on the course's RISC-V board (10 MHz, no floating point). #include "board.h" for the registers; print(x) shows a number. Tab indents; press Esc and then Tab to move on.
Check
A payload is 16, 32, 7.
(a)
What is its 8-bit sum?
(b)
What checksum byte makes the total 0 modulo 256?
Check
A command line answers with 12 characters at 9600 baud.
(a)
How long is the answer on the wire?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
(b)
At most how many such answers a second?
Check
Sum checksum of 77, 200, 128, in hex?
Check
Byte that zeroes a sum of 3C?
Check
Payload share with 2 header bytes, 16 payload, 1 checksum?
A kind of problem counts as solid once you've got it right on the first try twice in a row. Back to the lesson · Practice every topic in C12