ngscopeclient 0.1-dev+51fbda87c
SDCmdDecoder.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopeprotocols *
4* *
5* Copyright (c) 2012-2021 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
36#ifndef SDCmdDecoder_h
37#define SDCmdDecoder_h
38
39#include "PacketDecoder.h"
40
42{
43public:
44 enum stype
45 {
46 TYPE_HEADER,
47 TYPE_COMMAND,
48 TYPE_COMMAND_ARGS,
49 TYPE_RESPONSE_ARGS,
50 TYPE_CRC_OK,
51 TYPE_CRC_BAD,
52
53 TYPE_ERROR
54 };
55
57 {}
58
59 SDCmdSymbol(stype t, uint32_t d, uint32_t e=0, uint32_t f=0, uint32_t g=0)
60 : m_stype(t)
61 , m_data(d)
62 , m_extdata1(e)
63 , m_extdata2(f)
64 , m_extdata3(g)
65 {}
66
67 stype m_stype;
68 uint32_t m_data;
69
70 //Extended data for a few special responses
71 uint32_t m_extdata1;
72 uint32_t m_extdata2;
73 uint32_t m_extdata3;
74
75 bool operator== (const SDCmdSymbol& s) const
76 {
77 return (m_stype == s.m_stype) && (m_data == s.m_data) &&
78 (m_extdata1 == s.m_extdata1) && (m_extdata2 == s.m_extdata2) && (m_extdata3 == s.m_extdata3);
79 }
80};
81
82class SDCmdWaveform : public SparseWaveform<SDCmdSymbol>
83{
84public:
85 SDCmdWaveform (FilterParameter& cardTypeParam) : SparseWaveform<SDCmdSymbol>(), m_cardTypeParam(cardTypeParam) {};
86 virtual std::string GetText(size_t) override;
87 virtual std::string GetColor(size_t) override;
88
89 FilterParameter& m_cardTypeParam;
90};
91
92
97{
98public:
99 SDCmdDecoder(const std::string& color);
100
101 virtual void Refresh() override;
102
103 static std::string GetProtocolName();
104
105 virtual bool GetShowDataColumn() override;
106
107 std::vector<std::string> GetHeaders() override;
108
109 virtual bool CanMerge(Packet* first, Packet* cur, Packet* next) override;
110 virtual Packet* CreateMergedHeader(Packet* pack, size_t i) override;
111
112 virtual bool ValidateChannel(size_t i, StreamDescriptor stream) override;
113
114 enum CardType
115 {
116 SD_GENERIC,
117 SD_EMMC
118 };
119
120 PROTOCOL_DECODER_INITPROC(SDCmdDecoder)
121
122protected:
123 std::string m_cardtypename;
124};
125
126#endif
A parameter to a filter.
Definition: FilterParameter.h:86
Definition: PacketDecoder.h:85
Definition: PacketDecoder.h:40
Decodes the SD card command bus protocol.
Definition: SDCmdDecoder.h:97
virtual void Refresh() override
Evaluates a filter graph node.
Definition: SDCmdDecoder.cpp:80
virtual Packet * CreateMergedHeader(Packet *pack, size_t i) override
Creates a summary packet for one or more merged packets.
Definition: SDCmdDecoder.cpp:1350
virtual bool CanMerge(Packet *first, Packet *cur, Packet *next) override
Checks if multiple packets can be merged under a single heading in the protocol analyzer view.
Definition: SDCmdDecoder.cpp:1301
Definition: SDCmdDecoder.h:42
Definition: SDCmdDecoder.h:83
virtual std::string GetColor(size_t) override
Returns the displayed color (in HTML #rrggbb or #rrggbbaa notation) of a given protocol sample.
Definition: SDCmdDecoder.cpp:384
virtual std::string GetText(size_t) override
Returns the text representation of a given protocol sample.
Definition: SDCmdDecoder.cpp:411
A waveform sampled at irregular intervals.
Definition: Waveform.h:460
Descriptor for a single stream coming off a channel.
Definition: StreamDescriptor.h:46