Close

Updated header structure

A project log for n00n - Real Time Music Sensor Streaming Protocol

MIDI is so outdated, welcome to the 20s and the 16-bit world !

yann-guidon-ygdesYann Guidon / YGDES 06/21/2023 at 02:250 Comments

I decided to change the structure of the header : it now contains the checksum of the payload, so it is not appended after the payload. This "protects" the checksum with the header's checksum.

The checksums are nested now, which imposes a sequence for the checksums :

  1. The payload's checksum must be computed first (while the header is created)
  2. The header's checksum is computed when all the header's fields are filled.

This creates a new situation. The header is now 20 bytes long and the payload checksum might be cleared when there is no payload.

But if the payload has a length of one word (32 bits) or less, then it could be stored in the header instead...

The source code has been modified, it was not complex. The log 4. Header and payload checksums with PEAC is thus deprecated for the detailed description and code, though many aspects are still relevant. The header is now:

typedef struct {
  uint16_t
     Sign1,  // 'N', '0'
     Sign2,  // '0', 'n'
     Timecode_Frac,
     Timecode_Sec,
     Channel_ID,
     Type_Flags,
     Payload_checksum1,
     Payload_checksum2,
     Payload_Words,
     Header_checksum;
} N00N_header_struct;

 That's still 16 bytes of actual data, the 4 first bytes are only for static validation and resynch. Everything remains 32-bit-aligned as before, and the payload is appended as is after the header.

Discussions