void longitude_to_comp_str (double dlong, char *clon) { int x, x0, x1, x2, x3; if (dlong < -180.) { text_color_set(DW_COLOR_ERROR); dw_printf ("Longitude is less than -180. Changing to -180.n"); dlong = -180.; } if (dlong > 180.) { text_color_set(DW_COLOR_ERROR); dw_printf ("Longitude is greater than 180. Changing to 180.n"); dlong = 180.; } x = (int)round(190463. * (180. + dlong)); x0 = x / (91*91*91); x -= x0 * (91*91*91); x1 = x / (91*91); x -= x1 * (91*91); x2 = x / (91); x -= x2 * (91); x3 = x; clon[0] = x0 + 33; clon[1] = x1 + 33; clon[2] = x2 + 33; clon[3] = x3 + 33; }
double latitude_from_nmea (char *pstr, char *phemi) { double lat; if ( ! isdigit((unsigned char)(pstr[0]))) return (G_UNKNOWN); if (pstr[4] != '.') return (G_UNKNOWN); lat = (pstr[0] - '0') * 10 + (pstr[1] - '0') + atof(pstr+2) / 60.0; if (lat < 0 || lat > 90) { text_color_set(DW_COLOR_ERROR); dw_printf("Error: Latitude not in range of 0 to 90.\n"); } // Saw this one time: // $GPRMC,000000,V,0000.0000,0,00000.0000,0,000,000,000000,,*01 // If location is unknown, I think the hemisphere should be // an empty string. TODO: Check on this. // 'V' means void, so sentence should be discarded rather than // trying to extract any data from it. if (*phemi != 'N' && *phemi != 'S' && *phemi != '\0') { text_color_set(DW_COLOR_ERROR); dw_printf("Error: Latitude hemisphere should be N or S.\n"); } if (*phemi == 'S') lat = ( - lat); return (lat); }
static int remove_checksum (char *sent, int quiet) { char *p; unsigned char cs; // Do we have valid checksum? cs = 0; for (p = sent+1; *p != '*' && *p != '\0'; p++) { cs ^= *p; } p = strchr (sent, '*'); if (p == NULL) { if ( ! quiet) { text_color_set (DW_COLOR_INFO); dw_printf("Missing GPS checksum.\n"); } return (-1); } if (cs != strtoul(p+1, NULL, 16)) { if ( ! quiet) { text_color_set (DW_COLOR_ERROR); dw_printf("GPS checksum error. Expected %02x but found %s.\n", cs, p+1); } return (-1); } *p = '\0'; // Remove the checksum. return (0); }
static void print_error (pfstate_t *pf, char *msg) { char intro[50]; if (pf->from_chan == MAX_CHANS) { if (pf->to_chan == MAX_CHANS) { snprintf (intro, sizeof(intro), "filter[IG,IG]: "); } else { snprintf (intro, sizeof(intro), "filter[IG,%d]: ", pf->to_chan); } } else { if (pf->to_chan == MAX_CHANS) { snprintf (intro, sizeof(intro), "filter[%d,IG]: ", pf->from_chan); } else { snprintf (intro, sizeof(intro), "filter[%d,%d]: ", pf->from_chan, pf->to_chan); } } text_color_set (DW_COLOR_ERROR); dw_printf ("%s%s\n", intro, pf->filter_str); dw_printf ("%*s\n", (int)(strlen(intro) + pf->tokeni + 1), "^"); dw_printf ("%s\n", msg); }
void latitude_to_comp_str (double dlat, char *clat) { int y, y0, y1, y2, y3; if (dlat < -90.) { text_color_set(DW_COLOR_ERROR); dw_printf ("Latitude is less than -90. Changing to -90.n"); dlat = -90.; } if (dlat > 90.) { text_color_set(DW_COLOR_ERROR); dw_printf ("Latitude is greater than 90. Changing to 90.n"); dlat = 90.; } y = (int)round(380926. * (90. - dlat)); y0 = y / (91*91*91); y -= y0 * (91*91*91); y1 = y / (91*91); y -= y1 * (91*91); y2 = y / (91); y -= y2 * (91); y3 = y; clat[0] = y0 + 33; clat[1] = y1 + 33; clat[2] = y2 + 33; clat[3] = y3 + 33; }
static int checksum_not_ok (char *str, int len, char found) { int i; int sum; char expected; sum = 0; for (i=0; i<len; i++) { if (isdigit(str[i])) { sum += str[i] - '0'; } else if (str[i] >= 'A' && str[i] <= 'D') { sum += str[i] - 'A' + 10; } else { text_color_set(DW_COLOR_ERROR); dw_printf ("aprs_tt: checksum: bad character \"%c\" in checksum calculation!\n", str[i]); } } expected = '0' + (sum % 10); if (expected != found) { text_color_set(DW_COLOR_ERROR); dw_printf ("Bad checksum for \"%.*s\". Expected %c but received %c.\n", len, str, expected, found); return (TT_ERROR_BAD_CHECKSUM); } return (0); }
void redecode_init (struct audio_s *p_audio_config) { #if 0 #if __WIN32__ HANDLE redecode_th; #else pthread_t redecode_tid; int e; #endif #if DEBUG text_color_set(DW_COLOR_DEBUG); dw_printf ("redecode_init ( ... )\n"); #endif save_audio_config_p = p_audio_config; #if DEBUG text_color_set(DW_COLOR_DEBUG); dw_printf ("redecode_init: about to call rdq_init \n"); #endif rdq_init (); #if DEBUG text_color_set(DW_COLOR_DEBUG); dw_printf ("redecode_init: about to create thread \n"); #endif #if __WIN32__ redecode_th = _beginthreadex (NULL, 0, redecode_thread, NULL, 0, NULL); if (redecode_th == NULL) { text_color_set(DW_COLOR_ERROR); dw_printf ("Could not create redecode thread\n"); return; } #else //TODO: Give thread lower priority. e = pthread_create (&redecode_tid, NULL, redecode_thread, (void *)0); if (e != 0) { text_color_set(DW_COLOR_ERROR); perror("Could not create redecode thread"); return; } #endif #if DEBUG text_color_set(DW_COLOR_DEBUG); dw_printf ("redecode_init: finished \n"); #endif #endif } /* end redecode_init */
int dwgpsnmea_init (struct misc_config_s *pconfig, int debug) { //dwgps_info_t info; #if __WIN32__ HANDLE read_gps_th; #else pthread_t read_gps_tid; int e; #endif s_debug = debug; if (s_debug >= 2) { text_color_set(DW_COLOR_DEBUG); dw_printf ("dwgpsnmea_init()\n"); } if (strlen(pconfig->gpsnmea_port) == 0) { /* Nothing to do. Leave initial fix value for not init. */ return (0); } /* * Open serial port connection. * 4800 baud is standard for GPS. * Should add an option to allow changing someday. */ s_gpsnmea_port_fd = serial_port_open (pconfig->gpsnmea_port, 4800); if (s_gpsnmea_port_fd != MYFDERROR) { #if __WIN32__ read_gps_th = (HANDLE)_beginthreadex (NULL, 0, read_gpsnmea_thread, (void*)(long)s_gpsnmea_port_fd, 0, NULL); if (read_gps_th == NULL) { text_color_set(DW_COLOR_ERROR); dw_printf ("Could not create GPS NMEA listening thread.\n"); return (-1); } #else int e; e = pthread_create (&read_gps_tid, NULL, read_gpsnmea_thread, (void*)(long)s_gpsnmea_port_fd); if (e != 0) { text_color_set(DW_COLOR_ERROR); perror("Could not create GPS NMEA listening thread."); return (-1); } #endif } else { text_color_set(DW_COLOR_ERROR); dw_printf ("Could not open serial port %s for GPS receiver.\n", pconfig->gpsnmea_port); return (-1); } /* success */ return (1); } /* end dwgpsnmea_init */
void aprs_tt_sequence (int chan, char *msg) { int err; #if DEBUG text_color_set(DW_COLOR_DEBUG); dw_printf ("\n\"%s\"\n", msg); #endif /* * Discard empty message. * In case # is there as optional start. */ if (msg[0] == '#') return; /* * The parse functions will fill these in. */ strcpy (m_callsign, ""); m_symtab_or_overlay = '\\'; m_symbol_code = 'A'; m_longitude = G_UNKNOWN; m_latitude = G_UNKNOWN; strcpy (m_comment, ""); strcpy (m_freq, ""); m_mic_e = ' '; strcpy (m_dao, "!T !"); /* start out unknown */ m_ssid = 12; /* * Parse the touch tone sequence. */ err = parse_fields (msg); #if defined(DEBUG) || defined(TT_MAIN) text_color_set(DW_COLOR_DEBUG); dw_printf ("callsign=\"%s\", ssid=%d, symbol=\"%c%c\", freq=\"%s\", comment=\"%s\", lat=%.4f, lon=%.4f, dao=\"%s\"\n", m_callsign, m_ssid, m_symtab_or_overlay, m_symbol_code, m_freq, m_comment, m_latitude, m_longitude, m_dao); #endif if (err == 0) { /* * Digested successfully. Add to our list of users and schedule transmissions. */ #ifndef TT_MAIN err = tt_user_heard (m_callsign, m_ssid, m_symtab_or_overlay, m_symbol_code, m_latitude, m_longitude, m_freq, m_comment, m_mic_e, m_dao); #endif } // TODO send response to user. // err == 0 OK, others, suitable error response. } /* end aprs_tt_sequence */
int pfilter (int from_chan, int to_chan, char *filter, packet_t pp) { pfstate_t pfstate; char *p; int result; assert (from_chan >= 0 && from_chan <= MAX_CHANS); assert (to_chan >= 0 && to_chan <= MAX_CHANS); if (pp == NULL) { text_color_set(DW_COLOR_DEBUG); dw_printf ("INTERNAL ERROR in pfilter: NULL packet pointer. Please report this!\n"); return (-1); } if (filter == NULL) { text_color_set(DW_COLOR_DEBUG); dw_printf ("INTERNAL ERROR in pfilter: NULL filter string pointer. Please report this!\n"); return (-1); } pfstate.from_chan = from_chan; pfstate.to_chan = to_chan; /* Copy filter string, removing any control characters. */ memset (pfstate.filter_str, 0, sizeof(pfstate.filter_str)); strncpy (pfstate.filter_str, filter, MAX_FILTER_LEN-1); pfstate.nexti = 0; for (p = pfstate.filter_str; *p != '\0'; p++) { if (iscntrl(*p)) { *p = ' '; } } pfstate.pp = pp; decode_aprs (&pfstate.decoded, pp, 1); next_token(&pfstate); if (pfstate.token_type == TOKEN_EOL) { /* Empty filter means reject all. */ result = 0; } else { result = parse_expr (&pfstate); if (pfstate.token_type != TOKEN_AND && pfstate.token_type != TOKEN_OR && pfstate.token_type != TOKEN_EOL) { print_error (&pfstate, "Expected logical operator or end of line here."); result = -1; } } return (result); } /* end pfilter */
void longitude_to_str (double dlong, int ambiguity, char *slong) { char hemi; /* Hemisphere: N or S */ int ideg; /* whole number of degrees. */ double dmin; /* Minutes after removing degrees. */ char smin[8]; /* Minutes in format mm.mm */ if (dlong < -180.) { text_color_set(DW_COLOR_ERROR); dw_printf ("Longitude is less than -180. Changing to -180.n"); dlong = -180.; } if (dlong > 180.) { text_color_set(DW_COLOR_ERROR); dw_printf ("Longitude is greater than 180. Changing to 180.n"); dlong = 180.; } if (dlong < 0) { dlong = (- dlong); hemi = 'W'; } else { hemi = 'E'; } ideg = (int)dlong; dmin = (dlong - ideg) * 60.; sprintf (smin, "%05.2f", dmin); /* Due to roundoff, 59.9999 could come out as "60.00" */ if (smin[0] == '6') { smin[0] = '0'; ideg++; } sprintf (slong, "%03d%s%c", ideg, smin, hemi); /* * The spec says position ambiguity in latitude also * applies to longitude automatically. * Blanking longitude digits is not necessary but I do it * because it makes things clearer. */ if (ambiguity >= 1) { slong[7] = ' '; if (ambiguity >= 2) { slong[6] = ' '; if (ambiguity >= 3) { slong[4] = ' '; if (ambiguity >= 4) { slong[3] = ' '; } } } } } /* end longitude_to_str */
void gen_bandpass (float f1, float f2, float *bp_filter, int filter_size, bp_window_t wtype) { int j; float w; float G; float center = 0.5 * (filter_size - 1); #if DEBUG1 text_color_set(DW_COLOR_DEBUG); dw_printf ("Bandpass, size=%d\n", filter_size); dw_printf (" j shape sinc final\n"); #endif assert (filter_size >= 3 && filter_size <= MAX_FILTER_SIZE); for (j=0; j<filter_size; j++) { float sinc; float shape; if (j - center == 0) { sinc = 2 * (f2 - f1); } else { sinc = sin(2 * M_PI * f2 * (j-center)) / (M_PI*(j-center)) - sin(2 * M_PI * f1 * (j-center)) / (M_PI*(j-center)); } shape = window (wtype, filter_size, j); bp_filter[j] = sinc * shape; #if DEBUG1 dw_printf ("%6d %6.2f %6.3f %6.3f\n", j, shape, sinc, bp_filter[j] ) ; #endif } /* * Normalize bandpass for unity gain in middle of passband. * Can't use same technique as for lowpass. * Instead compute gain in middle of passband. * See http://dsp.stackexchange.com/questions/4693/fir-filter-gain */ w = 2 * M_PI * (f1 + f2) / 2; G = 0; for (j=0; j<filter_size; j++) { G += 2 * bp_filter[j] * cos((j-center)*w); // is this correct? } #if DEBUG1 dw_printf ("Before normalizing, G=%.3f\n", G); #endif for (j=0; j<filter_size; j++) { bp_filter[j] = bp_filter[j] / G; } }
int main (int argc, char *argv[]) { dw_printf ("CQ DX\n"); morse_send (0, "CQ DX", 10, 10, 10); dw_printf ("\n\n"); dw_printf ("wb2osz/9\n"); morse_send (0, "wb2osz/9", 10, 10, 10); dw_printf ("\n\n"); }
void latitude_to_str (double dlat, int ambiguity, char *slat) { char hemi; /* Hemisphere: N or S */ int ideg; /* whole number of degrees. */ double dmin; /* Minutes after removing degrees. */ char smin[8]; /* Minutes in format mm.mm */ if (dlat < -90.) { text_color_set(DW_COLOR_ERROR); dw_printf ("Latitude is less than -90. Changing to -90.n"); dlat = -90.; } if (dlat > 90.) { text_color_set(DW_COLOR_ERROR); dw_printf ("Latitude is greater than 90. Changing to 90.n"); dlat = 90.; } if (dlat < 0) { dlat = (- dlat); hemi = 'S'; } else { hemi = 'N'; } ideg = (int)dlat; dmin = (dlat - ideg) * 60.; sprintf (smin, "%05.2f", dmin); /* Due to roundoff, 59.9999 could come out as "60.00" */ if (smin[0] == '6') { smin[0] = '0'; ideg++; } sprintf (slat, "%02d%s%c", ideg, smin, hemi); if (ambiguity >= 1) { slat[6] = ' '; if (ambiguity >= 2) { slat[5] = ' '; if (ambiguity >= 3) { slat[3] = ' '; if (ambiguity >= 4) { slat[2] = ' '; } } } } } /* end latitude_to_str */
void gen_lowpass (float fc, float *lp_filter, int filter_size, bp_window_t wtype) { int j; float G; #if DEBUG1 text_color_set(DW_COLOR_DEBUG); dw_printf ("Lowpass, size=%d, fc=%.2f\n", filter_size, fc); dw_printf (" j shape sinc final\n"); #endif assert (filter_size >= 3 && filter_size <= MAX_FILTER_SIZE); for (j=0; j<filter_size; j++) { float center; float sinc; float shape; center = 0.5 * (filter_size - 1); if (j - center == 0) { sinc = 2 * fc; } else { sinc = sin(2 * M_PI * fc * (j-center)) / (M_PI*(j-center)); } shape = window (wtype, filter_size, j); lp_filter[j] = sinc * shape; #if DEBUG1 dw_printf ("%6d %6.2f %6.3f %6.3f\n", j, shape, sinc, lp_filter[j] ) ; #endif } /* * Normalize lowpass for unity gain at DC. */ G = 0; for (j=0; j<filter_size; j++) { G += lp_filter[j]; } for (j=0; j<filter_size; j++) { lp_filter[j] = lp_filter[j] / G; } }
static int parse_object_name (char *e) { int len; int c_length; char tttemp[40], stemp[30]; assert (e[0] == 'A'); assert (e[1] == 'A'); len = strlen(e); /* * Object name in two key format. */ if (len >= 2 + 1 && len <= 30) { if (tt_two_key_to_text (e+2, 0, m_callsign) == 0) { m_callsign[9] = '\0'; /* truncate to 9 */ m_ssid = 0; /* No ssid for object name */ return (0); } } text_color_set(DW_COLOR_ERROR); dw_printf ("Touch tone object name not valid: \"%s\"\n", e); return (TT_ERROR_INVALID_OBJNAME); } /* end parse_oject_name */
int symbols_into_dest (char symtab, char symbol, char *dest) { if (symbol >= '!' && symbol <= '~' && symtab == '/') { /* Primary Symbol table. */ snprintf (dest, 7, "GPSC%02d", symbol - ' '); return (0); } else if (symbol >= '!' && symbol <= '~' && symtab == '\\') { /* Alternate Symbol table. */ snprintf (dest, 7, "GPSE%02d", symbol - ' '); return (0); } else if (symbol >= '!' && symbol <= '~' && (isupper(symtab) || isdigit(symtab))) { /* Alternate Symbol table with overlay. */ snprintf (dest, 7, "GPS%s%c", alternate_symtab[symbol - ' '].xy, symtab); return (0); } text_color_set(DW_COLOR_ERROR); dw_printf ("Could not convert symbol \"%c%c\" to GPSxyz destination format.\n", symtab, symbol); strlcpy (dest, "GPS???", sizeof(dest)); /* Error. */ return (1); }
static int morse_units_ch (int ch) { int i; int len; int k; int units; i = morse_lookup (ch); if (i < 0) { return (1); /* space or any invalid character */ } len = strlen(morse[i].enc); units = len - 1; for (k = 0; k < len; k++) { switch (morse[i].enc[k]) { case '.': units++; break; case '-': units += 3; break; default: dw_printf ("ERROR: morse_units_ch: should not be here.\n"); break; } } return (units); }
static void morse_quiet (int tu) { int n; for (n=0; n<tu; n++) { dw_printf ("."); } } /* end morse_quiet */
static int parse_symbol (char *e) { int len; char nstr[4]; int nn; char stemp[10]; assert (e[0] == 'A'); assert (e[1] == 'B'); len = strlen(e); if (len >= 4 && len <= 10) { nstr[0] = e[3]; nstr[1] = e[4]; nstr[2] = '\0'; nn = atoi (nstr); if (nn < 1) { nn = 1; } else if (nn > 94) { nn = 94; } switch (e[2]) { case '1': m_symtab_or_overlay = '/'; m_symbol_code = 32 + nn; return (0); break; case '2': m_symtab_or_overlay = '\\'; m_symbol_code = 32 + nn; return (0); break; case '0': if (len >= 6) { if (tt_two_key_to_text (e+5, 0, stemp) == 0) { m_symbol_code = 32 + nn; m_symtab_or_overlay = stemp[0]; return (0); } } break; } } text_color_set(DW_COLOR_ERROR); dw_printf ("Touch tone symbol not valid: \"%s\"\n", e); return (TT_ERROR_INVALID_SYMBOL); } /* end parse_oject_name */
void latitude_to_nmea (double dlat, char *slat, char *hemi) { int ideg; /* whole number of degrees. */ double dmin; /* Minutes after removing degrees. */ char smin[10]; /* Minutes in format mm.mmmm */ if (dlat == G_UNKNOWN) { strcpy (slat, ""); strcpy (hemi, ""); return; } if (dlat < -90.) { text_color_set(DW_COLOR_ERROR); dw_printf ("Latitude is less than -90. Changing to -90.n"); dlat = -90.; } if (dlat > 90.) { text_color_set(DW_COLOR_ERROR); dw_printf ("Latitude is greater than 90. Changing to 90.n"); dlat = 90.; } if (dlat < 0) { dlat = (- dlat); strcpy (hemi, "S"); } else { strcpy (hemi, "N"); } ideg = (int)dlat; dmin = (dlat - ideg) * 60.; sprintf (smin, "%07.4f", dmin); /* Due to roundoff, 59.99999 could come out as "60.0000" */ if (smin[0] == '6') { smin[0] = '0'; ideg++; } sprintf (slat, "%02d%s", ideg, smin); } /* end latitude_to_str */
void longitude_to_nmea (double dlong, char *slong, char *hemi) { int ideg; /* whole number of degrees. */ double dmin; /* Minutes after removing degrees. */ char smin[10]; /* Minutes in format mm.mmmm */ if (dlong == G_UNKNOWN) { strcpy (slong, ""); strcpy (hemi, ""); return; } if (dlong < -180.) { text_color_set(DW_COLOR_ERROR); dw_printf ("longitude is less than -180. Changing to -180.n"); dlong = -180.; } if (dlong > 180.) { text_color_set(DW_COLOR_ERROR); dw_printf ("longitude is greater than 180. Changing to 180.n"); dlong = 180.; } if (dlong < 0) { dlong = (- dlong); strcpy (hemi, "W"); } else { strcpy (hemi, "E"); } ideg = (int)dlong; dmin = (dlong - ideg) * 60.; sprintf (smin, "%07.4f", dmin); /* Due to roundoff, 59.99999 could come out as "60.0000" */ if (smin[0] == '6') { smin[0] = '0'; ideg++; } sprintf (slong, "%03d%s", ideg, smin); } /* end longitude_to_nmea */
static void raw_tt_data_to_app (int chan, char *msg) { #if TT_MAIN return ; #else char src[10], dest[10]; char raw_tt_msg[200]; packet_t pp; char *c, *s; int i; int err; alevel_t alevel; // Set source and dest to something valid to keep rest of processing happy. // For lack of a better idea, make source "DTMF" to indicate where it came from. // Application version might be useful in case we end up using different // message formats in later versions. strcpy (src, "DTMF"); sprintf (dest, "%s%d%d", APP_TOCALL, MAJOR_VERSION, MINOR_VERSION); sprintf (raw_tt_msg, "%s>%s:t%s", src, dest, msg); pp = ax25_from_text (raw_tt_msg, 1); /* * Process like a normal received frame. * NOTE: This goes directly to application rather than * thru the multi modem duplicate processing. * * Should we use a different type so it can be easily * distinguished later? * * We try to capture an overall audio level here. * Mark and space do not apply in this case. * This currently doesn't get displayed but we might want it someday. */ if (pp != NULL) { alevel = demod_get_audio_level (chan, 0); alevel.mark = -2; alevel.space = -2; dlq_append (DLQ_REC_FRAME, chan, -1, pp, alevel, RETRY_NONE, "tt"); } else { text_color_set(DW_COLOR_ERROR); dw_printf ("Could not convert \"%s\" into APRS packet.\n", raw_tt_msg); } #endif }
int xmit_speak_it (char *script, int c, char *orig_msg) { int err; char cmd[2000]; char *p; char msg[2000]; /* Remove any quotes because it will mess up command line argument parsing. */ strlcpy (msg, orig_msg, sizeof(msg)); for (p=msg; *p!='\0'; p++) { if (*p == '"') *p = ' '; } #if __WIN32__ snprintf (cmd, sizeof(cmd), "%s %d \"%s\" >nul", script, c, msg); #else snprintf (cmd, sizeof(cmd), "%s %d \"%s\"", script, c, msg); #endif //text_color_set(DW_COLOR_DEBUG); //dw_printf ("cmd=%s\n", cmd); err = system (cmd); if (err != 0) { char cwd[1000]; char path[3000]; char *ignore; text_color_set(DW_COLOR_ERROR); dw_printf ("Failed to run text-to-speech script, %s\n", script); ignore = getcwd (cwd, sizeof(cwd)); strlcpy (path, getenv("PATH"), sizeof(path)); dw_printf ("CWD = %s\n", cwd); dw_printf ("PATH = %s\n", path); } return (err); }
static void xmit_speech (int c, packet_t pp) { int info_len; unsigned char *pinfo; /* * Print spoken packet. Prefix by channel. */ info_len = ax25_get_info (pp, &pinfo); text_color_set(DW_COLOR_XMIT); dw_printf ("[%d.speech] \"%s\"\n", c, pinfo); if (strlen(save_audio_config_p->tts_script) == 0) { text_color_set(DW_COLOR_ERROR); dw_printf ("Text-to-speech script has not been configured.\n"); ax25_delete (pp); return; } /* * Turn on transmitter. */ ptt_set (OCTYPE_PTT, c, 1); /* * Invoke the speech-to-text script. */ xmit_speak_it (save_audio_config_p->tts_script, c, (char*)pinfo); /* * Turn off transmitter. */ ptt_set (OCTYPE_PTT, c, 0); ax25_delete (pp); } /* end xmit_speech */
static void pftest (int test_num, char *filter, char *monitor, int expected) { int result; packet_t pp; text_color_set (DW_COLOR_DEBUG); dw_printf ("test number %d\n", test_num); pp = ax25_from_text (monitor, 1); assert (pp != NULL); result = pfilter (0, 0, filter, pp); if (result != expected) { text_color_set (DW_COLOR_ERROR); dw_printf ("Unexpected result for test number %d\n", test_num); error_count++; } ax25_delete (pp); }
static void morse_tone (int tu) { int num_cycles; int n; for (n=0; n<tu; n++) { dw_printf ("#"); } } /* end morse_tone */
static int filt_r (pfstate_t *pf) { char str[MAX_TOKEN_LEN]; char *cp; char sep[2]; char *v; double dlat, dlon, ddist, km; strlcpy (str, pf->token_str, sizeof(str)); sep[0] = str[1]; sep[1] = '\0'; cp = str + 2; if (pf->decoded.g_lat == G_UNKNOWN || pf->decoded.g_lon == G_UNKNOWN) { return (0); } v = strsep (&cp, sep); if (v == NULL) { print_error (pf, "Missing latitude for Range filter."); return (-1); } dlat = atof(v); v = strsep (&cp, sep); if (v == NULL) { print_error (pf, "Missing longitude for Range filter."); return (-1); } dlon = atof(v); v = strsep (&cp, sep); if (v == NULL) { print_error (pf, "Missing distance for Range filter."); return (-1); } ddist = atof(v); km = ll_distance_km (dlat, dlon, pf->decoded.g_lat, pf->decoded.g_lon); text_color_set (DW_COLOR_DEBUG); dw_printf ("Calculated distance = %.3f km\n", km); if (km <= ddist) { return (1); } return (0); }
void log_term (void) { if (g_log_fp != NULL) { text_color_set(DW_COLOR_INFO); dw_printf("Closing log file \"%s\".\n", g_open_fname); fclose (g_log_fp); g_log_fp = NULL; strlcpy (g_open_fname, "", sizeof(g_open_fname)); } } /* end log_term */
int morse_send (int chan, char *str, int wpm, int txdelay, int txtail) { int time_units; char *p; time_units = 0; for (p = str; *p != '\0'; p++) { int i; i = morse_lookup (*p); if (i >= 0) { const char *e; for (e = morse[i].enc; *e != '\0'; e++) { if (*e == '.') { morse_tone (1); time_units++; } else { morse_tone (3); time_units += 3; } if (e[1] != '\0') { morse_quiet (1); time_units++; } } } else { morse_quiet (1); time_units++; } if (p[1] != '\0') { morse_quiet (3); time_units += 3; } } if (time_units != morse_units_str(str)) { dw_printf ("morse: Internal error. Inconsistent length, %d vs. %d calculated.\n", time_units, morse_units_str(str)); } return (txdelay + TIME_UNITS_TO_MS(time_units, wpm) + txtail); } /* end morse_send */