mirror of
https://github.com/lupyuen/pinephone-nuttx.git
synced 2025-01-13 05:08:32 +08:00
Adding Long Packet
This commit is contained in:
parent
9d403711e3
commit
b182aadf9a
1 changed files with 6 additions and 5 deletions
11
display.zig
11
display.zig
|
@ -119,22 +119,23 @@ fn compose_long_packet(
|
|||
const csl: u8 = @intCast(u8, cs & 0xff);
|
||||
const csh: u8 = @intCast(u8, cs >> 8);
|
||||
|
||||
// Packet Header (4 bytes): Data Identifier + Word Count + Error Correction COde
|
||||
// Packet Header (4 bytes) = Data Identifier + Word Count + Error Correction COde
|
||||
const header = [4]u8 { di, wcl, wch, ecc };
|
||||
|
||||
// Packet Payload:
|
||||
// Data (0 to 65,541 bytes):
|
||||
// Number of data bytes should match the Word Count (WC)
|
||||
assert(wc <= 65_541);
|
||||
assert(len <= 65_541);
|
||||
const payload = buf[0..len];
|
||||
|
||||
// Packet Footer (2 bytes): Checksum (CS)
|
||||
// Packet Footer (2 bytes) = Checksum (CS)
|
||||
const footer = [2]u8 { csl, csh };
|
||||
|
||||
// TODO: Packet = Packet Header + Payload + Packet Footer
|
||||
// Packet = Packet Header + Payload + Packet Footer
|
||||
var pkt = std.mem.zeroes([1024]u8);
|
||||
assert(pkt.len >= header.len + len + footer.len); // Increase pkt size
|
||||
std.mem.copy(u8, pkt[0..header.len], &header);
|
||||
////std.mem.copy(u8, pkt[header.len..header.len + len], buf);
|
||||
std.mem.copy(u8, pkt[header.len..], payload);
|
||||
std.mem.copy(u8, pkt[(header.len + len)..], &footer);
|
||||
const pktlen = header.len + len + footer.len;
|
||||
|
||||
|
|
Loading…
Reference in a new issue