mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2025-05-29 04:42:28 -04: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
7e2cf9b9e6
commit
e8e5ffefe9
@ -701,48 +701,50 @@ QString HRDTransceiver::send_command (QString const& cmd, bool no_debug, bool pr
|
|||||||
|
|
||||||
auto context = '[' + QString::number (current_radio_) + "] ";
|
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};
|
unsigned retries {5};
|
||||||
bool replied {false};
|
bool replied {false};
|
||||||
while (!replied && --retries)
|
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);
|
replied = hrd_->waitForReadyRead (socket_wait_time);
|
||||||
if (!replied && hrd_->error () != hrd_->SocketTimeoutError)
|
if (!replied && hrd_->error () != hrd_->SocketTimeoutError)
|
||||||
{
|
{
|
||||||
|
@ -116,9 +116,9 @@ private:
|
|||||||
ModeMap mode_A_map_; // The map of modes available for VFO
|
ModeMap mode_A_map_; // The map of modes available for VFO
|
||||||
// A.
|
// A.
|
||||||
|
|
||||||
int mode_B_dropdown_; // The map of modes available for VFO
|
int mode_B_dropdown_; // The drop down index for VFO B mode
|
||||||
// B. May be -1 if independent VFO
|
// setting. May be -1 if independent
|
||||||
// mode setting not available.
|
// VFO mode setting not available.
|
||||||
|
|
||||||
ModeMap mode_B_map_; // The map of modes for VFO B.
|
ModeMap mode_B_map_; // The map of modes for VFO B.
|
||||||
|
|
||||||
@ -126,8 +126,10 @@ private:
|
|||||||
// operation. May be -1 if no button
|
// operation. May be -1 if no button
|
||||||
// is available.
|
// is available.
|
||||||
|
|
||||||
int split_mode_dropdown_; // The drop down list that allows
|
int split_mode_dropdown_; // The drop down index that allows
|
||||||
// split mode to be turned on and off.
|
// 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
|
bool split_mode_dropdown_write_only_; // Some rigs cannot report
|
||||||
// split status.
|
// split status.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user