ngscopeclient v0.2.2
Loading...
Searching...
No Matches
USB2PCSDecoder.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopeprotocols *
4* *
5* Copyright (c) 2012-2026 Andrew D. Zonenberg and contributors *
6* All rights reserved. *
7* *
8* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
9* following conditions are met: *
10* *
11* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
12* following disclaimer. *
13* *
14* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
15* following disclaimer in the documentation and/or other materials provided with the distribution. *
16* *
17* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
18* derived from this software without specific prior written permission. *
19* *
20* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
21* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
22* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
24* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
26* POSSIBILITY OF SUCH DAMAGE. *
27* *
28***********************************************************************************************************************/
29
35#ifndef USB2PCSDecoder_h
36#define USB2PCSDecoder_h
37
38#include "USB2PMADecoder.h"
39
44{
45public:
46
47 enum SymbolType
48 {
49 TYPE_SYNC,
50 TYPE_EOP,
51 TYPE_RESET,
52 //TODO: handle suspend (idle for >3 ms)
53 //TODO: handle resume
54 TYPE_DATA,
55 TYPE_ERROR
56 };
57
58 USB2PCSSymbol(SymbolType type = TYPE_SYNC, uint8_t data = 0)
59 : m_type(type)
60 , m_data(data)
61 {
62 }
63
64 SymbolType m_type;
65 uint8_t m_data;
66
67 bool operator==(const USB2PCSSymbol& rhs) const
68 {
69 return (m_type == rhs.m_type);
70 }
71};
72
73class USB2PCSWaveform : public SparseWaveform<USB2PCSSymbol>
74{
75public:
77 virtual std::string GetText(size_t) override;
78 virtual std::string GetColor(size_t) override;
79};
80
81class USB2PCSDecoder : public Filter
82{
83public:
84 USB2PCSDecoder(const std::string& color);
85
86 virtual void Refresh(vk::raii::CommandBuffer& cmdBuf, std::shared_ptr<QueueHandle> queue) override;
87
88 static std::string GetProtocolName();
89
90 PROTOCOL_DECODER_INITPROC(USB2PCSDecoder)
91
92protected:
93 enum BusSpeed
94 {
95 SPEED_1M,
96 SPEED_12M,
97 SPEED_480M
98 };
99
100 enum DecodeState
101 {
102 STATE_IDLE,
103 STATE_SYNC,
104 STATE_DATA
105 };
106
107 void RefreshIterationIdle(
108 size_t nin,
109 DecodeState& state,
110 BusSpeed& speed,
111 size_t& ui_width,
114 size_t& count,
115 int64_t& offset
116 );
117
118 void RefreshIterationSync(
119 size_t nin,
120 DecodeState& state,
121 BusSpeed speed,
122 size_t& ui_width,
125 size_t& count,
126 int64_t& offset,
127 uint8_t& data,
128 bool& first
129 );
130
131 void RefreshIterationData(
132 size_t nin,
133 size_t nlast,
134 DecodeState& state,
135 BusSpeed speed,
136 size_t& ui_width,
139 size_t& count,
140 int64_t& offset,
141 uint8_t& data);
142};
143
144#endif
Declaration of USB2PMADecoder.
Definition AcceleratorBuffer.h:204
Abstract base class for all filter graph blocks which are not physical instrument channels.
Definition Filter.h:105
A waveform sampled at irregular intervals.
Definition Waveform.h:514
Definition USB2PCSDecoder.h:82
A single symbol at the PCS layer (byte or command)
Definition USB2PCSDecoder.h:44
Definition USB2PCSDecoder.h:74
virtual std::string GetColor(size_t) override
Returns the displayed color (in HTML #rrggbb or #rrggbbaa notation) of a given protocol sample.
Definition USB2PCSDecoder.cpp:498
virtual std::string GetText(size_t) override
Returns the text representation of a given protocol sample.
Definition USB2PCSDecoder.cpp:519
Definition USB2PMADecoder.h:67