From 98b8949f3b8149ef40e59b50f5d58fe5044a4432 Mon Sep 17 00:00:00 2001 From: "David E. Tiller" <3858971+dtiller@users.noreply.github.com> Date: Wed, 30 Mar 2022 10:43:02 -0400 Subject: [PATCH] Slight fixes before switching to uint64_t and MSB processing. --- src/eotd.c | 26 +++++++------------------- src/eotd.h | 2 +- src/hdlc_rec.c | 8 -------- src/multi_modem.c | 4 ++-- src/version.h | 1 + 5 files changed, 11 insertions(+), 30 deletions(-) diff --git a/src/eotd.c b/src/eotd.c index 60ce161..193edd9 100644 --- a/src/eotd.c +++ b/src/eotd.c @@ -23,20 +23,8 @@ * File: eotd.c * * Purpose: Functions for processing received EOTD transmissions and - * converting to NMEA sentence representation. + * converting to text format. * - * References: AIVDM/AIVDO protocol decoding by Eric S. Raymond - * https://gpsd.gitlab.io/gpsd/AIVDM.html - * - * Sample recording with about 100 messages. Test with "atest -B AIS xxx.wav" - * https://github.com/freerange/ais-on-sdr/wiki/example-data/long-beach-160-messages.wav - * - * Useful on-line decoder for AIS NMEA sentences. - * https://www.aggsoft.com/ais-decoder.htm - * - * Future? Add an interface to feed AIS data into aprs.fi. - * https://aprs.fi/page/ais_feeding - * *******************************************************************************/ #include "direwolf.h" @@ -53,21 +41,21 @@ /*------------------------------------------------------------------- * - * Convert EOTD binary block (from HDLC frame) to NMEA sentence. + * Convert EOTD binary block (from HDLC frame) to text. * * In: Pointer to EOTD binary block and number of bytes. - * Out: NMEA sentence. Provide size to avoid string overflow. + * Out: text. * *--------------------------------------------------------------------*/ -void eotd_to_nmea (unsigned char *eotd, int eotd_len, char *nmea, int nmea_size) +void eotd_to_text (unsigned char *eotd, int eotd_len, char *text, int text_size) { time_t now = time(NULL); - *nmea = '\0'; - strcat(nmea, ctime(&now)); + *text = '\0'; + strcat(text, ctime(&now)); for (int i = 0; i < eotd_len; i++) { char temp[32]; snprintf(temp, sizeof(temp), " %02x", eotd[i]); - strlcat(nmea, temp, nmea_size); + strlcat(text, temp, text_size); } } diff --git a/src/eotd.h b/src/eotd.h index 64dba3a..3a55158 100644 --- a/src/eotd.h +++ b/src/eotd.h @@ -1 +1 @@ -void eotd_to_nmea (unsigned char *ais, int ais_len, char *nema, int nema_size); +void eotd_to_text (unsigned char *ais, int ais_len, char *text, int text_size); diff --git a/src/hdlc_rec.c b/src/hdlc_rec.c index 93cb524..5a003ab 100644 --- a/src/hdlc_rec.c +++ b/src/hdlc_rec.c @@ -432,7 +432,6 @@ a good modem here and providing a result when it is received. #define EOTD_PREAMBLE_AND_BARKER_CODE 0x55555712 #define HOTD_PREAMBLE_AND_BARKER_CODE 0x558f1129 #define EOTD_MAX_LEN 8 -#undef DUMMY_BIT_HACK static void eotd_rec_bit (int chan, int subchan, int slice, int raw, int future_use) { @@ -468,13 +467,6 @@ dw_printf("chan=%d subchan=%d slice=%d raw=%d\n", chan, subchan, slice, raw); else if (H->eotd_gathering) { H->olen++; -#ifdef DUMMY_BIT_HACK - /* Hack to skip 'dummy' 64th bit */ - if (H->olen == 7 && H->frame_len == 7) { - H->eotd_acc <<= 1; - H->olen++; - } -#endif if (H->olen == 8) { H->olen = 0; char ch = H->eotd_acc & 0xff; diff --git a/src/multi_modem.c b/src/multi_modem.c index 86a59a7..432da29 100644 --- a/src/multi_modem.c +++ b/src/multi_modem.c @@ -345,9 +345,9 @@ void multi_modem_process_rec_frame (int chan, int subchan, int slice, unsigned c } else if (save_audio_config_p->achan[chan].modem_type == MODEM_EOTD) { char nmea[300]; - eotd_to_nmea (fbuf, flen, nmea, sizeof(nmea)); + eotd_to_text (fbuf, flen, nmea, sizeof(nmea)); char monfmt[276]; - snprintf (monfmt, sizeof(monfmt), "EOTD>%s%1d%1d:{%c%c%s", APP_TOCALL, MAJOR_VERSION, MINOR_VERSION, USER_DEF_USER_ID, USER_DEF_TYPE_AIS, nmea); + snprintf (monfmt, sizeof(monfmt), "EOTD>%s%1d%1d:{%c%c%s", APP_TOCALL, MAJOR_VERSION, MINOR_VERSION, USER_DEF_USER_ID, USER_DEF_TYPE_EOTD, nmea); pp = ax25_from_text (monfmt, 1); } else { diff --git a/src/version.h b/src/version.h index a09490c..feaa6c9 100644 --- a/src/version.h +++ b/src/version.h @@ -19,3 +19,4 @@ #define USER_DEF_TYPE_AIS 'A' // data type A for AIS NMEA sentence #define USER_DEF_TYPE_EAS 'E' // data type E for EAS broadcasts +#define USER_DEF_TYPE_EOTD 'T' // data type T for 'T'rain broadcasts