minimodem: --rx prints all bytes unmolested, unless --print-filter
Now, minimodem prints all received bytes without isprint() filtering, unless --print-filter is specified. Allows for binary file transfers and multibyte characters.
This commit is contained in:
parent
ead6952a58
commit
49ccd10e1f
|
@ -136,6 +136,11 @@ The bits are printed in the order they are received. Framing bits (start
|
||||||
and stop bits) are omitted from the output.
|
and stop bits) are omitted from the output.
|
||||||
(This option applies to \-\-rx mode only).
|
(This option applies to \-\-rx mode only).
|
||||||
.TP
|
.TP
|
||||||
|
.B \-\-print-filter
|
||||||
|
Filter the received text output, replacing any "non-printable" bytes
|
||||||
|
with a '.' character.
|
||||||
|
(This option applies to \-\-rx mode only).
|
||||||
|
.TP
|
||||||
.B \-\-benchmarks
|
.B \-\-benchmarks
|
||||||
Run and report internal performance tests (all other flags are ignored).
|
Run and report internal performance tests (all other flags are ignored).
|
||||||
.TP
|
.TP
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -311,6 +312,7 @@ usage()
|
||||||
" --rx-one\n"
|
" --rx-one\n"
|
||||||
" --benchmarks\n"
|
" --benchmarks\n"
|
||||||
" --binary-output\n"
|
" --binary-output\n"
|
||||||
|
" --print-filter\n"
|
||||||
" {baudmode}\n"
|
" {baudmode}\n"
|
||||||
" any_number_N Bell-like N bps --ascii\n"
|
" any_number_N Bell-like N bps --ascii\n"
|
||||||
" 1200 Bell202 1200 bps --ascii\n"
|
" 1200 Bell202 1200 bps --ascii\n"
|
||||||
|
@ -327,6 +329,7 @@ main( int argc, char*argv[] )
|
||||||
char *modem_mode = NULL;
|
char *modem_mode = NULL;
|
||||||
int TX_mode = -1;
|
int TX_mode = -1;
|
||||||
int quiet_mode = 0;
|
int quiet_mode = 0;
|
||||||
|
int output_print_filter = 0;
|
||||||
float band_width = 0;
|
float band_width = 0;
|
||||||
unsigned int bfsk_mark_f = 0;
|
unsigned int bfsk_mark_f = 0;
|
||||||
unsigned int bfsk_space_f = 0;
|
unsigned int bfsk_space_f = 0;
|
||||||
|
@ -397,6 +400,7 @@ main( int argc, char*argv[] )
|
||||||
MINIMODEM_OPT_RX_ONE,
|
MINIMODEM_OPT_RX_ONE,
|
||||||
MINIMODEM_OPT_BENCHMARKS,
|
MINIMODEM_OPT_BENCHMARKS,
|
||||||
MINIMODEM_OPT_BINARY_OUTPUT,
|
MINIMODEM_OPT_BINARY_OUTPUT,
|
||||||
|
MINIMODEM_OPT_PRINT_FILTER,
|
||||||
MINIMODEM_OPT_XRXNOISE,
|
MINIMODEM_OPT_XRXNOISE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -431,6 +435,7 @@ main( int argc, char*argv[] )
|
||||||
{ "rx-one", 0, 0, MINIMODEM_OPT_RX_ONE },
|
{ "rx-one", 0, 0, MINIMODEM_OPT_RX_ONE },
|
||||||
{ "benchmarks", 0, 0, MINIMODEM_OPT_BENCHMARKS },
|
{ "benchmarks", 0, 0, MINIMODEM_OPT_BENCHMARKS },
|
||||||
{ "binary-output", 0, 0, MINIMODEM_OPT_BINARY_OUTPUT },
|
{ "binary-output", 0, 0, MINIMODEM_OPT_BINARY_OUTPUT },
|
||||||
|
{ "print-filter", 0, 0, MINIMODEM_OPT_PRINT_FILTER },
|
||||||
{ "Xrxnoise", 1, 0, MINIMODEM_OPT_XRXNOISE },
|
{ "Xrxnoise", 1, 0, MINIMODEM_OPT_XRXNOISE },
|
||||||
{ 0 }
|
{ 0 }
|
||||||
};
|
};
|
||||||
|
@ -537,6 +542,9 @@ main( int argc, char*argv[] )
|
||||||
case MINIMODEM_OPT_BINARY_OUTPUT:
|
case MINIMODEM_OPT_BINARY_OUTPUT:
|
||||||
output_mode_binary = 1;
|
output_mode_binary = 1;
|
||||||
break;
|
break;
|
||||||
|
case MINIMODEM_OPT_PRINT_FILTER:
|
||||||
|
output_print_filter = 1;
|
||||||
|
break;
|
||||||
case MINIMODEM_OPT_XRXNOISE:
|
case MINIMODEM_OPT_XRXNOISE:
|
||||||
rxnoise_factor = atof(optarg);
|
rxnoise_factor = atof(optarg);
|
||||||
break;
|
break;
|
||||||
|
@ -1148,16 +1156,22 @@ main( int argc, char*argv[] )
|
||||||
dataout_size - dataout_nbytes,
|
dataout_size - dataout_nbytes,
|
||||||
bits, (int)bfsk_n_data_bits);
|
bits, (int)bfsk_n_data_bits);
|
||||||
|
|
||||||
|
if ( dataout_nbytes == 0 )
|
||||||
|
continue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Print the output buffer to stdout
|
* Print the output buffer to stdout
|
||||||
*/
|
*/
|
||||||
if ( dataout_nbytes ) {
|
if ( output_print_filter == 0 ) {
|
||||||
|
if ( write(1, dataoutbuf, dataout_nbytes) < 0 )
|
||||||
|
perror("write");
|
||||||
|
} else {
|
||||||
char *p = dataoutbuf;
|
char *p = dataoutbuf;
|
||||||
for ( ; dataout_nbytes; p++,dataout_nbytes-- ) {
|
for ( ; dataout_nbytes; p++,dataout_nbytes-- ) {
|
||||||
char printable_char = isprint(*p)||isspace(*p) ? *p : '.';
|
char printable_char = isprint(*p)||isspace(*p) ? *p : '.';
|
||||||
printf( "%c", printable_char );
|
if ( write(1, &printable_char, 1) < 0 )
|
||||||
|
perror("write");
|
||||||
}
|
}
|
||||||
fflush(stdout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* end of the main loop */
|
} /* end of the main loop */
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
exec ./self-test testdata-multibyte.txt 1200
|
|
@ -0,0 +1,4 @@
|
||||||
|
Minimodem unterstützt jetzt Deutsch!
|
||||||
|
Beachten sie, dass wörter mit multibyte-zeichen korrekt gedruckt werden.
|
||||||
|
Minimodem ahora soporta Español!
|
||||||
|
Minimodem prend désormais en Français!
|
Loading…
Reference in New Issue