фиксы до работы с перемычкой вместо оптики
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user