From b2c4bbf7f86057028542d9325b3a0a02cc7af3ee Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Tue, 8 Jun 2021 08:58:11 -0700 Subject: [PATCH] Better baud rate management for LAN-connected radios. --- wfmain.cpp | 25 ++++++++++++++++++++----- wfmain.h | 2 +- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index 50b674c..4c8367a 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -847,16 +847,22 @@ void wfmain::receiveCommReady() } } - -void wfmain::receiveFoundRigID(rigCapabilities rigCaps) +void wfmain::calculateTimingParameters() { - // Entry point for unknown rig being identified at the start of the program. - //now we know what the rig ID is: - //qInfo(logSystem()) << "In wfview, we now have a reply to our request for rig identity sent to CIV BROADCAST."; + // Function for calculating polling parameters. + // Requires that we know the "baud rate" of the actual + // radio connection. // baud on the serial port reflects the actual rig connection, // even if a client-server connection is being used. // Computed time for a 10 byte message, with a safety factor of 2. + + if (prefs.serialPortBaud == 0) + { + prefs.serialPortBaud = 9600; + qInfo(logSystem()) << "WARNING: baud rate received was zero. Assuming 9600 baud, performance may suffer."; + } + unsigned int usPerByte = 9600*1000 / prefs.serialPortBaud; unsigned int msMinTiming=usPerByte * 10*2/1000; if(msMinTiming < 35) @@ -874,6 +880,14 @@ void wfmain::receiveFoundRigID(rigCapabilities rigCaps) // startup initial state: delayedCmdStartupInterval_ms = msMinTiming * 2; +} + + +void wfmain::receiveFoundRigID(rigCapabilities rigCaps) +{ + // Entry point for unknown rig being identified at the start of the program. + //now we know what the rig ID is: + //qInfo(logSystem()) << "In wfview, we now have a reply to our request for rig identity sent to CIV BROADCAST."; if(rig->usingLAN()) { @@ -4135,6 +4149,7 @@ void wfmain::receiveBaudRate(quint32 baud) { qInfo() << "Received serial port baud rate from remote server:" << baud; prefs.serialPortBaud = baud; + calculateTimingParameters(); } void wfmain::on_rigPowerOnBtn_clicked() diff --git a/wfmain.h b/wfmain.h index 06c1f34..4cfe241 100644 --- a/wfmain.h +++ b/wfmain.h @@ -649,7 +649,7 @@ private: void initPeriodicCommands(); void insertPeriodicCommand(cmds cmd, unsigned char priority); - + void calculateTimingParameters(); void changeMode(mode_kind mode); void changeMode(mode_kind mode, bool dataOn);