mirror of
https://github.com/n5ac/smartsdr-dsp.git
synced 2025-12-06 03:01:59 +01:00
Replace spaces in string parsing with non-printable 0x7F for correct passthrough in radio
This commit is contained in:
parent
637e3376a0
commit
5cd5b63b7e
|
|
@ -265,6 +265,7 @@ uint32 cmd_slice(int requester_fd, int argc, char **argv)
|
|||
if(strncmp(argv[2], "string", strlen("string")) == 0)
|
||||
{
|
||||
char* new_string = argv[2]+strlen("string")+1;
|
||||
charReplace(new_string, (char) 0x7F, ' ');
|
||||
freedv_set_string(slc, new_string);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,8 +196,14 @@ Circular_Float_Buffer TX4_cb = &tx4_cb;
|
|||
void my_put_next_rx_char(void *callback_state, char c)
|
||||
{
|
||||
char new_char[2];
|
||||
new_char[0] = c;
|
||||
if ( c == ' ' ) {
|
||||
/* Encode spaces differently */
|
||||
new_char[0] = (char) 0x7F;
|
||||
} else {
|
||||
new_char[0] = c;
|
||||
}
|
||||
new_char[1] = 0;
|
||||
|
||||
strncat(_rx_string, new_char, MAX_RX_STRING_LENGTH+4);
|
||||
if (strlen(_rx_string) > MAX_RX_STRING_LENGTH)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ uint32 register_mode(void)
|
|||
|
||||
}
|
||||
/* Transfer data expecting to encounter end of input (or an error) */
|
||||
inputBuffer = (char *) malloc (nbytes + 1); // Initial buffer size
|
||||
inputBuffer = (char *) safe_malloc (nbytes + 1); // Initial buffer size
|
||||
|
||||
readFlag = TRUE;
|
||||
while(readFlag) // Look for the start of the [header]
|
||||
|
|
@ -186,6 +186,7 @@ uint32 register_mode(void)
|
|||
if (numRead == -1)
|
||||
{
|
||||
output(ANSI_YELLOW"Error reading config file %s\n", cfg_file);
|
||||
safe_free(inputBuffer);
|
||||
return 999;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -140,3 +140,19 @@ void printIP(uint32 ip)
|
|||
output("%d.%d.%d.%d\n",((ip>>24)& 0xFF),((ip>>16)& 0xFF),((ip>>8)& 0xFF),(ip & 0xFF));
|
||||
}
|
||||
|
||||
void charReplace( char * string, char oldChar, char newChar )
|
||||
{
|
||||
if ( string == NULL ) {
|
||||
output("Null string passed to charReplace\n");
|
||||
return ;
|
||||
}
|
||||
|
||||
while (*string != 0 ) {
|
||||
if ( *string == oldChar )
|
||||
*string = newChar;
|
||||
|
||||
string++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,5 +45,6 @@ void lock_malloc_init(void);
|
|||
void* safe_malloc(size_t size);
|
||||
void safe_free(void* ptr);
|
||||
void printIP(uint32 ip);
|
||||
void charReplace( char * string, char oldChar, char newChar );
|
||||
|
||||
#endif /* UTILS_H_ */
|
||||
|
|
|
|||
Loading…
Reference in a new issue