@@ -174,10 +174,10 @@ void decode_aprs (decode_aprs_t *A, packet_t pp, int quiet, int third_party)
174174 A -> g_quiet = quiet ;
175175
176176 if (isprint (* pinfo )) {
177- snprintf (A -> g_data_type_desc , sizeof (A -> g_data_type_desc ), "Unknown APRS Data Type Indicator \"%c\"" , * pinfo );
177+ snprintf (A -> g_data_type_desc , sizeof (A -> g_data_type_desc ), "ERROR!!! Unknown APRS Data Type Indicator \"%c\"" , * pinfo );
178178 }
179179 else {
180- snprintf (A -> g_data_type_desc , sizeof (A -> g_data_type_desc ), "ERROR!!! Unknown APRS Data Type Indicator: unprintable 0x%02x" , * pinfo );
180+ snprintf (A -> g_data_type_desc , sizeof (A -> g_data_type_desc ), "ERROR!!! Unknown APRS Data Type Indicator: unprintable 0x%02x" , * pinfo );
181181 }
182182
183183 A -> g_symbol_table = '/' ; /* Default to primary table. */
@@ -303,7 +303,7 @@ void decode_aprs (decode_aprs_t *A, packet_t pp, int quiet, int third_party)
303303
304304 if (strncmp ((char * )pinfo , "!!" , 2 ) == 0 )
305305 {
306- aprs_ultimeter (A , (char * )pinfo , info_len );
306+ aprs_ultimeter (A , (char * )pinfo , info_len ); // TODO: produce obsolete error.
307307 }
308308 else
309309 {
@@ -312,15 +312,15 @@ void decode_aprs (decode_aprs_t *A, packet_t pp, int quiet, int third_party)
312312 break ;
313313
314314
315- //case '#': /* Peet Bros U-II Weather station */
315+ //case '#': /* Peet Bros U-II Weather station */ // TODO: produce obsolete error.
316316 //case '*': /* Peet Bros U-II Weather station */
317317 //break;
318318
319319 case '$' : /* Raw GPS data or Ultimeter 2000 */
320320
321321 if (strncmp ((char * )pinfo , "$ULTW" , 5 ) == 0 )
322322 {
323- aprs_ultimeter (A , (char * )pinfo , info_len );
323+ aprs_ultimeter (A , (char * )pinfo , info_len ); // TODO: produce obsolete error.
324324 }
325325 else
326326 {
@@ -536,7 +536,13 @@ void decode_aprs_print (decode_aprs_t *A) {
536536 snprintf (rng , sizeof (rng ), ", range=%.1f" , A -> g_range );
537537 strlcat (stemp , rng , sizeof (stemp ));
538538 }
539- text_color_set (DW_COLOR_DECODED );
539+
540+ if (strncmp (stemp , "ERROR" , 5 ) == 0 ) {
541+ text_color_set (DW_COLOR_ERROR );
542+ }
543+ else {
544+ text_color_set (DW_COLOR_DECODED );
545+ }
540546 dw_printf ("%s\n" , stemp );
541547
542548/*
@@ -556,7 +562,6 @@ void decode_aprs_print (decode_aprs_t *A) {
556562 * Any example was checked for each hemihemisphere using
557563 * http://www.amsat.org/cgi-bin/gridconv
558564 */
559- // FIXME soften language about upper case.
560565
561566 if (strlen (A -> g_maidenhead ) > 0 ) {
562567
@@ -1565,7 +1570,7 @@ static void aprs_mic_e (decode_aprs_t *A, packet_t pp, unsigned char *info, int
15651570 * Purpose: Decode "Message Format."
15661571 * The word message is used loosely all over the place, but it has a very specific meaning here.
15671572 *
1568- * Inputs: info - Pointer to Information field.
1573+ * Inputs: info - Pointer to Information field. Be carefull not to modify it here!
15691574 * ilen - Information field length.
15701575 * quiet - suppress error messages.
15711576 *
@@ -1609,7 +1614,7 @@ static void aprs_mic_e (decode_aprs_t *A, packet_t pp, unsigned char *info, int
16091614 *
16101615 *------------------------------------------------------------------*/
16111616
1612- static void aprs_message (decode_aprs_t * A , unsigned char * info , int ilen , int quiet )
1617+ static void aprs_message (decode_aprs_t * A , unsigned char * info , int ilen , int quiet )
16131618{
16141619
16151620 struct aprs_message_s {
@@ -1619,7 +1624,7 @@ static void aprs_message (decode_aprs_t *A, unsigned char *info, int ilen, int q
16191624 char message [256 - 1 - 9 - 1 ]; /* Officially up to 67 characters for message text. */
16201625 /* Relaxing seemingly arbitrary restriction here; it doesn't need to fit on a punched card. */
16211626 /* Wouldn't surprise me if others did not pay attention to the limit. */
1622- /* Optional { followed by 1-5 alphanumeric characters for message number */
1627+ /* Optional '{' followed by 1-5 alphanumeric characters for message number */
16231628
16241629 /* If the first character is '?' it is a Directed Station Query. */
16251630 } * p ;
@@ -1751,6 +1756,16 @@ static void aprs_message (decode_aprs_t *A, unsigned char *info, int ilen, int q
17511756 text_color_set (DW_COLOR_ERROR );
17521757 dw_printf ("ERROR: Message number is missing after \"ack\".\n" );
17531758 }
1759+
1760+ // Xastir puts a carriage return on the end.
1761+ char * p = strchr (A -> g_message_number , '\r' );
1762+ if (p != NULL ) {
1763+ text_color_set (DW_COLOR_ERROR );
1764+ dw_printf ("The APRS protocol specification says nothing about a possible carriage return after the\n" );
1765+ dw_printf ("message id. Adding CR might prevent proper interoperability with with other applications.\n" );
1766+ * p = '\0' ;
1767+ }
1768+
17541769 if (strlen (A -> g_message_number ) >= 3 && A -> g_message_number [2 ] == '}' ) A -> g_message_number [2 ] = '\0' ;
17551770 snprintf (A -> g_data_type_desc , sizeof (A -> g_data_type_desc ), "\"%s\" ACKnowledged message number \"%s\" from \"%s\"" , A -> g_src , A -> g_message_number , addressee );
17561771 A -> g_message_subtype = message_subtype_ack ;
@@ -1765,6 +1780,16 @@ static void aprs_message (decode_aprs_t *A, unsigned char *info, int ilen, int q
17651780 text_color_set (DW_COLOR_ERROR );
17661781 dw_printf ("ERROR: Message number is missing after \"rej\".\n" );
17671782 }
1783+
1784+ // Xastir puts a carriage return on the end.
1785+ char * p = strchr (A -> g_message_number , '\r' );
1786+ if (p != NULL ) {
1787+ text_color_set (DW_COLOR_ERROR );
1788+ dw_printf ("The APRS protocol specification says nothing about a possible carriage return after the\n" );
1789+ dw_printf ("message id. Adding CR might prevent proper interoperability with with other applications.\n" );
1790+ * p = '\0' ;
1791+ }
1792+
17681793 if (strlen (A -> g_message_number ) >= 3 && A -> g_message_number [2 ] == '}' ) A -> g_message_number [2 ] = '\0' ;
17691794 snprintf (A -> g_data_type_desc , sizeof (A -> g_data_type_desc ), "\"%s\" REJected message number \"%s\" from \"%s\"" , A -> g_src , A -> g_message_number , addressee );
17701795 A -> g_message_subtype = message_subtype_ack ;
@@ -1788,13 +1813,23 @@ static void aprs_message (decode_aprs_t *A, unsigned char *info, int ilen, int q
17881813 // Look for message number.
17891814 char * pno = strchr (p -> message , '{' );
17901815 if (pno != NULL ) {
1791- * pno = '\0' ;
1792- int mlen = strlen (pno + 1 );
1816+ strlcpy (A -> g_message_number , pno + 1 , sizeof (A -> g_message_number ));
1817+
1818+ // Xastir puts a carriage return on the end.
1819+ char * p = strchr (A -> g_message_number , '\r' );
1820+ if (p != NULL ) {
1821+ text_color_set (DW_COLOR_ERROR );
1822+ dw_printf ("The APRS protocol specification says nothing about a possible carriage return after the\n" );
1823+ dw_printf ("message id. Adding CR might prevent proper interoperability with with other applications.\n" );
1824+ * p = '\0' ;
1825+ }
1826+
1827+ int mlen = strlen (A -> g_message_number );
17931828 if (mlen < 1 || mlen > 5 ) {
17941829 text_color_set (DW_COLOR_ERROR );
1795- dw_printf ("Message number \"%s\" has length outside range of 1 to 5.\n" , pno + 1 );
1830+ dw_printf ("Message number \"%s\" has length outside range of 1 to 5.\n" , A -> g_message_number );
17961831 }
1797- strlcpy ( A -> g_message_number , pno + 1 , sizeof ( A -> g_message_number ));
1832+
17981833 // TODO: Complain if not alphanumeric.
17991834
18001835 char ack [8 ] = "" ;
@@ -1824,6 +1859,11 @@ static void aprs_message (decode_aprs_t *A, unsigned char *info, int ilen, int q
18241859 /* No location so don't use process_comment () */
18251860
18261861 strlcpy (A -> g_comment , p -> message , sizeof (A -> g_comment ));
1862+ // Remove message number when displaying message text.
1863+ pno = strchr (A -> g_comment , '{' );
1864+ if (pno != NULL ) {
1865+ * pno = '\0' ;
1866+ }
18271867 }
18281868
18291869}
@@ -3752,9 +3792,14 @@ time_t get_timestamp (decode_aprs_t *A, char *p)
37523792 * It is composed of:
37533793 * a pair of letters in range A to R.
37543794 * a pair of digits in range of 0 to 9.
3755- * a pair of letters in range of A to X.
3795+ * an optional pair of letters in range of A to X.
3796+ *
3797+ * The spec says:
3798+ * "All letters must be transmitted in upper case.
3799+ * Letters may be received in upper case or lower case."
37563800 *
3757- * The APRS spec says that all letters must be transmitted in upper case.
3801+ * Typically the second set of letters is written in lower case.
3802+ * An earlier version incorrectly produced an error if lower case found.
37583803 *
37593804 *
37603805 * Examples from APRS spec:
@@ -3775,25 +3820,10 @@ int get_maidenhead (decode_aprs_t *A, char *p)
37753820
37763821 /* We have 4 characters matching the rule. */
37773822
3778- if (islower (p [0 ]) || islower (p [1 ])) {
3779- if ( ! A -> g_quiet ) {
3780- text_color_set (DW_COLOR_ERROR );
3781- dw_printf ("Warning: Lower case letter in Maidenhead locator. Specification requires upper case.\n" );
3782- }
3783- }
3784-
37853823 if (toupper (p [4 ]) >= 'A' && toupper (p [4 ]) <= 'X' &&
37863824 toupper (p [5 ]) >= 'A' && toupper (p [5 ]) <= 'X' ) {
37873825
37883826 /* We have 6 characters matching the rule. */
3789-
3790- if (islower (p [4 ]) || islower (p [5 ])) {
3791- if ( ! A -> g_quiet ) {
3792- text_color_set (DW_COLOR_ERROR );
3793- dw_printf ("Warning: Lower case letter in Maidenhead locator. Specification requires upper case.\n" );
3794- }
3795- }
3796-
37973827 return 6 ;
37983828 }
37993829
@@ -4649,7 +4679,7 @@ static void process_comment (decode_aprs_t *A, char *pstart, int clen)
46494679 int a = A -> g_comment [match [0 ].rm_so + 2 ];
46504680 int o = A -> g_comment [match [0 ].rm_so + 3 ];
46514681
4652- dw_printf ("DAO start=%d, end=%d\n" , (int )(match [0 ].rm_so ), (int )(match [0 ].rm_eo ));
4682+ // dw_printf("DAO start=%d, end=%d\n", (int)(match[0].rm_so), (int)(match[0].rm_eo));
46534683
46544684
46554685/*
@@ -5035,7 +5065,9 @@ int main (int argc, char *argv[])
50355065 /* Try to process it. */
50365066
50375067 text_color_set (DW_COLOR_REC );
5038- dw_printf ("\n%s\n" , stuff );
5068+ dw_printf ("\n" );
5069+ ax25_safe_print (stuff , -1 , 0 );
5070+ dw_printf ("\n" );
50395071
50405072// Do we have monitor format, KISS, or AX.25 frame?
50415073
0 commit comments