123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- // // ******************************************************************
- // // /\ /| @File USBDecode.h
- // // \ V/ @Brief
- // // | "") @Author lijinwen, ghz005@uni-trend.com.cn
- // // / | @Creation 2024-1-4
- // // / \\ @Modified 2024-1-15
- // // *(__\_\
- // // ******************************************************************
- #pragma once
- #include <iostream>
- #include <future>
- #include <chrono>
- #include <thread>
- #include <cmath>
-
- #include "../EdgePulse.h"
- #include "SYNC.h"
- #include "ProtocolUSBEnums.h"
- #include "USBDecodeOptions.h"
- #include "USBDecodeResult.h"
- #include "USBPacket.h"
- namespace Protocol
- {
- class USBDecode
- {
-
- public:
- USBDecode(): signalRate(), byteCount(0)
- {
- }
- double GetBitRateByPs() const;
- std::vector<std::string> EventInfoTitles() const;
- Enums::SignalRate SignalRate() const;
- void SetSignalRate(Enums::SignalRate value);
- uint16_t ByteCount() const;
- void SetByteCount(uint16_t value);
- static uint16_t MaxByteCount();
- static uint16_t MinByteCount();
- bool Parse_USB(UsbDecodeOptions option,std::vector<Protocol::TwoLevelEdgePulse> edgePluses1,
- std::vector<Protocol::TwoLevelEdgePulse> edgePluses2,std::promise<void>& cancellationSignal);
- private:
- UsbDecodeResult resultData;
- Enums::SignalRate signalRate;
- uint16_t byteCount;
- std::vector<USBPacket> usbPackets;
-
- private:
- bool CheckDifferenceWithinThreshold(double* array, int32_t size, double threshold = 0.15);
- void ClearEdgeArray(Protocol::Edge* edges, int32_t size);
- bool CheckSyncEdges(Protocol::Edge startEdge, Protocol::Edge* edges);
- bool CheckSyncSpans(Protocol::TwoLevelEdgePulse* node, int32_t& leftOverSize, int32_t count,
- int32_t& avgSpans);
- bool CheckSyncSpansByArrary(int32_t* startIndexs, const int32_t count, int32_t& avgSpans);
- bool FindAllSyncs(Protocol::TwoLevelEdgePulse* node, int32_t& leftOverSize,
- std::vector<SYNC>& allSYNC, std::promise<void>& cancellationSignal, bool polarity = false);
- bool FindPackets(Protocol::TwoLevelEdgePulse* node, int32_t& leftOverSize,
- std::vector<USBPacket>& allPacket, std::promise<void>& cancellationSignal,
- bool polarity = false);
- bool ParseData(std::vector<Protocol::TwoLevelEdgePulse> edgePluses,
- std::promise<void>& cancellationSignal);
- };
- }
|