kopia lustrzana https://github.com/Hamlib/Hamlib
Merge pull request #739 from cjritola/fixesJuly2021
Use loop to ensure RS-HFIQ hears first command. Closes #738pull/750/head
commit
b7f4722603
|
@ -36,6 +36,7 @@
|
||||||
#include "hamlib/rig.h"
|
#include "hamlib/rig.h"
|
||||||
#include "serial.h"
|
#include "serial.h"
|
||||||
|
|
||||||
|
#define RSHFIQ_INIT_RETRY 5
|
||||||
|
|
||||||
static int rshfiq_open(RIG *rig)
|
static int rshfiq_open(RIG *rig)
|
||||||
{
|
{
|
||||||
|
@ -79,36 +80,28 @@ static int rshfiq_open(RIG *rig)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//There is a delay between when the port is open and the RS-HFIQ can receive and respond.
|
||||||
|
//Make a few attempts at getting the version string just in case the RS-HFIQ has to catch up first.
|
||||||
|
retval = -RIG_ETIMEOUT;
|
||||||
|
for (int init_retry_count = 0; (init_retry_count < RSHFIQ_INIT_RETRY) && (retval == -RIG_ETIMEOUT); init_retry_count++)
|
||||||
|
{
|
||||||
rig_flush(&rig->state.rigport);
|
rig_flush(&rig->state.rigport);
|
||||||
|
|
||||||
snprintf(versionstr, sizeof(versionstr), "*w\r");
|
snprintf(versionstr, sizeof(versionstr), "*w\r");
|
||||||
rig_debug(RIG_DEBUG_TRACE, "%s: cmdstr = %s\n", __func__, versionstr);
|
rig_debug(RIG_DEBUG_TRACE, "%s: cmdstr = %s\n", __func__, versionstr);
|
||||||
retval = write_block(&rig->state.rigport, versionstr, strlen(versionstr));
|
retval = write_block(&rig->state.rigport, versionstr, strlen(versionstr));
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
{
|
{
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = read_string(&rig->state.rigport, versionstr, 20, stopset, 2);
|
retval = read_string(&rig->state.rigport, versionstr, 20, stopset, 2);
|
||||||
|
|
||||||
if (retval <= 0)
|
|
||||||
{
|
|
||||||
// Just one retry if the arduino is just booting
|
|
||||||
retval = write_block(&rig->state.rigport, versionstr, strlen(versionstr));
|
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
|
||||||
{
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = read_string(&rig->state.rigport, versionstr, 20, stopset, 2);
|
|
||||||
|
|
||||||
if (retval <= 0)
|
if (retval <= 0)
|
||||||
{
|
{
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
rig_flush(&rig->state.rigport);
|
||||||
|
|
||||||
versionstr[retval] = 0;
|
versionstr[retval] = 0;
|
||||||
rig_debug(RIG_DEBUG_TRACE, "%s: Rigversion = %s\n", __func__, versionstr);
|
rig_debug(RIG_DEBUG_TRACE, "%s: Rigversion = %s\n", __func__, versionstr);
|
||||||
|
|
Ładowanie…
Reference in New Issue