1
- //
2
- // This file is part of Dire Wolf, an amateur radio packet TNC.
1
+ ////
2
+ //// This file is part of Dire Wolf, an amateur radio packet TNC.
3
3
//
4
4
// Copyright (C) 2011, 2012, 2013, 2014, 2015 John Langner, WB2OSZ
5
5
//
@@ -111,6 +111,10 @@ struct hdlc_state_s {
111
111
int eas_plus_found ; /* "+" seen, indicating end of geographical area list. */
112
112
113
113
int eas_fields_after_plus ; /* Number of "-" characters after the "+". */
114
+
115
+ uint32_t eotd_acc ; /* Accumulate last recent 32 bits for EOTD. */
116
+
117
+ int eotd_gathering ; /* Decoding in progress - valid frame. */
114
118
};
115
119
116
120
static struct hdlc_state_s hdlc_state [MAX_CHANS ][MAX_SUBCHANS ][MAX_SLICERS ];
@@ -423,6 +427,8 @@ a good modem here and providing a result when it is received.
423
427
*
424
428
***********************************************************************************/
425
429
430
+ #define PREAMBLE_AND_BARKER_CODE 0x55555712
431
+ #define EOTD_MAX_LEN 8
426
432
427
433
static void eotd_rec_bit (int chan , int subchan , int slice , int raw , int future_use )
428
434
{
@@ -432,7 +438,59 @@ static void eotd_rec_bit (int chan, int subchan, int slice, int raw, int future_
432
438
* Different state information for each channel / subchannel / slice.
433
439
*/
434
440
H = & hdlc_state [chan ][subchan ][slice ];
441
+
435
442
fprintf (stderr , "chan=%d subchan=%d slice=%d raw=%d\n" , chan , subchan , slice , raw );
443
+ //dw_printf ("slice %d = %d\n", slice, raw);
444
+
445
+ // Accumulate most recent 32 bits in MSB-first order.
446
+
447
+ H -> eotd_acc <<= 1 ;
448
+ H -> eotd_acc |= raw ;
449
+
450
+ int done = 0 ;
451
+
452
+ if (!H -> eotd_gathering && H -> eotd_acc == PREAMBLE_AND_BARKER_CODE ) {
453
+ dw_printf ("Barker Code Found\n" );
454
+ H -> olen = 0 ;
455
+ H -> eotd_gathering = 1 ;
456
+ H -> frame_len = 0 ;
457
+ }
458
+ else if (H -> eotd_gathering ) {
459
+ H -> olen ++ ;
460
+
461
+ /* Hack to skip 'dummy' 64th bit */
462
+ if (H -> olen == 7 && H -> frame_len == 7 ) {
463
+ fprintf (stderr , "Special case!\n" );
464
+ H -> eotd_acc <<= 1 ;
465
+ H -> olen ++ ;
466
+ }
467
+
468
+ if (H -> olen == 8 ) {
469
+ H -> olen = 0 ;
470
+ char ch = H -> eotd_acc & 0xff ;
471
+ H -> frame_buf [H -> frame_len ++ ] = ch ;
472
+ H -> frame_buf [H -> frame_len ] = '\0' ;
473
+ //dw_printf ("frame_buf = %s\n", H->frame_buf);
474
+
475
+ if (H -> frame_len == EOTD_MAX_LEN ) { // FIXME: look for other places with max length
476
+ done = 1 ;
477
+ for (int ii = 0 ; ii < EOTD_MAX_LEN ; ii ++ ) {fprintf (stderr , "%02x " , H -> frame_buf [ii ]); } fprintf (stderr , "\n" );
478
+ }
479
+ }
480
+ }
481
+
482
+ if (done ) {
483
+ #ifdef DEBUG_E
484
+ dw_printf ("frame_buf %d = %s\n" , slice , H -> frame_buf );
485
+ #endif
486
+ alevel_t alevel = demod_get_audio_level (chan , subchan );
487
+ multi_modem_process_rec_frame (chan , subchan , slice , H -> frame_buf , H -> frame_len , alevel , 0 , 0 );
488
+
489
+ H -> eotd_acc = 0 ;
490
+ H -> eotd_gathering = 0 ;
491
+ H -> olen = 0 ;
492
+ H -> frame_len = 0 ;
493
+ }
436
494
return ;
437
495
} // end eotd_rec_bit
438
496
0 commit comments