From 0140e0df1260e6ccc3b437fe80bdaed73f5263cd Mon Sep 17 00:00:00 2001 From: Kamal Mostafa Date: Sat, 8 Jun 2013 10:16:56 -0700 Subject: [PATCH] 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. --- src/minimodem.c | 18 ++++++++++-- tests/test-80-SAME | 1 + tests/test-80-SAME-datastream | 55 ----------------------------------- 3 files changed, 17 insertions(+), 57 deletions(-) create mode 100755 tests/test-80-SAME delete mode 100755 tests/test-80-SAME-datastream diff --git a/src/minimodem.c b/src/minimodem.c index 192c230..e1cb167 100644 --- a/src/minimodem.c +++ b/src/minimodem.c @@ -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); 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&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