mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-10 00:43:41 +00:00
WIP: device synchronization
This commit is contained in:
parent
047f6ce981
commit
58918f81c1
90 changed files with 8970 additions and 310 deletions
|
|
@ -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++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -331,6 +331,8 @@ enum class PacketType : uint8_t {
|
|||
DeviceStatusV1 = 25,
|
||||
RequestDeviceStatus = 26,
|
||||
VNADatapoint = 27,
|
||||
SetTrigger = 28,
|
||||
ClearTrigger = 29,
|
||||
};
|
||||
|
||||
using PacketInfo = struct _packetinfo {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue