From 51db482d9a1f2f64a9d1246711527abf77ce5a86 Mon Sep 17 00:00:00 2001 From: John Phelps Date: Wed, 31 Oct 2012 20:55:39 -0500 Subject: [PATCH] Allow xmit of EOT character * Still retains use of " ^r " in the user window * Covers special-case for FLARQ usage where ETX should stop the modem * EOT character can now be transmitted from Tx window instead of switching to Rx mode * From: Andrej Lajovic - Substitute symbolic names for negative return values of get_tx_char() --- src/blank/blank.cxx | 4 ++-- src/contestia/contestia.cxx | 6 ++--- src/cw_rtty/cw.cxx | 2 +- src/cw_rtty/rtty.cxx | 4 ++-- src/dialogs/fl_digi.cxx | 45 ++++++++++++++++++++++--------------- src/dominoex/dominoex.cxx | 4 ++-- src/feld/feld.cxx | 4 ++-- src/include/fl_digi.h | 8 +++++++ src/mfsk/mfsk.cxx | 4 ++-- src/mt63/mt63.cxx | 4 ++-- src/navtex/navtex.cxx | 2 +- src/olivia/olivia.cxx | 7 +++--- src/packet/pkt.cxx | 2 +- src/psk/psk.cxx | 4 ++-- src/thor/thor.cxx | 4 ++-- src/throb/throb.cxx | 4 ++-- src/trx/nullmodem.cxx | 3 ++- src/wwv/wwv.cxx | 2 +- 18 files changed, 65 insertions(+), 48 deletions(-) diff --git a/src/blank/blank.cxx b/src/blank/blank.cxx index d2a83c63..1c779a7b 100644 --- a/src/blank/blank.cxx +++ b/src/blank/blank.cxx @@ -204,9 +204,9 @@ int xmtbyte; case TX_STATE_DATA: xmtbyte = get_tx_char(); - if (xmtbyte == -1) + if (xmtbyte == GET_TX_CHAR_NODATA) sendidle(); - else if ( xmtbyte == 0x03 || stopflag) + else if ( xmtbyte == GET_TX_CHAR_ETX || stopflag) txstate = TX_STATE_FLUSH; else sendchar(xmtbyte); diff --git a/src/contestia/contestia.cxx b/src/contestia/contestia.cxx index 3e679702..39e91312 100644 --- a/src/contestia/contestia.cxx +++ b/src/contestia/contestia.cxx @@ -160,14 +160,14 @@ int contestia::tx_process() // to read any more. If stopflag is set, we will always read // whatever there is. if (stopflag || (Tx->GetReadReady() < Tx->BitsPerSymbol)) { - if (!stopflag && (c = get_tx_char()) == 0x03) + if (!stopflag && (c = get_tx_char()) == GET_TX_CHAR_ETX) stopflag = true; if (stopflag) Tx->Stop(); else { + if (c == GET_TX_CHAR_NODATA) + c = 0; /* Replace un-representable characters with a dot */ - if (c == -1) - c = 0; if (c > (progdefaults.contestia8bit ? 255 : 127)) c = '.'; if (c > 127) { diff --git a/src/cw_rtty/cw.cxx b/src/cw_rtty/cw.cxx index befb9d92..194efab6 100644 --- a/src/cw_rtty/cw.cxx +++ b/src/cw_rtty/cw.cxx @@ -1169,7 +1169,7 @@ int cw::tx_process() } c = get_tx_char(); - if (c == 0x03 || stopflag) { + if (c == GET_TX_CHAR_ETX || stopflag) { send_symbol(0, symbollen); stopflag = false; return -1; diff --git a/src/cw_rtty/rtty.cxx b/src/cw_rtty/rtty.cxx index 211e7d7c..7a16e2ae 100644 --- a/src/cw_rtty/rtty.cxx +++ b/src/cw_rtty/rtty.cxx @@ -762,7 +762,7 @@ int rtty::tx_process() c = get_tx_char(); // TX buffer empty - if (c == 3 || stopflag) { + if (c == GET_TX_CHAR_ETX || stopflag) { stopflag = false; line_char_count = 0; if (nbits != 5) { @@ -780,7 +780,7 @@ int rtty::tx_process() } // send idle character if c == -1 - if (c == -1) { + if (c == GET_TX_CHAR_NODATA) { send_idle(); return 0; } diff --git a/src/dialogs/fl_digi.cxx b/src/dialogs/fl_digi.cxx index 24d1c80d..e7ad9eec 100644 --- a/src/dialogs/fl_digi.cxx +++ b/src/dialogs/fl_digi.cxx @@ -6353,14 +6353,21 @@ int get_tx_char(void) enum { STATE_CHAR, STATE_CTRL }; static int state = STATE_CHAR; - if (!que_ok) { return -1; } - if (Qwait_time) { return -1; } - if (Qidle_time) { return -1; } - if (macro_idle_on) { return -1; } - if (idling) { return -1; } - - if (arq_text_available) - return (arq_get_char() & 0xFF); + if (!que_ok) { return GET_TX_CHAR_NODATA; } + if (Qwait_time) { return GET_TX_CHAR_NODATA; } + if (Qidle_time) { return GET_TX_CHAR_NODATA; } + if (macro_idle_on) { return GET_TX_CHAR_NODATA; } + if (idling) { return GET_TX_CHAR_NODATA; } + + if (arq_text_available) { + char character = (arq_get_char() & 0xFF); + if (character == 0x03) { + // ETX (0x03) in ARQ data means "stop transmitting" not "send ETX" + return(GET_TX_CHAR_ETX); + } + else + return(character); + } if (active_modem == cw_modem && progdefaults.QSKadjust) return szTestChar[2 * progdefaults.TestChar]; @@ -6369,7 +6376,7 @@ int get_tx_char(void) !idling ) { Fl::add_timeout(progStatus.repeatIdleTime, get_tx_char_idle); idling = true; - return -1; + return GET_TX_CHAR_NODATA; } int c; @@ -6398,7 +6405,7 @@ int get_tx_char(void) if (c == -1) { queue_reset(); - return(-1); + return(GET_TX_CHAR_NODATA); } if (state == STATE_CTRL) { @@ -6407,33 +6414,33 @@ int get_tx_char(void) switch (c) { case 'r': REQ_SYNC(&FTextTX::clear_sent, TransmitText); - return(3); // ETX + return(GET_TX_CHAR_ETX); break; case 'R': if (TransmitText->eot()) { REQ_SYNC(&FTextTX::clear_sent, TransmitText); - return(3); // ETX + return(GET_TX_CHAR_ETX); } else - return(-1); + return(GET_TX_CHAR_NODATA); break; case 'L': REQ(qso_save_now); - return(-1); + return(GET_TX_CHAR_NODATA); break; case 'C': REQ(clearQSO); - return(-1); + return(GET_TX_CHAR_NODATA); break; case '!': if (queue_must_rx()) { que_timeout = 400; // 20 seconds REQ(queue_execute_after_rx, (void *)0); while(que_waiting) MilliSleep(1); - return(3); + return(GET_TX_CHAR_ETX); } else { REQ(do_que_execute, (void*)0); while(que_waiting) MilliSleep(1); - return(-1); + return(GET_TX_CHAR_NODATA); } break; default: @@ -6454,8 +6461,10 @@ int get_tx_char(void) transmit: c = tx_encoder.pop(); - if (c == -1) + if (c == -1) { LOG_ERROR("TX encoding conversion error: pushed content, but got nothing back"); + return(GET_TX_CHAR_NODATA); + } return(c); } diff --git a/src/dominoex/dominoex.cxx b/src/dominoex/dominoex.cxx index fae18150..7f95d056 100644 --- a/src/dominoex/dominoex.cxx +++ b/src/dominoex/dominoex.cxx @@ -720,9 +720,9 @@ int dominoex::tx_process() break; case TX_STATE_DATA: i = get_tx_char(); - if (i == -1) + if (i == GET_TX_CHAR_NODATA) sendsecondary(); - else if (i == 3) + else if (i == GET_TX_CHAR_ETX) txstate = TX_STATE_END; else sendchar(i, 0); diff --git a/src/feld/feld.cxx b/src/feld/feld.cxx index 7eb2338e..72231c89 100644 --- a/src/feld/feld.cxx +++ b/src/feld/feld.cxx @@ -575,7 +575,7 @@ int feld::tx_process() c = get_tx_char(); - if (c == 0x03 || stopflag) { + if (c == GET_TX_CHAR_ETX || stopflag) { tx_state = POSTAMBLE; postamble = 3; return 0; @@ -583,7 +583,7 @@ int feld::tx_process() // if TX buffer empty // send idle character - if (c == -1) { + if (c == GET_TX_CHAR_NODATA) { if (progdefaults.HellXmtIdle == true) c = '.'; else { diff --git a/src/include/fl_digi.h b/src/include/fl_digi.h index adb58a52..528522ac 100644 --- a/src/include/fl_digi.h +++ b/src/include/fl_digi.h @@ -236,6 +236,14 @@ extern void queue_execute_after_rx(void*); extern int rxtx_charset; extern void put_rx_data(int *data, int len); + +// Values returned by get_tx_char() to signal various conditions to the +// modems. These values need to be negative so they don't interfere with +// normal TX data (which is always byte-sized and positive). + +#define GET_TX_CHAR_NODATA -1 // no data available +#define GET_TX_CHAR_ETX -3 // end of transmission requested + extern int get_tx_char(); extern int get_secondary_char(); extern void put_echo_char(unsigned int data, int style = FTextBase::XMIT); diff --git a/src/mfsk/mfsk.cxx b/src/mfsk/mfsk.cxx index af3a6816..ce75b058 100644 --- a/src/mfsk/mfsk.cxx +++ b/src/mfsk/mfsk.cxx @@ -914,9 +914,9 @@ int mfsk::tx_process() startpic = false; txstate = TX_STATE_PICTURE_START; } - else if ( xmtbyte == 0x03 || stopflag) + else if ( xmtbyte == GET_TX_CHAR_ETX || stopflag) txstate = TX_STATE_FLUSH; - else if (xmtbyte == -1) + else if (xmtbyte == GET_TX_CHAR_NODATA) sendidle(); else sendchar(xmtbyte); diff --git a/src/mt63/mt63.cxx b/src/mt63/mt63.cxx index 9646d08c..bbd01a02 100644 --- a/src/mt63/mt63.cxx +++ b/src/mt63/mt63.cxx @@ -76,12 +76,12 @@ int mt63::tx_process() } c = get_tx_char(); - if (c == 0x03) { + if (c == GET_TX_CHAR_ETX) { stopflag = true; flush = Tx->DataInterleave; } - if (c == -1 || stopflag == true) c = 0; + if (c == GET_TX_CHAR_NODATA || stopflag == true) c = 0; if (stopflag) { stopflag = false; diff --git a/src/navtex/navtex.cxx b/src/navtex/navtex.cxx index 5c419255..7e1548e3 100644 --- a/src/navtex/navtex.cxx +++ b/src/navtex/navtex.cxx @@ -1586,7 +1586,7 @@ public: for(;;) { int c = get_tx_char(); - if( c == -1 ) { + if( c == GET_TX_CHAR_NODATA ) { break ; } msg.push_back( c ); diff --git a/src/olivia/olivia.cxx b/src/olivia/olivia.cxx index 117e7dac..b228025b 100755 --- a/src/olivia/olivia.cxx +++ b/src/olivia/olivia.cxx @@ -161,12 +161,12 @@ int olivia::tx_process() // whatever there is. if (stopflag || (Tx->GetReadReady() < Tx->BitsPerSymbol)) { - if (!stopflag && (c = get_tx_char()) == 0x03) + if (!stopflag && (c = get_tx_char()) == GET_TX_CHAR_ETX) stopflag = true; if (stopflag) Tx->Stop(); else { - if (c == -1) + if (c == GET_TX_CHAR_NODATA) c = 0; if (c > 127) { if (progdefaults.olivia8bit && c <= 255) { @@ -183,9 +183,8 @@ int olivia::tx_process() } } - if (c != 0 && c != 0x03) { + if (c > 0) put_echo_char(c); - } if ((len = Tx->Output(txfbuffer)) > 0) ModulateXmtr(txfbuffer, len); diff --git a/src/packet/pkt.cxx b/src/packet/pkt.cxx index 9d716a63..9eed81a9 100644 --- a/src/packet/pkt.cxx +++ b/src/packet/pkt.cxx @@ -2304,7 +2304,7 @@ int pkt::tx_process() // TX buffer empty // if (c == 0x03 || stopflag) { - if (c == -1 || stopflag || tx_char_count == 0) { + if (c == GET_TX_CHAR_ETX || stopflag || tx_char_count == 0) { if (!stopflag) { // compute FCS and add it to the frame via *tx_cbuf unsigned int fcs = computeFCS(&txbuf[0], tx_cbuf); diff --git a/src/psk/psk.cxx b/src/psk/psk.cxx index 74c02a4f..08f0abbc 100644 --- a/src/psk/psk.cxx +++ b/src/psk/psk.cxx @@ -1081,14 +1081,14 @@ int psk::tx_process() c = get_tx_char(); - if (c == 0x03 || stopflag) { + if (c == GET_TX_CHAR_ETX || stopflag) { tx_flush(); stopflag = false; cwid(); return -1; // we're done } - if (c == -1) { + if (c == GET_TX_CHAR_NODATA) { if (_pskr) { // MFSK varicode instead of psk tx_char(0); // diff --git a/src/thor/thor.cxx b/src/thor/thor.cxx index c227dd82..ddab8be7 100644 --- a/src/thor/thor.cxx +++ b/src/thor/thor.cxx @@ -869,9 +869,9 @@ int thor::tx_process() break; case TX_STATE_DATA: i = get_tx_char(); - if (i == -1) + if (i == GET_TX_CHAR_NODATA) sendsecondary(); - else if (i == 3) + else if (i == GET_TX_CHAR_ETX) txstate = TX_STATE_END; else sendchar(i, 0); diff --git a/src/throb/throb.cxx b/src/throb/throb.cxx index 0ee32b96..2bc96049 100644 --- a/src/throb/throb.cxx +++ b/src/throb/throb.cxx @@ -621,7 +621,7 @@ int throb::tx_process() c = get_tx_char(); // end of transmission - if (c == 0x03 || stopflag) { + if (c == GET_TX_CHAR_ETX || stopflag) { send(idlesym); // reset_syms(); //prepare RX. idle/space syms always start as 0 and 1, respectively. cwid(); @@ -629,7 +629,7 @@ int throb::tx_process() } // TX buffer empty - if (c == -1) { + if (c == GET_TX_CHAR_NODATA) { send(idlesym); /* send idle throbs */ flip_syms(); return 0; diff --git a/src/trx/nullmodem.cxx b/src/trx/nullmodem.cxx index d983cb7f..8a545cc4 100644 --- a/src/trx/nullmodem.cxx +++ b/src/trx/nullmodem.cxx @@ -85,7 +85,8 @@ int NULLMODEM::rx_process(const double *buf, int len) int NULLMODEM::tx_process() { - if ( get_tx_char() == 0x03 || stopflag) { + MilliSleep(10); + if ( get_tx_char() == GET_TX_CHAR_ETX || stopflag) { stopflag = false; return -1; } diff --git a/src/wwv/wwv.cxx b/src/wwv/wwv.cxx index 284b736a..ed13c683 100644 --- a/src/wwv/wwv.cxx +++ b/src/wwv/wwv.cxx @@ -202,7 +202,7 @@ int wwv::tx_process() static int cycle = 4; int c = get_tx_char(); - if (c == 0x03 || stopflag) { + if (c == GET_TX_CHAR_ETX || stopflag) { stopflag = false; return -1; }