kopia lustrzana https://github.com/Hamlib/Hamlib
Fix CW morse infinite loop when error occurs RIG_EINVAL
rodzic
d57e4ae185
commit
af86f44eac
|
@ -6933,21 +6933,39 @@ int newcat_send_morse(RIG *rig, vfo_t vfo, const char *msg)
|
|||
{
|
||||
struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv;
|
||||
int rc;
|
||||
char *s = strdup(msg);
|
||||
|
||||
ENTERFUNC;
|
||||
|
||||
if (newcat_is_rig(rig, RIG_MODEL_FT450))
|
||||
int chan = 0;
|
||||
if (strlen(msg)==1)
|
||||
{
|
||||
// 450 manual says 1/2/3 playback needs P1=6/7/8
|
||||
s[0] += 5;
|
||||
switch(*msg)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
chan = atoi(msg);
|
||||
default:
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "KY%c%c", s[0], cat_term);
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
}
|
||||
if (newcat_is_rig(rig, RIG_MODEL_FT450) && chan < 4)
|
||||
{
|
||||
// 450 manual says 1/2/3 playback needs P1=6/7/8
|
||||
chan += 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "KY%d%c", chan, cat_term);
|
||||
}
|
||||
|
||||
rc = newcat_set_cmd(rig);
|
||||
free(s);
|
||||
RETURNFUNC(rc);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@ char modeA = '0';
|
|||
char modeB = '0';
|
||||
int keyspd = 20;
|
||||
int bandselect = 5;
|
||||
int width = 21;
|
||||
int narrow = 0;
|
||||
|
||||
// ID 0310 == 310, Must drop leading zero
|
||||
typedef enum nc_rigid_e
|
||||
|
@ -299,6 +301,24 @@ int main(int argc, char *argv[])
|
|||
sprintf(buf,"BS%02d;", bandselect);
|
||||
n = write(fd, buf, strlen(buf));
|
||||
}
|
||||
else if (strncmp(buf, "SH0;", 4)==0)
|
||||
{
|
||||
sprintf(buf,"SH0%02d;", width);
|
||||
n = write(fd, buf, strlen(buf));
|
||||
}
|
||||
else if (strncmp(buf, "SH0", 3)==0)
|
||||
{
|
||||
sscanf(buf,"SH0%02d", &width);
|
||||
}
|
||||
else if (strncmp(buf, "NA0;", 4)==0)
|
||||
{
|
||||
sprintf(buf,"NA0%d;", narrow);
|
||||
n = write(fd, buf, strlen(buf));
|
||||
}
|
||||
else if (strncmp(buf, "NA0", 3)==0)
|
||||
{
|
||||
sscanf(buf,"NA0%d", &narrow);
|
||||
}
|
||||
|
||||
else if (strlen(buf) > 0)
|
||||
{
|
||||
|
|
|
@ -16,6 +16,7 @@ void initFIFO(FIFO_RIG *fifo)
|
|||
|
||||
void resetFIFO(FIFO_RIG *fifo)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: fifo flushed\n", __func__);
|
||||
fifo->head = fifo->tail;
|
||||
fifo->flush = 1;
|
||||
}
|
||||
|
|
|
@ -8142,10 +8142,16 @@ void *morse_data_handler(void *arg)
|
|||
if (result != RIG_OK)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error: %s\n", __func__, rigerror(result));
|
||||
if (result == -RIG_EINVAL)
|
||||
{
|
||||
// severe error -- so flush it and stop
|
||||
resetFIFO(rig->state.fifo_morse);
|
||||
nloops = 0;
|
||||
}
|
||||
hl_usleep(100 * 1000);
|
||||
}
|
||||
//wait_morse_ptt(rig, RIG_VFO_CURR);
|
||||
nloops++;
|
||||
nloops--;
|
||||
|
||||
} while (result != RIG_OK && rig->state.fifo_morse->flush == 0 && --nloops > 0);
|
||||
if (nloops == 0)
|
||||
|
|
Ładowanie…
Reference in New Issue