minimodem: --tx SAME emits 16 sync-byte preamble
Emit a preamble of 16 (hardcoded) sync-bytes if --sync-byte is specified with --tx mode. This makes --tx SAME emit the required preamble of 16 0xAB's automatically. So --rx SAME now directly decodes the output of --tx SAME without needing to manually inject the preamble byte(s), simplifying the test case. Thanks to Harold Giddings, for reporting the issue.
This commit is contained in:
parent
24f1acff4f
commit
0140e0df12
|
@ -107,6 +107,8 @@ static void fsk_transmit_stdin(
|
|||
int n_data_bits,
|
||||
float bfsk_nstartbits,
|
||||
float bfsk_nstopbits,
|
||||
unsigned int bfsk_do_tx_sync_bytes,
|
||||
unsigned int bfsk_sync_byte,
|
||||
databits_encoder encode
|
||||
)
|
||||
{
|
||||
|
@ -141,16 +143,23 @@ static void fsk_transmit_stdin(
|
|||
// fprintf(stderr, "<c=%d>", c);
|
||||
unsigned int nwords;
|
||||
unsigned int bits[2];
|
||||
unsigned int j;
|
||||
nwords = encode(bits, c);
|
||||
|
||||
if ( !tx_transmitting )
|
||||
{
|
||||
tx_transmitting = 1;
|
||||
int j;
|
||||
/* emit leader tone (mark) */
|
||||
for ( j=0; j<tx_leader_bits_len; j++ )
|
||||
simpleaudio_tone(sa_out, bfsk_mark_f, bit_nsamples);
|
||||
/* emit "preamble" of sync bytes */
|
||||
for ( j=0; j<bfsk_do_tx_sync_bytes; j++ )
|
||||
fsk_transmit_frame(sa_out, bfsk_sync_byte, n_data_bits,
|
||||
bit_nsamples, bfsk_mark_f, bfsk_space_f,
|
||||
bfsk_nstartbits, bfsk_nstopbits);
|
||||
}
|
||||
unsigned int j;
|
||||
|
||||
/* emit data bits */
|
||||
for ( j=0; j<nwords; j++ )
|
||||
fsk_transmit_frame(sa_out, bits[j], n_data_bits,
|
||||
bit_nsamples, bfsk_mark_f, bfsk_space_f,
|
||||
|
@ -363,6 +372,7 @@ main( int argc, char*argv[] )
|
|||
int bfsk_nstartbits = -1;
|
||||
float bfsk_nstopbits = -1;
|
||||
unsigned int bfsk_do_rx_sync = 0;
|
||||
unsigned int bfsk_do_tx_sync_bytes = 0;
|
||||
unsigned int bfsk_sync_byte = -1;
|
||||
unsigned int bfsk_n_data_bits = 0;
|
||||
int autodetect_shift;
|
||||
|
@ -535,6 +545,7 @@ main( int argc, char*argv[] )
|
|||
break;
|
||||
case MINIMODEM_OPT_SYNC_BYTE:
|
||||
bfsk_do_rx_sync = 1;
|
||||
bfsk_do_tx_sync_bytes = 16;
|
||||
bfsk_sync_byte = strtol(optarg, NULL, 0);
|
||||
break;
|
||||
case 'q':
|
||||
|
@ -638,6 +649,7 @@ main( int argc, char*argv[] )
|
|||
bfsk_nstartbits = 0;
|
||||
bfsk_nstopbits = 0;
|
||||
bfsk_do_rx_sync = 1;
|
||||
bfsk_do_tx_sync_bytes = 16;
|
||||
bfsk_sync_byte = 0xAB;
|
||||
bfsk_mark_f = 2083.0 + 1/3.0;
|
||||
bfsk_space_f = 1562.5;
|
||||
|
@ -757,6 +769,8 @@ main( int argc, char*argv[] )
|
|||
bfsk_n_data_bits,
|
||||
bfsk_nstartbits,
|
||||
bfsk_nstopbits,
|
||||
bfsk_do_tx_sync_bytes,
|
||||
bfsk_sync_byte,
|
||||
bfsk_databits_encode
|
||||
);
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
exec ./self-test testdata-ascii.txt SAME
|
|
@ -1,55 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
MINIMODEM="${MINIMODEM-./minimodem}"
|
||||
[ -f "$MINIMODEM" ] || {
|
||||
MINIMODEM="../src/minimodem"
|
||||
[ -f "$MINIMODEM" ] || {
|
||||
echo "E: cannot find minimodem in ./ or ../src/" 1>&2
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
teststring="Testing 0 1 2 3 4. This is only a test. Testing 5 6 7 8 9. This is only a test."
|
||||
[ "$1" != "" ] && teststring="$1"
|
||||
|
||||
|
||||
TMPF="/tmp/minimodem-test-$$"
|
||||
trap "rm -f $TMPF.*" 0
|
||||
|
||||
set -e
|
||||
|
||||
minimodem_tx_args="SAME"
|
||||
minimodem_rx_args="SAME"
|
||||
|
||||
|
||||
# insert the 0xAB SAME sync byte to simulate the start of a SAME
|
||||
# protocol bytestream.
|
||||
printf "JUNK\\xAB${teststring}" \
|
||||
| $MINIMODEM --tx --file $TMPF.wav $minimodem_tx_args
|
||||
|
||||
# cp $TMPF.wav /tmp/x.wav
|
||||
|
||||
$MINIMODEM --rx --file $TMPF.wav $minimodem_rx_args \
|
||||
> $TMPF.out 2> $TMPF.err || {
|
||||
cat $TMPF.err
|
||||
exit 1
|
||||
}
|
||||
|
||||
# printf "$teststring" | cmp - $TMPF.out
|
||||
printf "$teststring" | diff - $TMPF.out
|
||||
|
||||
{
|
||||
read xlitcarrier
|
||||
read xlitblankline
|
||||
read xlithashes xlitnocarrier stats
|
||||
stats="${stats% ###}"
|
||||
} < $TMPF.err
|
||||
|
||||
|
||||
result="OK "
|
||||
exitcode=0
|
||||
|
||||
echo -e "$result $stats"
|
||||
|
||||
exit $exitcode
|
Loading…
Reference in New Issue