mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2025-02-03 09:44:24 -05:00
Change recent HRD retry to only retry reply check.
Because of a possible Windows or Qt defect in TCP/IP received bytes detection it seems necessary to retry QTCPSocket::waitReadReady() blocking calls after a time out response as there may actually be data waiting. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@4256 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
90d92a47d7
commit
6f7fd45297
@ -701,48 +701,50 @@ QString HRDTransceiver::send_command (QString const& cmd, bool no_debug, bool pr
|
||||
|
||||
auto context = '[' + QString::number (current_radio_) + "] ";
|
||||
|
||||
int bytes_to_send;
|
||||
int bytes_sent;
|
||||
if (v4 == protocol_)
|
||||
{
|
||||
auto message = ((prepend_context ? context + cmd : cmd) + "\r").toLocal8Bit ();
|
||||
bytes_to_send = message.size ();
|
||||
bytes_sent = hrd_->write (message.data (), bytes_to_send);
|
||||
|
||||
if (!no_debug)
|
||||
{
|
||||
#if WSJT_TRACE_CAT
|
||||
qDebug () << "HRDTransceiver::send_command:" << message;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto string = prepend_context ? context + cmd : cmd;
|
||||
QScopedPointer<HRDMessage> message (new (string) HRDMessage);
|
||||
bytes_to_send = message->size_;
|
||||
bytes_sent = hrd_->write (reinterpret_cast<char *> (message.data ()), bytes_to_send);
|
||||
}
|
||||
|
||||
if (bytes_sent < bytes_to_send
|
||||
|| !hrd_->waitForBytesWritten (socket_wait_time)
|
||||
|| QTcpSocket::ConnectedState != hrd_->state ())
|
||||
{
|
||||
#if WSJT_TRACE_CAT
|
||||
qDebug () << "HRDTransceiver::send_command \"" << cmd << "\" failed" << hrd_->errorString ();
|
||||
#endif
|
||||
|
||||
throw error {
|
||||
tr ("Ham Radio Deluxe send command \"%1\" failed %2\n")
|
||||
.arg (cmd)
|
||||
.arg (hrd_->errorString ())
|
||||
};
|
||||
}
|
||||
|
||||
// waitForReadReady appears to be unreliable on Windows timing out
|
||||
// when data is waiting so retry a few times
|
||||
unsigned retries {5};
|
||||
bool replied {false};
|
||||
while (!replied && --retries)
|
||||
{
|
||||
int bytes_to_send;
|
||||
int bytes_sent;
|
||||
if (v4 == protocol_)
|
||||
{
|
||||
auto message = ((prepend_context ? context + cmd : cmd) + "\r").toLocal8Bit ();
|
||||
bytes_to_send = message.size ();
|
||||
bytes_sent = hrd_->write (message.data (), bytes_to_send);
|
||||
|
||||
if (!no_debug)
|
||||
{
|
||||
#if WSJT_TRACE_CAT
|
||||
qDebug () << "HRDTransceiver::send_command:" << message;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto string = prepend_context ? context + cmd : cmd;
|
||||
QScopedPointer<HRDMessage> message (new (string) HRDMessage);
|
||||
bytes_to_send = message->size_;
|
||||
bytes_sent = hrd_->write (reinterpret_cast<char *> (message.data ()), bytes_to_send);
|
||||
}
|
||||
|
||||
if (bytes_sent < bytes_to_send
|
||||
|| !hrd_->waitForBytesWritten (socket_wait_time)
|
||||
|| QTcpSocket::ConnectedState != hrd_->state ())
|
||||
{
|
||||
#if WSJT_TRACE_CAT
|
||||
qDebug () << "HRDTransceiver::send_command \"" << cmd << "\" failed" << hrd_->errorString ();
|
||||
#endif
|
||||
|
||||
throw error {
|
||||
tr ("Ham Radio Deluxe send command \"%1\" failed %2\n")
|
||||
.arg (cmd)
|
||||
.arg (hrd_->errorString ())
|
||||
};
|
||||
}
|
||||
|
||||
replied = hrd_->waitForReadyRead (socket_wait_time);
|
||||
if (!replied && hrd_->error () != hrd_->SocketTimeoutError)
|
||||
{
|
||||
|
@ -116,9 +116,9 @@ private:
|
||||
ModeMap mode_A_map_; // The map of modes available for VFO
|
||||
// A.
|
||||
|
||||
int mode_B_dropdown_; // The map of modes available for VFO
|
||||
// B. May be -1 if independent VFO
|
||||
// mode setting not available.
|
||||
int mode_B_dropdown_; // The drop down index for VFO B mode
|
||||
// setting. May be -1 if independent
|
||||
// VFO mode setting not available.
|
||||
|
||||
ModeMap mode_B_map_; // The map of modes for VFO B.
|
||||
|
||||
@ -126,8 +126,10 @@ private:
|
||||
// operation. May be -1 if no button
|
||||
// is available.
|
||||
|
||||
int split_mode_dropdown_; // The drop down list that allows
|
||||
// split mode to be turned on and off.
|
||||
int split_mode_dropdown_; // The drop down index that allows
|
||||
// split mode to be turned on and
|
||||
// off. May be -1 if no such drop down
|
||||
// exists.
|
||||
|
||||
bool split_mode_dropdown_write_only_; // Some rigs cannot report
|
||||
// split status.
|
||||
|
Loading…
Reference in New Issue
Block a user