ngscopeclient 0.1-dev+51fbda87c
UartTrigger.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 UartTrigger_h
37#define UartTrigger_h
38
39#include "SerialTrigger.h"
40
41#ifdef _WIN32
42//Our parity type definitions are also found in windows.h!
43//Undefine those so we can use ours instead.
44#undef PARITY_NONE
45#undef PARITY_ODD
46#undef PARITY_EVEN
47#undef PARITY_MARK
48#undef PARITY_SPACE
49#endif
50
56{
57public:
59 virtual ~UartTrigger();
60
63 {
66
69
72
75
78 };
79
86 { m_parity.SetIntVal(type); }
87
90 { return (ParityType) m_parity.GetIntVal(); }
91
94 {
97
100
103
106 };
107
114 { m_matchtype.SetIntVal(type); }
115
118 { return (MatchType) m_matchtype.GetIntVal(); }
119
122 {
125
128 };
129
136 { m_polarity.SetIntVal(type); }
137
140 { return (Polarity) m_polarity.GetIntVal(); }
141
143 int64_t GetBitRate()
144 { return m_baudrate.GetIntVal(); }
145
151 void SetBitRate(int64_t t)
152 { m_baudrate.SetIntVal(t); }
153
156 { return m_stoptype.GetFloatVal(); }
157
163 void SetStopBits(float n)
164 { m_stoptype.SetFloatVal(n); }
165
166 virtual bool ValidateChannel(size_t i, StreamDescriptor stream) override;
167
168 static std::string GetTriggerName();
169 TRIGGER_INITPROC(UartTrigger);
170
171protected:
172
175
178
181
184
187};
188
189#endif
Declaration of SerialTrigger.
A parameter to a filter.
Definition: FilterParameter.h:86
void SetIntVal(int64_t i)
Sets the parameter to an integer value.
Definition: FilterParameter.cpp:307
int64_t GetIntVal() const
Returns the value of the parameter interpreted as an integer.
Definition: FilterParameter.h:119
void SetFloatVal(float f)
Sets the parameter to a floating point value.
Definition: FilterParameter.cpp:323
float GetFloatVal() const
Returns the value of the parameter interpreted as a floating point number.
Definition: FilterParameter.h:125
Generic representation of an oscilloscope, logic analyzer, or spectrum analyzer.
Definition: Oscilloscope.h:50
Abstract base class for serial protocol triggers with pattern matching.
Definition: SerialTrigger.h:42
Descriptor for a single stream coming off a channel.
Definition: StreamDescriptor.h:46
Trigger when a UART sees a certain data pattern.
Definition: UartTrigger.h:56
FilterParameter & m_stoptype
Stop type.
Definition: UartTrigger.h:183
MatchType GetMatchType()
Returns the currently selected match mode.
Definition: UartTrigger.h:117
FilterParameter & m_parity
Parity type.
Definition: UartTrigger.h:177
ParityType GetParityType()
Get the currently selected parity mode.
Definition: UartTrigger.h:89
void SetParityType(ParityType type)
Set the parity for the trigger.
Definition: UartTrigger.h:85
float GetStopBits()
Get the length of the stop bit, in UI.
Definition: UartTrigger.h:155
int64_t GetBitRate()
Get the current baud rate.
Definition: UartTrigger.h:143
void SetPolarity(Polarity type)
Sets the UART polarity.
Definition: UartTrigger.h:135
FilterParameter & m_polarity
Polarity.
Definition: UartTrigger.h:186
Polarity
Polarity of the port.
Definition: UartTrigger.h:122
@ IDLE_LOW
Idle low, pull high to send a bit.
Definition: UartTrigger.h:127
@ IDLE_HIGH
Idle high, pull low to send a bit.
Definition: UartTrigger.h:124
FilterParameter & m_matchtype
Match type.
Definition: UartTrigger.h:180
static std::string GetTriggerName()
Returns the trigger name "UART".
Definition: UartTrigger.cpp:94
MatchType
What kind of pattern to match.
Definition: UartTrigger.h:94
@ TYPE_DATA
Match on a data byte.
Definition: UartTrigger.h:96
@ TYPE_START
Match on a start bit.
Definition: UartTrigger.h:102
@ TYPE_STOP
Match on a stop bit.
Definition: UartTrigger.h:105
@ TYPE_PARITY_ERR
Match on a parity error.
Definition: UartTrigger.h:99
void SetMatchType(MatchType type)
Sets the match mode for the trigger.
Definition: UartTrigger.h:113
Polarity GetPolarity()
Get the current trigger polarity.
Definition: UartTrigger.h:139
void SetBitRate(int64_t t)
Sets the baud rate.
Definition: UartTrigger.h:151
void SetStopBits(float n)
Set the length of the stop bit.
Definition: UartTrigger.h:163
UartTrigger(Oscilloscope *scope)
Creates a new UART trigger.
Definition: UartTrigger.cpp:51
ParityType
Type of parity to use.
Definition: UartTrigger.h:63
@ PARITY_EVEN
Even parity.
Definition: UartTrigger.h:71
@ PARITY_MARK
Mark parity.
Definition: UartTrigger.h:74
@ PARITY_SPACE
Space parity.
Definition: UartTrigger.h:77
@ PARITY_NONE
No parity.
Definition: UartTrigger.h:65
@ PARITY_ODD
Odd parity.
Definition: UartTrigger.h:68
FilterParameter & m_baudrate
Baud rate.
Definition: UartTrigger.h:174