Baud rate calculations are now only happening when baud rate is received

and reasonable.
merge-requests/5/head
Elliott Liggett 2021-06-08 09:18:40 -07:00
rodzic c6f55f34e7
commit 857286dae2
2 zmienionych plików z 37 dodań i 22 usunięć

Wyświetl plik

@ -476,27 +476,6 @@ void wfmain::receiveFoundRigID(rigCapabilities rigCaps)
//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.";
// 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.
unsigned int usPerByte = 9600*1000 / prefs.serialPortBaud;
unsigned int msMinTiming=usPerByte * 10*2/1000;
if(msMinTiming < 35)
msMinTiming = 35;
delayedCommand->setInterval( msMinTiming * 2); // 20 byte message
periodicPollingTimer->setInterval( msMinTiming ); // slower for s-meter poll
qInfo(logSystem()) << "Delay command interval timing: " << msMinTiming * 2 << "ms";
qInfo(logSystem()) << "Periodic polling timer: " << msMinTiming << "ms";
// Normal:
delayedCmdIntervalLAN_ms = msMinTiming * 2;
delayedCmdIntervalSerial_ms = msMinTiming * 2;
// startup initial state:
delayedCmdStartupInterval_ms = msMinTiming * 2;
if(rig->usingLAN())
{
usingLAN = true;
@ -4337,10 +4316,46 @@ void wfmain::receiveSpectrumSpan(freqt freqspan, bool isSub)
}
}
void wfmain::calculateTimingParameters()
{
// 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)
msMinTiming = 35;
delayedCommand->setInterval( msMinTiming * 2); // 20 byte message
periodicPollingTimer->setInterval( msMinTiming ); // slower for s-meter poll
qInfo(logSystem()) << "Delay command interval timing: " << msMinTiming * 2 << "ms";
qInfo(logSystem()) << "Periodic polling timer: " << msMinTiming << "ms";
// Normal:
delayedCmdIntervalLAN_ms = msMinTiming * 2;
delayedCmdIntervalSerial_ms = msMinTiming * 2;
// startup initial state:
delayedCmdStartupInterval_ms = msMinTiming * 2;
}
void wfmain::receiveBaudRate(quint32 baud)
{
qInfo() << "Received serial port baud rate from remote server:" << baud;
prefs.serialPortBaud = baud;
calculateTimingParameters();
}
void wfmain::on_rigPowerOnBtn_clicked()

Wyświetl plik

@ -672,7 +672,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);