17
17
18
18
#include <stdbool.h>
19
19
#include <stdint.h>
20
+ #include <stdio.h>
21
+ #include <ctype.h>
20
22
#include <string.h>
21
23
22
24
#include "platform.h"
@@ -171,8 +173,10 @@ static bool mspSerialProcessReceivedData(mspPort_t *mspPort, uint8_t c)
171
173
case MSP_CHECKSUM_V1 :
172
174
if (mspPort -> checksum1 == c ) {
173
175
mspPort -> c_state = MSP_COMMAND_RECEIVED ;
176
+ SD (fprintf (stderr , "[MSPV1] Command received\n" ));
174
177
} else {
175
178
mspPort -> c_state = MSP_IDLE ;
179
+ SD (fprintf (stderr , "[MSPV1] Checksum error!\n" ));
176
180
}
177
181
break ;
178
182
@@ -225,6 +229,7 @@ static bool mspSerialProcessReceivedData(mspPort_t *mspPort, uint8_t c)
225
229
// Check for potential buffer overflow
226
230
if (hdrv2 -> size > MSP_PORT_INBUF_SIZE ) {
227
231
mspPort -> c_state = MSP_IDLE ;
232
+ SD (fprintf (stderr , "[MSPV2] Potential buffer overflow!\n" ));
228
233
}
229
234
else {
230
235
mspPort -> dataSize = hdrv2 -> size ;
@@ -248,7 +253,9 @@ static bool mspSerialProcessReceivedData(mspPort_t *mspPort, uint8_t c)
248
253
case MSP_CHECKSUM_V2_NATIVE :
249
254
if (mspPort -> checksum2 == c ) {
250
255
mspPort -> c_state = MSP_COMMAND_RECEIVED ;
256
+ SD (fprintf (stderr , "[MSPV2] command received!\n" ));
251
257
} else {
258
+ SD (fprintf (stderr , "[MSPV2] Checksum error!\n" ));
252
259
mspPort -> c_state = MSP_IDLE ;
253
260
}
254
261
break ;
@@ -472,6 +479,7 @@ void mspSerialProcessOnePort(mspPort_t * const mspPort, mspEvaluateNonMspData_e
472
479
const uint8_t c = serialRead (mspPort -> port );
473
480
const bool consumed = mspSerialProcessReceivedData (mspPort , c );
474
481
482
+ //SD(fprintf(stderr, "[MSP]: received char: %02x (%c) state: %i\n", c, isprint(c) ? c : '.', mspPort->c_state));
475
483
if (!consumed && evaluateNonMspData == MSP_EVALUATE_NON_MSP_DATA ) {
476
484
mspEvaluateNonMspData (mspPort , c );
477
485
}
0 commit comments