@@ -243,6 +243,8 @@ bool _TF_FN TF_AddIdListener(TinyFrame *tf, TF_Msg *msg, TF_Listener cb, TF_TICK
243
243
return true;
244
244
}
245
245
}
246
+
247
+ TF_Error ("Failed to add ID listener" );
246
248
return false;
247
249
}
248
250
@@ -263,6 +265,8 @@ bool _TF_FN TF_AddTypeListener(TinyFrame *tf, TF_TYPE frame_type, TF_Listener cb
263
265
return true;
264
266
}
265
267
}
268
+
269
+ TF_Error ("Failed to add type listener" );
266
270
return false;
267
271
}
268
272
@@ -282,6 +286,8 @@ bool _TF_FN TF_AddGenericListener(TinyFrame *tf, TF_Listener cb)
282
286
return true;
283
287
}
284
288
}
289
+
290
+ TF_Error ("Failed to add generic listener" );
285
291
return false;
286
292
}
287
293
@@ -298,6 +304,8 @@ bool _TF_FN TF_RemoveIdListener(TinyFrame *tf, TF_ID frame_id)
298
304
return true;
299
305
}
300
306
}
307
+
308
+ TF_Error ("ID listener %d to remove not found" , (int )frame_id );
301
309
return false;
302
310
}
303
311
@@ -314,6 +322,8 @@ bool _TF_FN TF_RemoveTypeListener(TinyFrame *tf, TF_TYPE type)
314
322
return true;
315
323
}
316
324
}
325
+
326
+ TF_Error ("Type listener %d to remove not found" , (int )type );
317
327
return false;
318
328
}
319
329
@@ -330,6 +340,8 @@ bool _TF_FN TF_RemoveGenericListener(TinyFrame *tf, TF_Listener cb)
330
340
return true;
331
341
}
332
342
}
343
+
344
+ TF_Error ("Generic listener to remove not found" );
333
345
return false;
334
346
}
335
347
@@ -428,6 +440,8 @@ static void _TF_FN TF_HandleReceivedMessage(TinyFrame *tf)
428
440
}
429
441
}
430
442
}
443
+
444
+ TF_Error ("Unhandled message, type %d" , (int )msg .type );
431
445
}
432
446
433
447
//endregion Listeners
@@ -468,7 +482,10 @@ void _TF_FN TF_AcceptChar(TinyFrame *tf, unsigned char c)
468
482
{
469
483
// Parser timeout - clear
470
484
if (tf -> parser_timeout_ticks >= TF_PARSER_TIMEOUT_TICKS ) {
471
- TF_ResetParser (tf );
485
+ if (tf -> state != TFState_SOF ) {
486
+ TF_ResetParser (tf );
487
+ TF_Error ("Parser timeout" );
488
+ }
472
489
}
473
490
tf -> parser_timeout_ticks = 0 ;
474
491
@@ -481,7 +498,7 @@ void _TF_FN TF_AcceptChar(TinyFrame *tf, unsigned char c)
481
498
482
499
#if !TF_USE_SOF_BYTE
483
500
if (tf -> state == TFState_SOF ) {
484
- pars_begin_frame ();
501
+ pars_begin_frame (tf );
485
502
}
486
503
#endif
487
504
@@ -532,6 +549,7 @@ void _TF_FN TF_AcceptChar(TinyFrame *tf, unsigned char c)
532
549
CKSUM_FINALIZE (tf -> cksum );
533
550
534
551
if (tf -> cksum != tf -> ref_cksum ) {
552
+ TF_Error ("Rx head cksum mismatch" );
535
553
TF_ResetParser (tf );
536
554
break ;
537
555
}
@@ -550,6 +568,7 @@ void _TF_FN TF_AcceptChar(TinyFrame *tf, unsigned char c)
550
568
CKSUM_RESET (tf -> cksum ); // Start collecting the payload
551
569
552
570
if (tf -> len > TF_MAX_PAYLOAD_RX ) {
571
+ TF_Error ("Rx payload too long: %d" , (int )tf -> len );
553
572
// ERROR - frame too long. Consume, but do not store.
554
573
tf -> discard_data = true;
555
574
}
@@ -582,8 +601,12 @@ void _TF_FN TF_AcceptChar(TinyFrame *tf, unsigned char c)
582
601
COLLECT_NUMBER (tf -> ref_cksum , TF_CKSUM ) {
583
602
// Check the header checksum against the computed value
584
603
CKSUM_FINALIZE (tf -> cksum );
585
- if (!tf -> discard_data && tf -> cksum == tf -> ref_cksum ) {
586
- TF_HandleReceivedMessage (tf );
604
+ if (!tf -> discard_data ) {
605
+ if (tf -> cksum == tf -> ref_cksum ) {
606
+ TF_HandleReceivedMessage (tf );
607
+ } else {
608
+ TF_Error ("Body cksum mismatch" );
609
+ }
587
610
}
588
611
589
612
TF_ResetParser (tf );
@@ -847,6 +870,8 @@ bool _TF_FN TF_RenewIdListener(TinyFrame *tf, TF_ID id)
847
870
return true;
848
871
}
849
872
}
873
+
874
+ TF_Error ("Renew listener: not found (id %d)" , (int )id );
850
875
return false;
851
876
}
852
877
@@ -867,6 +892,7 @@ void _TF_FN TF_Tick(TinyFrame *tf)
867
892
if (!lst -> fn || lst -> timeout == 0 ) continue ;
868
893
// count down...
869
894
if (-- lst -> timeout == 0 ) {
895
+ TF_Error ("ID listener %d has expired" , (int )lst -> id );
870
896
// Listener has expired
871
897
cleanup_id_listener (tf , i , lst );
872
898
}
0 commit comments