@@ -33,7 +33,7 @@ bool sempPrintErrorMessages;
3333
3434// Allocate the parse structure
3535SEMP_PARSE_STATE * sempAllocateParseStructure (
36- Print *printError ,
36+ Print *printDebug ,
3737 uint16_t scratchPadBytes,
3838 size_t bufferLength
3939 )
@@ -43,14 +43,14 @@ SEMP_PARSE_STATE * sempAllocateParseStructure(
4343 int parseBytes;
4444
4545 // Print the scratchPad area size
46- sempPrintf (printError , " scratchPadBytes: 0x%04x (%d) bytes" ,
46+ sempPrintf (printDebug , " scratchPadBytes: 0x%04x (%d) bytes" ,
4747 scratchPadBytes, scratchPadBytes);
4848
4949 // Align the scratch patch area
5050 if (scratchPadBytes < SEMP_ALIGN (scratchPadBytes))
5151 {
5252 scratchPadBytes = SEMP_ALIGN (scratchPadBytes);
53- sempPrintf (printError ,
53+ sempPrintf (printDebug ,
5454 " scratchPadBytes: 0x%04x (%d) bytes after alignment" ,
5555 scratchPadBytes, scratchPadBytes);
5656 }
@@ -60,17 +60,17 @@ SEMP_PARSE_STATE * sempAllocateParseStructure(
6060 if (scratchPadBytes < length)
6161 {
6262 scratchPadBytes = length;
63- sempPrintf (printError ,
63+ sempPrintf (printDebug ,
6464 " scratchPadBytes: 0x%04x (%d) bytes after mimimum size adjustment" ,
6565 scratchPadBytes, scratchPadBytes);
6666 }
6767 parseBytes = SEMP_ALIGN (sizeof (SEMP_PARSE_STATE));
68- sempPrintf (printError , " parseBytes: 0x%04x (%d)" , parseBytes, parseBytes);
68+ sempPrintf (printDebug , " parseBytes: 0x%04x (%d)" , parseBytes, parseBytes);
6969
7070 // Verify the minimum bufferLength
7171 if (bufferLength < SEMP_MINIMUM_BUFFER_LENGTH)
7272 {
73- sempPrintf (printError ,
73+ sempPrintf (printDebug ,
7474 " SEMP: Increasing bufferLength from %d to %d bytes, minimum size adjustment" ,
7575 bufferLength, SEMP_MINIMUM_BUFFER_LENGTH);
7676 bufferLength = SEMP_MINIMUM_BUFFER_LENGTH;
@@ -79,7 +79,7 @@ SEMP_PARSE_STATE * sempAllocateParseStructure(
7979 // Allocate the parser
8080 length = parseBytes + scratchPadBytes;
8181 parse = (SEMP_PARSE_STATE *)malloc (length + bufferLength);
82- sempPrintf (printError , " parse: %p" , parse);
82+ sempPrintf (printDebug , " parse: %p" , parse);
8383
8484 // Initialize the parse structure
8585 if (parse)
@@ -89,13 +89,13 @@ SEMP_PARSE_STATE * sempAllocateParseStructure(
8989
9090 // Set the scratch pad area address
9191 parse->scratchPad = ((void *)parse) + parseBytes;
92- parse->printError = printError ;
93- sempPrintf (parse->printError , " parse->scratchPad: %p" , parse->scratchPad );
92+ parse->printDebug = printDebug ;
93+ sempPrintf (parse->printDebug , " parse->scratchPad: %p" , parse->scratchPad );
9494
9595 // Set the buffer address and length
9696 parse->bufferLength = bufferLength;
9797 parse->buffer = (uint8_t *)(parse->scratchPad + scratchPadBytes);
98- sempPrintf (parse->printError , " parse->buffer: %p" , parse->buffer );
98+ sempPrintf (parse->printDebug , " parse->buffer: %p" , parse->buffer );
9999 }
100100 return parse;
101101}
@@ -231,6 +231,7 @@ SEMP_PARSE_STATE *sempBeginParser(
231231 SEMP_EOM_CALLBACK eomCallback,
232232 const char *parserName,
233233 Print *printError,
234+ Print *printDebug,
234235 SEMP_BAD_CRC_CALLBACK badCrc
235236 )
236237{
@@ -281,14 +282,15 @@ SEMP_PARSE_STATE *sempBeginParser(
281282 }
282283
283284 // Validate the parser address is not nullptr
284- parse = sempAllocateParseStructure (printError , scratchPadBytes, bufferLength);
285+ parse = sempAllocateParseStructure (printDebug , scratchPadBytes, bufferLength);
285286 if (!parse)
286287 {
287288 sempPrintln (printError, " SEMP: Failed to allocate the parse structure" );
288289 break ;
289290 }
290291
291292 // Initialize the parser
293+ parse->printError = printError;
292294 parse->parsers = parserTable;
293295 parse->parserCount = parserCount;
294296 parse->parserNames = parserNameTable;
@@ -298,8 +300,7 @@ SEMP_PARSE_STATE *sempBeginParser(
298300 parse->badCrc = badCrc;
299301
300302 // Display the parser configuration
301- if (sempPrintErrorMessages)
302- sempPrintParserConfiguration (parse);
303+ sempPrintParserConfiguration (parse, parse->printDebug );
303304 } while (0 );
304305
305306 // Return the parse structure address
0 commit comments