ngscopeclient 0.1-dev+51fbda87c
CANChannel.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopehal *
4* *
5* Copyright (c) 2012-2024 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 CANChannel_h
37#define CANChannel_h
38
44{
45public:
46
48 enum stype
49 {
52
55
58
61
64
67
70
73
76
79
82
85
88 };
89
92 {}
93
100 CANSymbol(stype t, uint32_t data)
101 : m_stype(t)
102 , m_data(data)
103 {
104 }
105
108
110 uint32_t m_data;
111
119 bool operator== (const CANSymbol& s) const
120 {
121 return (m_stype == s.m_stype) && (m_data == s.m_data);
122 }
123};
124
129class CANWaveform : public SparseWaveform<CANSymbol>
130{
131public:
133 virtual std::string GetText(size_t) override;
134 virtual std::string GetColor(size_t) override;
135};
136
142{
143public:
144
146 Oscilloscope* scope,
147 const std::string& hwname,
148 const std::string& color = "#808080",
149 size_t index = 0);
150
151 virtual ~CANChannel();
152};
153
154#endif
A filter or protocol analyzer channel which provides CAN bus data.
Definition: CANChannel.h:142
A single symbol within a CAN bus protocol decode.
Definition: CANChannel.h:44
bool operator==(const CANSymbol &s) const
Checks this symbol for equality against a second.
Definition: CANChannel.h:119
stype m_stype
Type of the symbol.
Definition: CANChannel.h:107
CANSymbol(stype t, uint32_t data)
Initializes a CAN symbol.
Definition: CANChannel.h:100
stype
Type of the symbol.
Definition: CANChannel.h:49
@ TYPE_FD
Full-duplex bit.
Definition: CANChannel.h:63
@ TYPE_SOF
Start of frame.
Definition: CANChannel.h:51
@ TYPE_R0
Reserved bit.
Definition: CANChannel.h:60
@ TYPE_ID
CAN ID.
Definition: CANChannel.h:54
@ TYPE_ACK
Acknowledgement bit.
Definition: CANChannel.h:81
@ TYPE_DATA
A data byte.
Definition: CANChannel.h:69
@ TYPE_RTR
Remote transmission request bit.
Definition: CANChannel.h:57
@ TYPE_CRC_BAD
CRC with an incorrect value.
Definition: CANChannel.h:75
@ TYPE_DLC
Data length code.
Definition: CANChannel.h:66
@ TYPE_EOF
End of frame.
Definition: CANChannel.h:87
@ TYPE_CRC_OK
CRC with a correct value.
Definition: CANChannel.h:72
@ TYPE_CRC_DELIM
CRC delimiter.
Definition: CANChannel.h:78
@ TYPE_ACK_DELIM
ACK delimiter.
Definition: CANChannel.h:84
CANSymbol()
Default constructor, performs no initialization.
Definition: CANChannel.h:91
uint32_t m_data
Data value (meaning depends on type)
Definition: CANChannel.h:110
A waveform containing CAN bus packets.
Definition: CANChannel.h:130
virtual std::string GetText(size_t) override
Returns the text representation of a given protocol sample.
Definition: CANChannel.cpp:115
virtual std::string GetColor(size_t) override
Returns the displayed color (in HTML #rrggbb or #rrggbbaa notation) of a given protocol sample.
Definition: CANChannel.cpp:61
A single channel on an oscilloscope.
Definition: OscilloscopeChannel.h:49
Generic representation of an oscilloscope, logic analyzer, or spectrum analyzer.
Definition: Oscilloscope.h:50
A waveform sampled at irregular intervals.
Definition: Waveform.h:460