Skip to content

Commit 7d58e40

Browse files
committed
New branch for 64 bit processing. Probably not needed.
1 parent 98b8949 commit 7d58e40

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

Diff for: src/hdlc_rec.c

+24-20
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ struct hdlc_state_s {
114114

115115
int eas_fields_after_plus; /* Number of "-" characters after the "+". */
116116

117-
uint32_t eotd_acc; /* Accumulate last recent 32 bits for EOTD. */
117+
uint64_t eotd_acc; /* Accumulate last recent 32 bits for EOTD. */
118118

119119
int eotd_gathering; /* Decoding in progress - valid frame. */
120120
};
@@ -429,9 +429,13 @@ a good modem here and providing a result when it is received.
429429
*
430430
***********************************************************************************/
431431

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
435439

436440
static void eotd_rec_bit (int chan, int subchan, int slice, int raw, int future_use)
437441
{
@@ -447,40 +451,40 @@ dw_printf("chan=%d subchan=%d slice=%d raw=%d\n", chan, subchan, slice, raw);
447451
#endif
448452
//dw_printf ("slice %d = %d\n", slice, raw);
449453

450-
// Accumulate most recent 32 bits in MSB-first order.
454+
// Accumulate most recent 32 bits in LSB-first order.
451455

452-
H->eotd_acc <<= 1;
453-
H->eotd_acc |= raw;
456+
H->eotd_acc >>= 1;
457+
if (raw) {
458+
H->eotd_acc |= 0x8000000000000000UL;
459+
}
454460

455461
int done = 0;
456462

457463
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)) {
460466
#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);
462468
#endif
463469
H->olen = 0;
464470
H->eotd_gathering = 1;
465471
H->frame_len = 0;
472+
H->eotd_acc = 0ULL;
466473
}
467474
else if (H->eotd_gathering) {
468475
H->olen++;
469476

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+
}
478483
done = 1;
479484
#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");
481486
#endif
482487
}
483-
}
484488
}
485489

486490
if (done) {

0 commit comments

Comments
 (0)