From e0335475b301c9929a9b5a10c0ce7afded517e83 Mon Sep 17 00:00:00 2001 From: Tom VA7TA Date: Tue, 6 Feb 2018 12:03:21 -0800 Subject: [PATCH 1/6] va7ta updates --- LibAPRS/AFSK.cpp | 68 ++++++++++++++++++++++++--------------------- LibAPRS/AFSK.h | 3 ++ LibAPRS/AX25.cpp | 5 +++- LibAPRS/LibAPRS.cpp | 7 ++++- LibAPRS/LibAPRS.h | 2 ++ 5 files changed, 52 insertions(+), 33 deletions(-) diff --git a/LibAPRS/AFSK.cpp b/LibAPRS/AFSK.cpp index 47a7e7c..a7daa60 100644 --- a/LibAPRS/AFSK.cpp +++ b/LibAPRS/AFSK.cpp @@ -9,6 +9,7 @@ extern bool LibAPRS_open_squelch; bool hw_afsk_dac_isr = false; bool hw_5v_ref = false; +bool fullBfrErr=false;//va7ta update Afsk *AFSK_modem; @@ -25,36 +26,39 @@ void AFSK_hw_refDetect(void) { } } -void AFSK_hw_init(void) { - // Set up ADC - - AFSK_hw_refDetect(); - - TCCR1A = 0; - TCCR1B = _BV(CS10) | _BV(WGM13) | _BV(WGM12); - ICR1 = (((CPU_FREQ+FREQUENCY_CORRECTION)) / 9600) - 1; - - if (hw_5v_ref) { - ADMUX = _BV(REFS0) | 0; - } else { - ADMUX = 0; - } - - ADC_DDR &= ~_BV(0); - ADC_PORT &= ~_BV(0); - DIDR0 |= _BV(0); - ADCSRB = _BV(ADTS2) | - _BV(ADTS1) | - _BV(ADTS0); - ADCSRA = _BV(ADEN) | - _BV(ADSC) | - _BV(ADATE)| - _BV(ADIE) | - _BV(ADPS2); - - AFSK_DAC_INIT(); - LED_TX_INIT(); - LED_RX_INIT(); +namespace AFSKADCINIT{//va7ta update + + void AFSK_hw_init(void) { + // Set up ADC + + AFSK_hw_refDetect(); + + TCCR1A = 0; + TCCR1B = _BV(CS10) | _BV(WGM13) | _BV(WGM12); + ICR1 = (((CPU_FREQ+FREQUENCY_CORRECTION)) / 9600) - 1; + + if (hw_5v_ref) { + ADMUX = _BV(REFS0) | 0; + } else { + ADMUX = 0; + } + + ADC_DDR &= ~_BV(0); + ADC_PORT &= ~_BV(0); + DIDR0 |= _BV(0); + ADCSRB = _BV(ADTS2) | + _BV(ADTS1) | + _BV(ADTS0); + ADCSRA = _BV(ADEN) | + _BV(ADSC) | + _BV(ADATE)| + _BV(ADIE) | + _BV(ADPS2); + + AFSK_DAC_INIT(); + LED_TX_INIT(); + LED_RX_INIT(); + } } void AFSK_init(Afsk *afsk) { @@ -73,7 +77,7 @@ void AFSK_init(Afsk *afsk) { fifo_push(&afsk->delayFifo, 0); } - AFSK_hw_init(); + AFSKADCINIT::AFSK_hw_init();//va7ta update } @@ -211,6 +215,8 @@ static bool hdlcParse(Hdlc *hdlc, bool bit, FIFOBuffer *fifo) { ret = false; hdlc->receiving = false; LED_RX_OFF(); + fullBfrErr=true;//va7ta update + } // Everytime we receive a HDLC_FLAG, we reset the diff --git a/LibAPRS/AFSK.h b/LibAPRS/AFSK.h index fe2ebad..75f882b 100644 --- a/LibAPRS/AFSK.h +++ b/LibAPRS/AFSK.h @@ -10,6 +10,9 @@ #include "HDLC.h" #define SIN_LEN 512 +namespace AFSKADCINIT {//va7ta update + void AFSK_hw_init(void);//va7ta update +};//va7ta update static const uint8_t sin_table[] PROGMEM = { 128, 129, 131, 132, 134, 135, 137, 138, 140, 142, 143, 145, 146, 148, 149, 151, diff --git a/LibAPRS/AX25.cpp b/LibAPRS/AX25.cpp index afe2b2d..fe3f831 100644 --- a/LibAPRS/AX25.cpp +++ b/LibAPRS/AX25.cpp @@ -15,6 +15,7 @@ extern int LibAPRS_vref; extern bool LibAPRS_open_squelch; +bool CRC_Err=false; // CRC error flag - va7ta update void ax25_init(AX25Ctx *ctx, ax25_callback_t hook) { memset(ctx, 0, sizeof(*ctx)); @@ -70,7 +71,9 @@ void ax25_poll(AX25Ctx *ctx) { LED_RX_ON(); } ax25_decode(ctx); - } + }else{//va7ta update + CRC_Err=true;//va7ta update + }//va7ta update } ctx->sync = true; ctx->crc_in = CRC_CCIT_INIT_VAL; diff --git a/LibAPRS/LibAPRS.cpp b/LibAPRS/LibAPRS.cpp index f271933..4c77b67 100644 --- a/LibAPRS/LibAPRS.cpp +++ b/LibAPRS/LibAPRS.cpp @@ -12,6 +12,7 @@ bool LibAPRS_open_squelch = false; unsigned long custom_preamble = 350UL; unsigned long custom_tail = 50UL; +char dataID_Flag; // '!' no messaging; '=' messaging va7ta update AX25Call src; AX25Call dst; @@ -121,6 +122,10 @@ void APRS_setTail(unsigned long tail) { custom_tail = tail; } +void APRS_setDataTypeID(uint8_t flag) {//va7ta update + dataID_Flag = flag;//va7ta update +}//va7ta update + void APRS_useAlternateSymbolTable(bool use) { if (use) { symbolTable = '\\'; @@ -228,7 +233,7 @@ void APRS_sendLoc(void *_buffer, size_t length) { } uint8_t *packet = (uint8_t*)malloc(payloadLength); uint8_t *ptr = packet; - packet[0] = '='; + packet[0] = dataID_Flag; //'!'or'='//va7ta update packet[9] = symbolTable; packet[19] = symbol; ptr++; diff --git a/LibAPRS/LibAPRS.h b/LibAPRS/LibAPRS.h index 78e725a..4e1849d 100644 --- a/LibAPRS/LibAPRS.h +++ b/LibAPRS/LibAPRS.h @@ -20,6 +20,8 @@ void APRS_setPath2(char *call, int ssid); void APRS_setPreamble(unsigned long pre); void APRS_setTail(unsigned long tail); void APRS_useAlternateSymbolTable(bool use); +void APRS_setDataTypeID(char flag);//va7ta update + void APRS_setSymbol(char sym); void APRS_setLat(char *lat); From 8eeeb56a3d57d349ae0e95ec90dc3aeb6e8c51ea Mon Sep 17 00:00:00 2001 From: Tom VA7TA Date: Tue, 6 Feb 2018 13:13:27 -0800 Subject: [PATCH 2/6] va7ta LibAPRS va7ta compile tested OK --- LibAPRS/LibAPRS.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LibAPRS/LibAPRS.h b/LibAPRS/LibAPRS.h index 4e1849d..d0a1e9c 100644 --- a/LibAPRS/LibAPRS.h +++ b/LibAPRS/LibAPRS.h @@ -20,7 +20,7 @@ void APRS_setPath2(char *call, int ssid); void APRS_setPreamble(unsigned long pre); void APRS_setTail(unsigned long tail); void APRS_useAlternateSymbolTable(bool use); -void APRS_setDataTypeID(char flag);//va7ta update +void APRS_setDataTypeID(uint8_t flag);//va7ta update void APRS_setSymbol(char sym); From e37fceee98612fbb8c75abaa639cefb80ca5eeca Mon Sep 17 00:00:00 2001 From: Tom VA7TA Date: Tue, 6 Feb 2018 17:45:58 -0800 Subject: [PATCH 3/6] va7ta update --- LibAPRS/examples/Basic_usage/Basic_usage.ino | 29 +++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/LibAPRS/examples/Basic_usage/Basic_usage.ino b/LibAPRS/examples/Basic_usage/Basic_usage.ino index 73b7452..8e598a4 100644 --- a/LibAPRS/examples/Basic_usage/Basic_usage.ino +++ b/LibAPRS/examples/Basic_usage/Basic_usage.ino @@ -11,6 +11,10 @@ // OR //#define ADC_REFERENCE REF_5V +// '!'(33) for no messaging; '='(61)if APRS messaging available +#define APRS_DATA_TYPE_FLAG '=' // va7ta update + +// Note some squelch delays are too short for catching APRS packets. // You can also define whether your modem will be // running with an open squelch radio: #define OPEN_SQUELCH false @@ -31,6 +35,9 @@ boolean gotPacket = false; AX25Msg incomingPacket; uint8_t *packetData; + +using namespace AFSKADCINIT;//provides access for re-initializing ADC for AFSK decoding + void aprs_msg_callback(struct AX25Msg *msg) { // If we already have a packet waiting to be // processed, we must drop the new one. @@ -109,6 +116,8 @@ void locationUpdateExample() { APRS_setHeight(4); APRS_setGain(7); APRS_setDirectivity(0); + APRS_setDataTypeID(APRS_DATA_TYPE_FLAG);//flags if APRS messaging is available (va7ta update) + // We'll define a comment string char *comment = "LibAPRS location update"; @@ -164,6 +173,14 @@ void processPacket() { boolean whichExample = false; void loop() { + /* va7ta update: + * insert this statement immediately after using the ADC for + * other possible functions such as measuring a voltage from + * a sensor. This is needed to re-configure the ADC for AFSK + * decoding. + */ + // AFSKADCINIT::AFSK_hw_init();// re-initialize AFSK operation + delay(1000); if (whichExample) { locationUpdateExample(); @@ -174,4 +191,14 @@ void loop() { delay(500); processPacket(); -} \ No newline at end of file + /* // monitor packet data errors - Note: cannot be used with open squelch + * if(CRC_Err==true){ + Serial.println(F("CRC_Error")); + CRC_Err=false; + }*/ + // Flag any buffer overrun errors + if(fullBfrErr==true){ + Serial.println(F("FullBufferError")); + fullBfrErr=false; + } +} From 8a072336356c6c92cf087b3f4501f530e7864904 Mon Sep 17 00:00:00 2001 From: Tom VA7TA Date: Tue, 6 Feb 2018 18:11:12 -0800 Subject: [PATCH 4/6] va7ta compile tested OK --- LibAPRS/examples/Basic_usage/Basic_usage.ino | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/LibAPRS/examples/Basic_usage/Basic_usage.ino b/LibAPRS/examples/Basic_usage/Basic_usage.ino index 8e598a4..a70180a 100644 --- a/LibAPRS/examples/Basic_usage/Basic_usage.ino +++ b/LibAPRS/examples/Basic_usage/Basic_usage.ino @@ -33,6 +33,8 @@ // from your main loop, like this: boolean gotPacket = false; +extern boolean fullBfrErr;//used for flagging data errors +extern boolean CRC_Err;//used for flagging data errors AX25Msg incomingPacket; uint8_t *packetData; @@ -191,11 +193,11 @@ void loop() { delay(500); processPacket(); - /* // monitor packet data errors - Note: cannot be used with open squelch - * if(CRC_Err==true){ + // monitor packet data errors - Note: cannot be used with open squelch + if(CRC_Err==true){ Serial.println(F("CRC_Error")); CRC_Err=false; - }*/ + } // Flag any buffer overrun errors if(fullBfrErr==true){ Serial.println(F("FullBufferError")); From 86d93fb860d964cd3bc99eb0f5f891bdb1b4600b Mon Sep 17 00:00:00 2001 From: Tom VA7TA Date: Tue, 6 Feb 2018 21:25:36 -0800 Subject: [PATCH 5/6] removed code addition flag comments --- LibAPRS/AFSK.cpp | 8 ++++---- LibAPRS/AFSK.h | 6 +++--- LibAPRS/AX25.cpp | 8 ++++---- LibAPRS/LibAPRS.h | 2 +- LibAPRS/examples/Basic_usage/Basic_usage.ino | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/LibAPRS/AFSK.cpp b/LibAPRS/AFSK.cpp index a7daa60..5b53727 100644 --- a/LibAPRS/AFSK.cpp +++ b/LibAPRS/AFSK.cpp @@ -9,7 +9,7 @@ extern bool LibAPRS_open_squelch; bool hw_afsk_dac_isr = false; bool hw_5v_ref = false; -bool fullBfrErr=false;//va7ta update +bool fullBfrErr=false; Afsk *AFSK_modem; @@ -26,7 +26,7 @@ void AFSK_hw_refDetect(void) { } } -namespace AFSKADCINIT{//va7ta update +namespace AFSKADCINIT{ void AFSK_hw_init(void) { // Set up ADC @@ -77,7 +77,7 @@ void AFSK_init(Afsk *afsk) { fifo_push(&afsk->delayFifo, 0); } - AFSKADCINIT::AFSK_hw_init();//va7ta update + AFSKADCINIT::AFSK_hw_init(); } @@ -215,7 +215,7 @@ static bool hdlcParse(Hdlc *hdlc, bool bit, FIFOBuffer *fifo) { ret = false; hdlc->receiving = false; LED_RX_OFF(); - fullBfrErr=true;//va7ta update + fullBfrErr=true; } diff --git a/LibAPRS/AFSK.h b/LibAPRS/AFSK.h index 75f882b..d03d24e 100644 --- a/LibAPRS/AFSK.h +++ b/LibAPRS/AFSK.h @@ -10,9 +10,9 @@ #include "HDLC.h" #define SIN_LEN 512 -namespace AFSKADCINIT {//va7ta update - void AFSK_hw_init(void);//va7ta update -};//va7ta update +namespace AFSKADCINIT { + void AFSK_hw_init(void); +}; static const uint8_t sin_table[] PROGMEM = { 128, 129, 131, 132, 134, 135, 137, 138, 140, 142, 143, 145, 146, 148, 149, 151, diff --git a/LibAPRS/AX25.cpp b/LibAPRS/AX25.cpp index fe3f831..b36c13e 100644 --- a/LibAPRS/AX25.cpp +++ b/LibAPRS/AX25.cpp @@ -15,7 +15,7 @@ extern int LibAPRS_vref; extern bool LibAPRS_open_squelch; -bool CRC_Err=false; // CRC error flag - va7ta update +bool CRC_Err=false; void ax25_init(AX25Ctx *ctx, ax25_callback_t hook) { memset(ctx, 0, sizeof(*ctx)); @@ -71,9 +71,9 @@ void ax25_poll(AX25Ctx *ctx) { LED_RX_ON(); } ax25_decode(ctx); - }else{//va7ta update - CRC_Err=true;//va7ta update - }//va7ta update + }else{ + CRC_Err=true; + } } ctx->sync = true; ctx->crc_in = CRC_CCIT_INIT_VAL; diff --git a/LibAPRS/LibAPRS.h b/LibAPRS/LibAPRS.h index d0a1e9c..3d23bcc 100644 --- a/LibAPRS/LibAPRS.h +++ b/LibAPRS/LibAPRS.h @@ -20,7 +20,7 @@ void APRS_setPath2(char *call, int ssid); void APRS_setPreamble(unsigned long pre); void APRS_setTail(unsigned long tail); void APRS_useAlternateSymbolTable(bool use); -void APRS_setDataTypeID(uint8_t flag);//va7ta update +void APRS_setDataTypeID(uint8_t flag); void APRS_setSymbol(char sym); diff --git a/LibAPRS/examples/Basic_usage/Basic_usage.ino b/LibAPRS/examples/Basic_usage/Basic_usage.ino index a70180a..44d73a6 100644 --- a/LibAPRS/examples/Basic_usage/Basic_usage.ino +++ b/LibAPRS/examples/Basic_usage/Basic_usage.ino @@ -12,7 +12,7 @@ //#define ADC_REFERENCE REF_5V // '!'(33) for no messaging; '='(61)if APRS messaging available -#define APRS_DATA_TYPE_FLAG '=' // va7ta update +#define APRS_DATA_TYPE_FLAG '=' // Note some squelch delays are too short for catching APRS packets. // You can also define whether your modem will be @@ -118,7 +118,7 @@ void locationUpdateExample() { APRS_setHeight(4); APRS_setGain(7); APRS_setDirectivity(0); - APRS_setDataTypeID(APRS_DATA_TYPE_FLAG);//flags if APRS messaging is available (va7ta update) + APRS_setDataTypeID(APRS_DATA_TYPE_FLAG);//flags if APRS messaging is available // We'll define a comment string @@ -175,7 +175,7 @@ void processPacket() { boolean whichExample = false; void loop() { - /* va7ta update: + /* * insert this statement immediately after using the ADC for * other possible functions such as measuring a voltage from * a sensor. This is needed to re-configure the ADC for AFSK From 8120ef5b5b906345a5ffa968fa32fa73b00d812e Mon Sep 17 00:00:00 2001 From: va7ta Date: Wed, 7 Feb 2018 22:25:51 -0800 Subject: [PATCH 6/6] va7ta ADC Sharing and Data Error Flags --- LibAPRS/AFSK.cpp | 2 +- LibAPRS/AFSK.h | 2 +- LibAPRS/AX25.cpp | 2 +- LibAPRS/LibAPRS.cpp | 2 +- LibAPRS/LibAPRS.h | 2 +- LibAPRS/examples/Basic_usage/Basic_usage.ino | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/LibAPRS/AFSK.cpp b/LibAPRS/AFSK.cpp index 5b53727..4a3d32c 100644 --- a/LibAPRS/AFSK.cpp +++ b/LibAPRS/AFSK.cpp @@ -215,7 +215,7 @@ static bool hdlcParse(Hdlc *hdlc, bool bit, FIFOBuffer *fifo) { ret = false; hdlc->receiving = false; LED_RX_OFF(); - fullBfrErr=true; + fullBfrErr=true; } diff --git a/LibAPRS/AFSK.h b/LibAPRS/AFSK.h index d03d24e..6e33cd1 100644 --- a/LibAPRS/AFSK.h +++ b/LibAPRS/AFSK.h @@ -12,7 +12,7 @@ #define SIN_LEN 512 namespace AFSKADCINIT { void AFSK_hw_init(void); -}; +}; static const uint8_t sin_table[] PROGMEM = { 128, 129, 131, 132, 134, 135, 137, 138, 140, 142, 143, 145, 146, 148, 149, 151, diff --git a/LibAPRS/AX25.cpp b/LibAPRS/AX25.cpp index b36c13e..96a1181 100644 --- a/LibAPRS/AX25.cpp +++ b/LibAPRS/AX25.cpp @@ -15,7 +15,7 @@ extern int LibAPRS_vref; extern bool LibAPRS_open_squelch; -bool CRC_Err=false; +bool CRC_Err=false; void ax25_init(AX25Ctx *ctx, ax25_callback_t hook) { memset(ctx, 0, sizeof(*ctx)); diff --git a/LibAPRS/LibAPRS.cpp b/LibAPRS/LibAPRS.cpp index 4c77b67..2fa07a9 100644 --- a/LibAPRS/LibAPRS.cpp +++ b/LibAPRS/LibAPRS.cpp @@ -4,7 +4,7 @@ Afsk modem; AX25Ctx AX25; -extern void aprs_msg_callback(struct AX25Msg *msg); +extern void aprs_msg_callback(struct AX25Msg *msg); #define countof(a) sizeof(a)/sizeof(a[0]) int LibAPRS_vref = REF_3V3; diff --git a/LibAPRS/LibAPRS.h b/LibAPRS/LibAPRS.h index 3d23bcc..9c49e35 100644 --- a/LibAPRS/LibAPRS.h +++ b/LibAPRS/LibAPRS.h @@ -19,7 +19,7 @@ void APRS_setPath2(char *call, int ssid); void APRS_setPreamble(unsigned long pre); void APRS_setTail(unsigned long tail); -void APRS_useAlternateSymbolTable(bool use); +void APRS_useAlternateSymbolTable(bool use); void APRS_setDataTypeID(uint8_t flag); void APRS_setSymbol(char sym); diff --git a/LibAPRS/examples/Basic_usage/Basic_usage.ino b/LibAPRS/examples/Basic_usage/Basic_usage.ino index 44d73a6..4930a21 100644 --- a/LibAPRS/examples/Basic_usage/Basic_usage.ino +++ b/LibAPRS/examples/Basic_usage/Basic_usage.ino @@ -175,7 +175,7 @@ void processPacket() { boolean whichExample = false; void loop() { - /* + /* * insert this statement immediately after using the ADC for * other possible functions such as measuring a voltage from * a sensor. This is needed to re-configure the ADC for AFSK