mirror of
https://github.com/Hamlib/Hamlib.git
synced 2024-09-22 02:47:21 +00:00
Change mutex locking locations in anytone.c
This commit is contained in:
parent
75699adbbb
commit
16137cd72a
@ -199,7 +199,6 @@ int anytone_transaction(RIG *rig, char *cmd, int cmd_len, int expected_len)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MUTEX_LOCK(p->mutex);
|
|
||||||
retval = anytone_send(rig, cmd, cmd_len);
|
retval = anytone_send(rig, cmd, cmd_len);
|
||||||
|
|
||||||
if (retval == RIG_OK && expected_len != 0)
|
if (retval == RIG_OK && expected_len != 0)
|
||||||
@ -215,8 +214,6 @@ int anytone_transaction(RIG *rig, char *cmd, int cmd_len, int expected_len)
|
|||||||
|
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
MUTEX_LOCK(p->mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURNFUNC(retval);
|
RETURNFUNC(retval);
|
||||||
@ -383,21 +380,26 @@ int anytone_set_vfo(RIG *rig, vfo_t vfo)
|
|||||||
{
|
{
|
||||||
char buf1[8] = { 0x41, 0x00, 0x01, 0x00, 0x0d, 0x00, 0x00, 0x06 };
|
char buf1[8] = { 0x41, 0x00, 0x01, 0x00, 0x0d, 0x00, 0x00, 0x06 };
|
||||||
char buf2[8] = { 0x41, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x06 };
|
char buf2[8] = { 0x41, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x06 };
|
||||||
|
MUTEX_LOCK(p->mutex);
|
||||||
anytone_transaction(rig, buf1, 8, 0);
|
anytone_transaction(rig, buf1, 8, 0);
|
||||||
hl_usleep(100 * 1000);
|
hl_usleep(100 * 1000);
|
||||||
anytone_transaction(rig, buf2, 8, 0);
|
anytone_transaction(rig, buf2, 8, 0);
|
||||||
// we expect 16 bytes coming back
|
// we expect 16 bytes coming back
|
||||||
unsigned char reply[16];
|
unsigned char reply[16];
|
||||||
int nbytes = read_block(&rig->state.rigport, reply, 16);
|
int nbytes = read_block(&rig->state.rigport, reply, 16);
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_ERR, "%s(%d): nbytes=%d\n", __func__, __LINE__, nbytes);
|
rig_debug(RIG_DEBUG_ERR, "%s(%d): nbytes=%d\n", __func__, __LINE__, nbytes);
|
||||||
|
|
||||||
if (reply[8] == 0x00) { p->vfo_curr = RIG_VFO_A; }
|
if (reply[8] == 0x00) { p->vfo_curr = RIG_VFO_A; }
|
||||||
else { p->vfo_curr = RIG_VFO_B; }
|
else { p->vfo_curr = RIG_VFO_B; }
|
||||||
|
|
||||||
|
MUTEX_UNLOCK(p->mutex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char buf1[8] = { 0x41, 0x00, 0x01, 0x00, 0x0d, 0x00, 0x00, 0x06 };
|
char buf1[8] = { 0x41, 0x00, 0x01, 0x00, 0x0d, 0x00, 0x00, 0x06 };
|
||||||
char buf2[8] = { 0x41, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x06 };
|
char buf2[8] = { 0x41, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x06 };
|
||||||
|
MUTEX_LOCK(p->mutex);
|
||||||
anytone_transaction(rig, buf1, 8, 0);
|
anytone_transaction(rig, buf1, 8, 0);
|
||||||
hl_usleep(100 * 1000);
|
hl_usleep(100 * 1000);
|
||||||
anytone_transaction(rig, buf2, 8, 0);
|
anytone_transaction(rig, buf2, 8, 0);
|
||||||
@ -407,6 +409,8 @@ int anytone_set_vfo(RIG *rig, vfo_t vfo)
|
|||||||
|
|
||||||
if (reply[8] == 0x00) { p->vfo_curr = RIG_VFO_A; }
|
if (reply[8] == 0x00) { p->vfo_curr = RIG_VFO_A; }
|
||||||
else { p->vfo_curr = RIG_VFO_B; }
|
else { p->vfo_curr = RIG_VFO_B; }
|
||||||
|
|
||||||
|
MUTEX_UNLOCK(p->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -455,9 +459,11 @@ int anytone_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
|||||||
|
|
||||||
if (ptt) { buf[1] = 0x01; }
|
if (ptt) { buf[1] = 0x01; }
|
||||||
|
|
||||||
|
MUTEX_LOCK(p->mutex);
|
||||||
anytone_transaction(rig, buf, 8, 1);
|
anytone_transaction(rig, buf, 8, 1);
|
||||||
anytone_priv_data_t *p = rig->state.priv;
|
anytone_priv_data_t *p = rig->state.priv;
|
||||||
p->ptt = ptt;
|
p->ptt = ptt;
|
||||||
|
MUTEX_UNLOCK(p->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURNFUNC(retval);
|
RETURNFUNC(retval);
|
||||||
|
Loading…
Reference in New Issue
Block a user