Skip to content

Commit e5182ea

Browse files
authored
Merge pull request #23 from LeeLeahy2/enable-disable
Replace sempSetPrint* with sempEnable*Output and sempDisable*Output
2 parents 56dbf02 + 6c250c4 commit e5182ea

File tree

10 files changed

+33
-21
lines changed

10 files changed

+33
-21
lines changed

Examples/Base_Test/Base_Test.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void setup()
121121
Serial.printf("Parser Name: %s\r\n", sempGetTypeName(parse, parse->type));
122122

123123
// Obtain a raw data stream from somewhere
124-
sempSetPrintDebug(parse, &Serial);
124+
sempEnableDebugOutput(parse);
125125
Serial.printf("Raw data stream: %d bytes\r\n", RAW_DATA_BYTES);
126126

127127
// The raw data stream is passed to the parser one byte at a time

Examples/Mixed_Parser/Mixed_Parser.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ void setup()
178178
Serial.printf("Raw data stream: %d bytes\r\n", rawDataBytes);
179179

180180
// The raw data stream is passed to the parser one byte at a time
181-
sempSetPrintDebug(parse, &Serial);
181+
sempEnableDebugOutput(parse);
182182
for (dataIndex = 0; dataIndex < DATA_STREAM_ENTRIES; dataIndex++)
183183
{
184184
for (int offset = 0; offset < dataStream[dataIndex].length; offset++)

Examples/Multiple_Parsers/Multiple_Parsers.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ void setup()
193193
Serial.printf("Raw data stream: %d bytes\r\n", rawDataBytes);
194194

195195
// The raw data stream is passed to the parser one byte at a time
196-
sempSetPrintDebug(nmeaParser, &Serial);
197-
sempSetPrintDebug(ubloxParser, &Serial);
196+
sempEnableDebugOutput(nmeaParser);
197+
sempEnableDebugOutput(ubloxParser);
198198
for (dataIndex = 0; dataIndex < DATA_STREAM_ENTRIES; dataIndex++)
199199
{
200200
for (int offset = 0; offset < dataStream[dataIndex].length; offset++)

Examples/NMEA_Test/NMEA_Test.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void setup()
104104
Serial.printf("Raw data stream: %d bytes\r\n", RAW_DATA_BYTES);
105105

106106
// The raw data stream is passed to the parser one byte at a time
107-
sempSetPrintDebug(parse, &Serial);
107+
sempEnableDebugOutput(parse);
108108
for (dataOffset = 0; dataOffset < RAW_DATA_BYTES; dataOffset++)
109109
// Update the parser state based on the incoming byte
110110
sempParseNextByte(parse, rawDataStream[dataOffset]);

Examples/RTCM_Test/RTCM_Test.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void setup()
9999
Serial.printf("Raw data stream: %d bytes\r\n", RAW_DATA_BYTES);
100100

101101
// The raw data stream is passed to the parser one byte at a time
102-
sempSetPrintDebug(parse, &Serial);
102+
sempEnableDebugOutput(parse);
103103
for (dataOffset = 0; dataOffset < RAW_DATA_BYTES; dataOffset++)
104104
// Update the parser state based on the incoming byte
105105
sempParseNextByte(parse, rawDataStream[dataOffset]);

Examples/UBLOX_Test/UBLOX_Test.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ void setup()
141141
Serial.printf("Raw data stream: %d bytes\r\n", RAW_DATA_BYTES);
142142

143143
// The raw data stream is passed to the parser one byte at a time
144-
sempSetPrintDebug(parse, &Serial);
144+
sempEnableDebugOutput(parse);
145145
for (dataOffset = 0; dataOffset < RAW_DATA_BYTES; dataOffset++)
146146
// Update the parser state based on the incoming byte
147147
sempParseNextByte(parse, rawDataStream[dataOffset]);

Examples/Unicore_Test/Unicore_Test.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void setup()
147147
Serial.printf("Raw data stream: %d bytes\r\n", RAW_DATA_BYTES);
148148

149149
// The raw data stream is passed to the parser one byte at a time
150-
sempSetPrintDebug(parse, &Serial);
150+
sempEnableDebugOutput(parse);
151151
for (dataOffset = 0; dataOffset < RAW_DATA_BYTES; dataOffset++)
152152
// Update the parser state based on the incoming byte
153153
sempParseNextByte(parse, rawDataStream[dataOffset]);

Examples/User_Parser/User_Parser.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ void setup()
167167
Serial.printf("Raw data stream: %d bytes\r\n", RAW_DATA_BYTES);
168168

169169
// The raw data stream is passed to the parser one byte at a time
170-
sempSetPrintDebug(parse, &Serial);
170+
sempEnableDebugOutput(parse);
171171
for (dataOffset = 0; dataOffset < RAW_DATA_BYTES; dataOffset++)
172172
{
173173
uint8_t data;

src/SparkFun_Extensible_Message_Parser.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,18 +192,28 @@ const char * sempGetStateName(const SEMP_PARSE_STATE *parse)
192192
return "Unknown state";
193193
}
194194

195-
// Enable or disable debug output. Specify nullptr to disable output.
196-
void sempSetPrintDebug(SEMP_PARSE_STATE *parse, Print *printDebug)
195+
// Disable debug output
196+
void sempDisableDebugOutput(SEMP_PARSE_STATE *parse)
197197
{
198-
// Set the class to print debug output
199-
parse->printDebug = printDebug;
198+
parse->printDebug = nullptr;
200199
}
201200

202-
// Enable or disable error output. Specify nullptr to disable output.
203-
void sempSetPrintError(SEMP_PARSE_STATE *parse, Print *printError)
201+
// Enable debug output
202+
void sempEnableDebugOutput(SEMP_PARSE_STATE *parse, Print *print)
204203
{
205-
// Set the class to print error output
206-
parse->printError = printError;
204+
parse->printDebug = print;
205+
}
206+
207+
// Disable error output
208+
void sempDisableErrorOutput(SEMP_PARSE_STATE *parse)
209+
{
210+
parse->printError = nullptr;
211+
}
212+
213+
// Enable error output
214+
void sempEnableErrorOutput(SEMP_PARSE_STATE *parse, Print *print)
215+
{
216+
parse->printError = print;
207217
}
208218

209219
//----------------------------------------

src/SparkFun_Extensible_Message_Parser.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,13 @@ const char * sempGetStateName(const SEMP_PARSE_STATE *parse);
212212
// Translate the type value into an ASCII type name
213213
const char * sempGetTypeName(SEMP_PARSE_STATE *parse, uint16_t type);
214214

215-
// Enable or disable debug output. Specify nullptr to disable output.
216-
void sempSetPrintDebug(SEMP_PARSE_STATE *parse, Print *printDebug);
215+
// Enable or disable debug output
216+
void sempEnableDebugOutput(SEMP_PARSE_STATE *parse, Print *print = &Serial);
217+
void sempDisableDebugOutput(SEMP_PARSE_STATE *parse);
217218

218-
// Enable or disable error output. Specify nullptr to disable output.
219-
void sempSetPrintError(SEMP_PARSE_STATE *parse, Print *printError);
219+
// Enable or disable error output
220+
void sempEnableErrorOutput(SEMP_PARSE_STATE *parse, Print *print = &Serial);
221+
void sempDisableErrorOutput(SEMP_PARSE_STATE *parse);
220222

221223
// The parser routines within a parser module are typically placed in
222224
// reverse order within the module. This lets the routine declaration

0 commit comments

Comments
 (0)