M17 - Fix / Initialize User Input Strings and Fix CAN Value;

This commit is contained in:
lwvmobile 2024-03-12 17:48:38 -04:00
parent 2392f57d62
commit 114d8d7dfc
4 changed files with 29 additions and 20 deletions

View File

@ -784,8 +784,8 @@ typedef struct
unsigned long long int m17_dst;
unsigned long long int m17_src;
uint8_t m17_can; //can value that was decoded from signal
uint8_t m17_can_en; //can value supplied to the encoding side
uint8_t m17_can; //can value that was decoded from signal
int m17_can_en; //can value supplied to the encoding side
char m17_dst_csd[20];
char m17_src_csd[20];
@ -802,6 +802,7 @@ typedef struct
//misc str storage
char str50a[50];
char str50b[50];
char str50c[50];
char m17dat[50]; //user supplied m17 data input string
char m17sms[800]; //user supplied sms text string

View File

@ -502,8 +502,7 @@ noCarrier (dsd_opts * opts, dsd_state * state)
state->m17_dst = 0;
state->m17_src = 0;
state->m17_can = 0; //can value that was decoded from signal
state->m17_can_en = 0; //can value supplied to the encoding side
state->m17_can = 0;
memset(state->m17_dst_csd, 0, sizeof(state->m17_dst_csd));
memset(state->m17_src_csd, 0, sizeof(state->m17_src_csd));
sprintf (state->m17_dst_str, "%s", "");
@ -514,10 +513,11 @@ noCarrier (dsd_opts * opts, dsd_state * state)
memset(state->m17_meta, 0, sizeof(state->m17_meta));
//misc str storage
memset (state->str50a, 0, 50*sizeof(char));
memset (state->str50b, 0, 50*sizeof(char));
memset (state->m17sms, 0, 800*sizeof(char));
sprintf (state->m17dat, "%s", "");
sprintf (state->str50a, "%s", "");
// memset (state->str50b, 0, 50*sizeof(char));
// memset (state->str50c, 0, 50*sizeof(char));
// memset (state->m17sms, 0, 800*sizeof(char));
// sprintf (state->m17dat, "%s", "");
//set float temp buffer to baseline
memset (state->audio_out_temp_buf, 0.0f, sizeof(state->audio_out_temp_buf));
@ -1179,9 +1179,17 @@ initState (dsd_state * state)
state->m17_pbc_ct = 0;
state->m17_str_dt = 9;
//misc str storage
sprintf (state->str50a, "%s", "");
memset (state->str50b, 0, 50*sizeof(char));
memset (state->str50c, 0, 50*sizeof(char));
memset (state->m17sms, 0, 800*sizeof(char));
sprintf (state->m17dat, "%s", "");
state->m17_dst = 0;
state->m17_src = 0;
state->m17_can = 0;
state->m17_can = 0; //can value that was decoded from signal
state->m17_can_en = -1; //can value supplied to the encoding side
memset(state->m17_dst_csd, 0, sizeof(state->m17_dst_csd));
memset(state->m17_src_csd, 0, sizeof(state->m17_src_csd));
sprintf (state->m17_dst_str, "%s", "");
@ -3006,8 +3014,8 @@ main (int argc, char **argv)
curr = strtok(NULL, ":"); //m17 src address
if (curr != NULL)
{
strncpy (state.str50a, curr, 9); //only read first 9
state.str50a[9] = '\0';
strncpy (state.str50c, curr, 9); //only read first 9
state.str50c[9] = '\0';
}
curr = strtok(NULL, ":"); //m17 dst address
@ -3027,7 +3035,7 @@ main (int argc, char **argv)
// fprintf (stderr, " %s;", state.m17dat);
//debug print
fprintf (stderr, " M17:%d:%s:%s; \n ", state.m17_can_en, state.str50a, state.str50b);
fprintf (stderr, " M17:%d:%s:%s; \n ", state.m17_can_en, state.str50c, state.str50b);
}
if (opts.playfiles == 1)

View File

@ -1684,7 +1684,7 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state)
state->nxdn_last_rid = 0;
state->nxdn_last_tg = 0;
sprintf (state->str50a, "%s", "");
sprintf (state->str50b, "%s", "");
memset (state->str50b, 0, 50*sizeof(char));
}
if (choice == 16) //toggle payload printing

View File

@ -1299,11 +1299,11 @@ void encodeM17STR(dsd_opts * opts, dsd_state * state)
//end User Defined Variables
//configure User Defined Variables, if defined at CLI
if (state->m17_can_en != 0) //is 0 a valid number?
if (state->m17_can_en != -1) //has a set value
can = state->m17_can_en;
if (state->str50a[0] != 0)
sprintf (s40, "%s", state->str50a);
if (state->str50c[0] != 0)
sprintf (s40, "%s", state->str50c);
if (state->str50b[0] != 0)
sprintf (d40, "%s", state->str50b);
@ -2288,11 +2288,11 @@ void encodeM17PKT(dsd_opts * opts, dsd_state * state)
//end User Defined Variables
//configure User Defined Variables, if defined at CLI
if (state->m17_can_en != 0) //is 0 a valid number?
if (state->m17_can_en != -1) //has a set value
can = state->m17_can_en;
if (state->str50a[0] != 0)
sprintf (s40, "%s", state->str50a);
if (state->str50c[0] != 0)
sprintf (s40, "%s", state->str50c);
if (state->str50b[0] != 0)
sprintf (d40, "%s", state->str50b);
@ -2301,7 +2301,7 @@ void encodeM17PKT(dsd_opts * opts, dsd_state * state)
sprintf (text, "%s", state->m17sms);
// switch to this if issues crop up (cygwin, etc)
// strncpy (s40, state->str50a, 9);
// strncpy (s40, state->str50c, 9);
// strncpy (d40, state->str50b, 9);
// s40[10] = '\0';
// d40[10] = '\0';