|
@@ -27,78 +27,79 @@
|
|
|
|
|
|
namespace Protocol
|
|
|
{
|
|
|
- class USBDecoder
|
|
|
- {
|
|
|
- public:
|
|
|
- USBDecoder() : usbDiffSignalRealEdgesCount_(0), waveMaxTimeIndexLen_(0)
|
|
|
- {
|
|
|
- differenceEopIndexs_ = {};
|
|
|
- resultCells_ = {};
|
|
|
- resultEvents_ = {};
|
|
|
- usb_packets_ = {};
|
|
|
- signEdgePulse_ = {};
|
|
|
- }
|
|
|
-
|
|
|
- static std::vector<std::string> EventInfoTitles();
|
|
|
-
|
|
|
- bool DecodeUSB(const UsbDecodeOptions& option, const EdgePulseDataTwoLevels& edge_pulses_dp,
|
|
|
- const EdgePulseDataTwoLevels& edge_pulses_dm, UsbDecodeResult& result);
|
|
|
-
|
|
|
- private:
|
|
|
- USBEnums::USBSpeed usbSpeed_;
|
|
|
- bool isAutoClk_;
|
|
|
- std::vector<UsbDecodeResultCell> resultCells_;
|
|
|
- std::vector<UsbDecodeEvent> resultEvents_;
|
|
|
- std::vector<USBPacket> usb_packets_;
|
|
|
- std::vector<int32_t> differenceEopIndexs_;
|
|
|
-
|
|
|
- std::vector<TwoLevelEdgePulse> signEdgePulse_;
|
|
|
-
|
|
|
- //usb差分信号非对齐位置
|
|
|
- std::vector<int32_t> usbDiffUnalignedFramesIndex_;
|
|
|
-
|
|
|
- //差分信号可用长度
|
|
|
- int32_t usbDiffSignalRealEdgesCount_;
|
|
|
- //传入波形最大时域长度
|
|
|
- int32_t waveMaxTimeIndexLen_;
|
|
|
- //同步帧长度
|
|
|
- int32_t syncBitLen_ = USB_USB_SYNC_BIT_MAX_LEN;
|
|
|
- bool ParseDiffSignalData(std::vector<TwoLevelEdgePulse> edge_pulses_dp,
|
|
|
- std::vector<TwoLevelEdgePulse> edge_pulses_dm)
|
|
|
- {
|
|
|
- //找出非对称边沿
|
|
|
- //todo add differenceEopIndexs
|
|
|
- //temp
|
|
|
- signEdgePulse_ = std::move(edge_pulses_dp);
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- bool CheckTimeDifferenceWithinThreshold(const double* array, int32_t size, double threshold = 0.15);
|
|
|
-
|
|
|
- static void ClearEdgeArray(Edge* edges, int32_t size);
|
|
|
-
|
|
|
- static bool CheckSyncEdges(Edge start_edge, const Edge* edges);
|
|
|
-
|
|
|
- //检查同步域在时域间隔
|
|
|
- bool CheckSyncSpans(const TwoLevelEdgePulse* node, int32_t count,
|
|
|
- int32_t& avg_spans);
|
|
|
-
|
|
|
- bool CheckSyncSpansByArray(const int32_t* start_indexs, int32_t count, int32_t& avg_spans);
|
|
|
-
|
|
|
- // bool FindAllSyncs(TwoLevelEdgePulse* node, std::vector<SYNC>& all_sync
|
|
|
- // , double set_bit_time_span, bool force_normal_speed, bool polarity = false);
|
|
|
- bool FindAllSyncs(TwoLevelEdgePulse* node, std::vector<SYNC>& all_sync
|
|
|
- , double set_bit_time_span, bool polarity = false);
|
|
|
-
|
|
|
- // static bool FindAllSyncs(Protocol::TwoLevelEdgePulse* node, int32_t left_over_size,
|
|
|
- // std::vector<SYNC>& all_sync, bool polarity = false);
|
|
|
-
|
|
|
- bool FindPackets(int32_t& left_over_size,
|
|
|
- std::vector<USBPacket>& all_packet, double set_bit_time_span,
|
|
|
- bool polarity = false);
|
|
|
- bool CheckOptions(UsbDecodeOptions option, const std::vector<TwoLevelEdgePulse>& edge_pulses_dp,
|
|
|
- const std::vector<TwoLevelEdgePulse>& edge_pulses_dm, double& set_bit_time_span);
|
|
|
- bool ParseSingleData(double set_bit_time_span, bool auto_clock);
|
|
|
- };
|
|
|
+ class USBDecoder
|
|
|
+ {
|
|
|
+ public:
|
|
|
+ USBDecoder() : usbDiffSignalRealEdgesCount_(0), waveMaxTimeIndexLen_(0)
|
|
|
+ {
|
|
|
+ differenceEopIndexs_ = {};
|
|
|
+ resultCells_ = {};
|
|
|
+ resultEvents_ = {};
|
|
|
+ usb_packets_ = {};
|
|
|
+ signEdgePulse_ = {};
|
|
|
+ }
|
|
|
+
|
|
|
+ static std::vector<std::string> EventInfoTitles();
|
|
|
+
|
|
|
+ bool DecodeUSB(const UsbDecodeOptions& option, const EdgePulseDataTwoLevels& edge_pulses_dp,
|
|
|
+ const EdgePulseDataTwoLevels& edge_pulses_dm, UsbDecodeResult& result);
|
|
|
+
|
|
|
+ private:
|
|
|
+ USBEnums::USBSpeed usbSpeed_;
|
|
|
+ bool isAutoClk_;
|
|
|
+ std::vector<UsbDecodeResultCell> resultCells_;
|
|
|
+ std::vector<UsbDecodeEvent> resultEvents_;
|
|
|
+ std::vector<USBPacket> usb_packets_;
|
|
|
+ std::vector<int32_t> differenceEopIndexs_;
|
|
|
+
|
|
|
+ std::vector<TwoLevelEdgePulse> signEdgePulse_;
|
|
|
+
|
|
|
+ //usb差分信号非对齐位置
|
|
|
+ std::vector<int32_t> usbDiffUnalignedFramesIndex_;
|
|
|
+
|
|
|
+ //差分信号可用长度
|
|
|
+ int32_t usbDiffSignalRealEdgesCount_;
|
|
|
+ //传入波形最大时域长度
|
|
|
+ int32_t waveMaxTimeIndexLen_;
|
|
|
+ //同步帧长度
|
|
|
+ int32_t syncBitLen_ = USB_USB_SYNC_BIT_MAX_LEN;
|
|
|
+ bool ParseDiffSignalData(std::vector<TwoLevelEdgePulse> edge_pulses_dp,
|
|
|
+ std::vector<TwoLevelEdgePulse> edge_pulses_dm)
|
|
|
+ {
|
|
|
+ //找出非对称边沿
|
|
|
+ //todo add differenceEopIndexs
|
|
|
+ //temp
|
|
|
+ signEdgePulse_ = std::move(edge_pulses_dp);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ bool CheckTimeDifferenceWithinThreshold(const double* array, int32_t size, int32_t avg_span, double threshold = USB_TIME_DIFFERENCE_THRESHOLD);
|
|
|
+ bool CheckTimeDifferenceWithinThreshold(const double* array, int32_t size, double threshold = USB_TIME_DIFFERENCE_THRESHOLD);
|
|
|
+
|
|
|
+ static void ClearEdgeArray(Edge* edges, int32_t size);
|
|
|
+
|
|
|
+ static bool CheckSyncEdges(Edge start_edge, const Edge* edges);
|
|
|
+
|
|
|
+ //检查同步域在时域间隔
|
|
|
+ bool CheckSyncSpans(const TwoLevelEdgePulse* node, int32_t count,
|
|
|
+ int32_t& avg_spans);
|
|
|
+
|
|
|
+ bool CheckSyncSpansByArray(const int32_t* start_indexs, int32_t count, int32_t& avg_span);
|
|
|
+
|
|
|
+ // bool FindAllSyncs(TwoLevelEdgePulse* node, std::vector<SYNC>& all_sync
|
|
|
+ // , double set_bit_time_span, bool force_normal_speed, bool polarity = false);
|
|
|
+ bool FindAllSyncs(TwoLevelEdgePulse* node, std::vector<SYNC>& all_sync
|
|
|
+ , double set_bit_time_span, bool polarity = false);
|
|
|
+
|
|
|
+ // static bool FindAllSyncs(Protocol::TwoLevelEdgePulse* node, int32_t left_over_size,
|
|
|
+ // std::vector<SYNC>& all_sync, bool polarity = false);
|
|
|
+
|
|
|
+ bool FindPackets(int32_t& left_over_size,
|
|
|
+ std::vector<USBPacket>& all_packet, double set_bit_time_span,
|
|
|
+ bool polarity = false);
|
|
|
+ bool CheckOptions(UsbDecodeOptions option, const std::vector<TwoLevelEdgePulse>& edge_pulses_dp,
|
|
|
+ const std::vector<TwoLevelEdgePulse>& edge_pulses_dm, double& set_bit_time_span);
|
|
|
+ bool ParseSingleData(double set_bit_time_span, bool auto_clock);
|
|
|
+ };
|
|
|
}
|