фиксы до работы с перемычкой вместо оптики

This commit is contained in:
2026-08-05 18:28:17 +03:00
parent e5c8c45dcc
commit c4c9167df1
17 changed files with 263 additions and 85 deletions

View File

@@ -1,6 +1,13 @@
#include "Protocol.h"
#include <stddef.h>
const char *messageName(MessageType type) {
static const char *names[] = {"DISCOVER", "DISCOVER_ACK", "PREPARE", "READY",
"START_STAGE", "RESULT", "ACK", "ABORT"};
const uint8_t index = static_cast<uint8_t>(type);
return index < sizeof(names) / sizeof(names[0]) ? names[index] : "UNKNOWN";
}
uint16_t packetCrc(const ProtocolPacket &p) {
const uint8_t *data = reinterpret_cast<const uint8_t *>(&p);
uint16_t crc = 0xFFFF;
@@ -19,4 +26,3 @@ bool validPacket(const ProtocolPacket &p) {
return p.magic == PROTOCOL_MAGIC && p.version == PROTOCOL_VERSION &&
p.type <= static_cast<uint8_t>(MessageType::ABORT) && p.crc == packetCrc(p);
}