WIP: device synchronization

This commit is contained in:
Jan Käberich 2022-08-07 03:01:22 +02:00
parent 047f6ce981
commit 58918f81c1
90 changed files with 8970 additions and 310 deletions

View file

@ -8,8 +8,8 @@
static uint8_t inputBuffer[1024];
uint16_t inputCnt = 0;
static uint8_t outputBuffer[1024];
static Communication::Callback callback = nullptr;
static uint8_t blockAcks = 0;
void Communication::SetCallback(Callback cb) {
callback = cb;
@ -66,7 +66,15 @@ void communication_usb_input(const uint8_t *buf, uint16_t len) {
}
bool Communication::SendWithoutPayload(Protocol::PacketType type) {
if(type == Protocol::PacketType::Ack && blockAcks) {
blockAcks--;
return true;
}
Protocol::PacketInfo p;
p.type = type;
return Send(p);
}
void Communication::BlockNextAck() {
blockAcks++;
}

View file

@ -13,6 +13,7 @@ using Callback = void(*)(const Protocol::PacketInfo&);
void SetCallback(Callback cb);
void Input(const uint8_t *buf, uint16_t len);
bool Send(const Protocol::PacketInfo &packet);
void BlockNextAck();
bool SendWithoutPayload(Protocol::PacketType type);
}

View file

@ -117,6 +117,8 @@ uint16_t Protocol::EncodePacket(const PacketInfo &packet, uint8_t *dest, uint16_
case PacketType::RequestFrequencyCorrection:
case PacketType::RequestAcquisitionFrequencySettings:
case PacketType::RequestDeviceStatus:
case PacketType::SetTrigger:
case PacketType::ClearTrigger:
// no payload
break;
case PacketType::VNADatapoint: payload_size = packet.VNAdatapoint->requiredBufferSize(); break;

View file

@ -331,6 +331,8 @@ enum class PacketType : uint8_t {
DeviceStatusV1 = 25,
RequestDeviceStatus = 26,
VNADatapoint = 27,
SetTrigger = 28,
ClearTrigger = 29,
};
using PacketInfo = struct _packetinfo {