@@ -114,7 +114,7 @@ struct hdlc_state_s {
114
114
115
115
int eas_fields_after_plus ; /* Number of "-" characters after the "+". */
116
116
117
- uint32_t eotd_acc ; /* Accumulate last recent 32 bits for EOTD. */
117
+ uint64_t eotd_acc ; /* Accumulate last recent 32 bits for EOTD. */
118
118
119
119
int eotd_gathering ; /* Decoding in progress - valid frame. */
120
120
};
@@ -429,9 +429,13 @@ a good modem here and providing a result when it is received.
429
429
*
430
430
***********************************************************************************/
431
431
432
- #define EOTD_PREAMBLE_AND_BARKER_CODE 0x55555712
433
- #define HOTD_PREAMBLE_AND_BARKER_CODE 0x558f1129
434
- #define EOTD_MAX_LEN 8
432
+ #define EOTD_MAX_BYTES 8
433
+
434
+ #define EOTD_PREAMBLE_AND_BARKER_CODE 0x48eaaaaa00000000ULL
435
+ #define EOTD_PREAMBLE_MASK 0xffffffff00000000ULL
436
+
437
+ #define HOTD_PREAMBLE_AND_BARKER_CODE 0x9488f1aa00000000ULL
438
+ #define HOTD_PREAMBLE_MASK 0xffffffff00000000ULL
435
439
436
440
static void eotd_rec_bit (int chan , int subchan , int slice , int raw , int future_use )
437
441
{
@@ -447,40 +451,40 @@ dw_printf("chan=%d subchan=%d slice=%d raw=%d\n", chan, subchan, slice, raw);
447
451
#endif
448
452
//dw_printf ("slice %d = %d\n", slice, raw);
449
453
450
- // Accumulate most recent 32 bits in MSB -first order.
454
+ // Accumulate most recent 32 bits in LSB -first order.
451
455
452
- H -> eotd_acc <<= 1 ;
453
- H -> eotd_acc |= raw ;
456
+ H -> eotd_acc >>= 1 ;
457
+ if (raw ) {
458
+ H -> eotd_acc |= 0x8000000000000000UL ;
459
+ }
454
460
455
461
int done = 0 ;
456
462
457
463
if (!H -> eotd_gathering &&
458
- (H -> eotd_acc == EOTD_PREAMBLE_AND_BARKER_CODE ||
459
- H -> eotd_acc == HOTD_PREAMBLE_AND_BARKER_CODE )) {
464
+ (( H -> eotd_acc & EOTD_PREAMBLE_MASK ) == EOTD_PREAMBLE_AND_BARKER_CODE ||
465
+ ( H -> eotd_acc & HOTD_PREAMBLE_MASK ) == HOTD_PREAMBLE_AND_BARKER_CODE )) {
460
466
#ifdef EOTD_DEBUG
461
- dw_printf ("Barker Code Found %x \n" , H -> eotd_acc );
467
+ dw_printf ("Barker Code Found %llx \n" , H -> eotd_acc );
462
468
#endif
463
469
H -> olen = 0 ;
464
470
H -> eotd_gathering = 1 ;
465
471
H -> frame_len = 0 ;
472
+ H -> eotd_acc = 0ULL ;
466
473
}
467
474
else if (H -> eotd_gathering ) {
468
475
H -> olen ++ ;
469
476
470
- if (H -> olen == 8 ) {
471
- H -> olen = 0 ;
472
- char ch = H -> eotd_acc & 0xff ;
473
- H -> frame_buf [H -> frame_len ++ ] = ch ;
474
- H -> frame_buf [H -> frame_len ] = '\0' ;
475
- //dw_printf ("frame_buf = %s\n", H->frame_buf);
476
-
477
- if (H -> frame_len == EOTD_MAX_LEN ) { // FIXME: look for other places with max length
477
+ if (H -> olen == EOTD_MAX_BYTES * 8 ) {
478
+ H -> frame_len = EOTD_MAX_BYTES ;
479
+ for (int i = EOTD_MAX_BYTES - 1 ; i >=0 ; i -- ) {
480
+ H -> frame_buf [i ] = H -> eotd_acc & 0xff ;
481
+ H -> eotd_acc >>= 8 ;
482
+ }
478
483
done = 1 ;
479
484
#ifdef EOTD_DEBUG
480
- for (int ii = 0 ; ii < EOTD_MAX_LEN ; ii ++ ) {dw_printf ("%02x " , H -> frame_buf [ii ]); } dw_printf ("\n" );
485
+ for (int ii = 0 ; ii < EOTD_MAX_BYTES ; ii ++ ) {dw_printf ("%02x " , H -> frame_buf [ii ]); } dw_printf ("\n" );
481
486
#endif
482
487
}
483
- }
484
488
}
485
489
486
490
if (done ) {
0 commit comments