mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-16 09:01:59 -05:00
Add retries to HRD send command mechanism.
It appears that the HRD logbook interferes with the HRD IP server causing it to fail to respond to pending commands. This enhancement adds a number of retries to the send command to HRD operation. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@4241 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
fbf58ae3f3
commit
bc0fdcf1d0
@ -701,6 +701,10 @@ QString HRDTransceiver::send_command (QString const& cmd, bool no_debug, bool pr
|
|||||||
|
|
||||||
auto context = '[' + QString::number (current_radio_) + "] ";
|
auto context = '[' + QString::number (current_radio_) + "] ";
|
||||||
|
|
||||||
|
unsigned retries {5};
|
||||||
|
bool replied {false};
|
||||||
|
while (!replied && --retries)
|
||||||
|
{
|
||||||
int bytes_to_send;
|
int bytes_to_send;
|
||||||
int bytes_sent;
|
int bytes_sent;
|
||||||
if (v4 == protocol_)
|
if (v4 == protocol_)
|
||||||
@ -729,20 +733,43 @@ QString HRDTransceiver::send_command (QString const& cmd, bool no_debug, bool pr
|
|||||||
|| QTcpSocket::ConnectedState != hrd_->state ())
|
|| QTcpSocket::ConnectedState != hrd_->state ())
|
||||||
{
|
{
|
||||||
#if WSJT_TRACE_CAT
|
#if WSJT_TRACE_CAT
|
||||||
qDebug () << "HRDTransceiver::send_command failed" << hrd_->errorString ();
|
qDebug () << "HRDTransceiver::send_command \"" << cmd << "\" failed" << hrd_->errorString ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
throw error {tr ("Ham Radio Deluxe send command failed\n") + hrd_->errorString ()};
|
throw error {
|
||||||
|
tr ("Ham Radio Deluxe send command \"%1\" failed %2\n")
|
||||||
|
.arg (cmd)
|
||||||
|
.arg (hrd_->errorString ())
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hrd_->waitForReadyRead (socket_wait_time))
|
replied = hrd_->waitForReadyRead (socket_wait_time);
|
||||||
|
if (!replied && hrd_->error () != hrd_->SocketTimeoutError)
|
||||||
{
|
{
|
||||||
#if WSJT_TRACE_CAT
|
#if WSJT_TRACE_CAT
|
||||||
qDebug () << "HRDTransceiver::send_command failed to reply" << hrd_->errorString ();
|
qDebug () << "HRDTransceiver::send_command \"" << cmd << "\" failed to reply" << hrd_->errorString ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
throw error {tr ("Ham Radio Deluxe failed to reply to command\n") + hrd_->errorString ()};
|
throw error {
|
||||||
|
tr ("Ham Radio Deluxe failed to reply to command \"%1\" %2\n")
|
||||||
|
.arg (cmd)
|
||||||
|
.arg (hrd_->errorString ())
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!replied)
|
||||||
|
{
|
||||||
|
#if WSJT_TRACE_CAT
|
||||||
|
qDebug () << "HRDTransceiver::send_command \"" << cmd << "\" retries exhausted";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
throw error {
|
||||||
|
tr ("Ham Radio Deluxe retries exhausted sending command \"%1\"")
|
||||||
|
.arg (cmd)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray buffer (hrd_->readAll ());
|
QByteArray buffer (hrd_->readAll ());
|
||||||
if (!no_debug)
|
if (!no_debug)
|
||||||
{
|
{
|
||||||
@ -762,10 +789,13 @@ QString HRDTransceiver::send_command (QString const& cmd, bool no_debug, bool pr
|
|||||||
if (reply->magic_1_value_ != reply->magic_1_ && reply->magic_2_value_ != reply->magic_2_)
|
if (reply->magic_1_value_ != reply->magic_1_ && reply->magic_2_value_ != reply->magic_2_)
|
||||||
{
|
{
|
||||||
#if WSJT_TRACE_CAT
|
#if WSJT_TRACE_CAT
|
||||||
qDebug () << "HRDTransceiver::send_command invalid reply";
|
qDebug () << "HRDTransceiver::send_command \"" << cmd << "\" invalid reply";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
throw error {tr ("Ham Radio Deluxe sent an invalid reply to our command")};
|
throw error {
|
||||||
|
tr ("Ham Radio Deluxe sent an invalid reply to our command \"%1\"")
|
||||||
|
.arg (cmd)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
result = QString {reply->payload_}; // this is not a memory leak (honest!)
|
result = QString {reply->payload_}; // this is not a memory leak (honest!)
|
||||||
@ -786,9 +816,12 @@ void HRDTransceiver::send_simple_command (QString const& command, bool no_debug)
|
|||||||
if ("OK" != send_command (command, no_debug))
|
if ("OK" != send_command (command, no_debug))
|
||||||
{
|
{
|
||||||
#if WSJT_TRACE_CAT
|
#if WSJT_TRACE_CAT
|
||||||
qDebug () << "HRDTransceiver::send_simple_command unexpected response";
|
qDebug () << "HRDTransceiver::send_simple_command \"" << command << "\" unexpected response";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
throw error {tr ("Ham Radio Deluxe didn't respond as expected")};
|
throw error {
|
||||||
|
tr ("Ham Radio Deluxe didn't respond to command \"%1\" as expected")
|
||||||
|
.arg (command)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user