mirror of https://github.com/wb2osz/direwolf.git
Slight fixes before switching to uint64_t and MSB processing.
This commit is contained in:
parent
742dfb486b
commit
98b8949f3b
26
src/eotd.c
26
src/eotd.c
|
@ -23,20 +23,8 @@
|
||||||
* File: eotd.c
|
* File: eotd.c
|
||||||
*
|
*
|
||||||
* Purpose: Functions for processing received EOTD transmissions and
|
* 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"
|
#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.
|
* 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);
|
time_t now = time(NULL);
|
||||||
*nmea = '\0';
|
*text = '\0';
|
||||||
strcat(nmea, ctime(&now));
|
strcat(text, ctime(&now));
|
||||||
for (int i = 0; i < eotd_len; i++) {
|
for (int i = 0; i < eotd_len; i++) {
|
||||||
char temp[32];
|
char temp[32];
|
||||||
snprintf(temp, sizeof(temp), " %02x", eotd[i]);
|
snprintf(temp, sizeof(temp), " %02x", eotd[i]);
|
||||||
strlcat(nmea, temp, nmea_size);
|
strlcat(text, temp, text_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -432,7 +432,6 @@ a good modem here and providing a result when it is received.
|
||||||
#define EOTD_PREAMBLE_AND_BARKER_CODE 0x55555712
|
#define EOTD_PREAMBLE_AND_BARKER_CODE 0x55555712
|
||||||
#define HOTD_PREAMBLE_AND_BARKER_CODE 0x558f1129
|
#define HOTD_PREAMBLE_AND_BARKER_CODE 0x558f1129
|
||||||
#define EOTD_MAX_LEN 8
|
#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)
|
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) {
|
else if (H->eotd_gathering) {
|
||||||
H->olen++;
|
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) {
|
if (H->olen == 8) {
|
||||||
H->olen = 0;
|
H->olen = 0;
|
||||||
char ch = H->eotd_acc & 0xff;
|
char ch = H->eotd_acc & 0xff;
|
||||||
|
|
|
@ -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) {
|
else if (save_audio_config_p->achan[chan].modem_type == MODEM_EOTD) {
|
||||||
char nmea[300];
|
char nmea[300];
|
||||||
eotd_to_nmea (fbuf, flen, nmea, sizeof(nmea));
|
eotd_to_text (fbuf, flen, nmea, sizeof(nmea));
|
||||||
char monfmt[276];
|
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);
|
pp = ax25_from_text (monfmt, 1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -19,3 +19,4 @@
|
||||||
|
|
||||||
#define USER_DEF_TYPE_AIS 'A' // data type A for AIS NMEA sentence
|
#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_EAS 'E' // data type E for EAS broadcasts
|
||||||
|
#define USER_DEF_TYPE_EOTD 'T' // data type T for 'T'rain broadcasts
|
||||||
|
|
Loading…
Reference in New Issue