Update anytone.c a bit

pull/1330/head
Mike Black W9MDB 2023-06-03 16:48:20 -05:00
rodzic 2491d208d9
commit 412221d346
2 zmienionych plików z 18 dodań i 16 usunięć

Wyświetl plik

@ -163,15 +163,16 @@ int anytone_send(RIG *rig,
// ---------------------------------------------------------------------------
// anytone_receive
// ---------------------------------------------------------------------------
int anytone_receive(RIG *rig, char *buf, int buf_len, int expected)
int anytone_receive(RIG *rig, unsigned char *buf, int buf_len, int expected)
{
int retval = RIG_OK;
struct rig_state *rs = &rig->state;
ENTERFUNC;
retval = read_string(&rs->rigport, (unsigned char *) buf, buf_len,
NULL, 0, 0, expected);
// retval = read_string(&rs->rigport, (unsigned char *) buf, buf_len,
// NULL, 0, 0, expected);
retval = read_block(&rs->rigport, buf, expected);
if (retval > 0)
{
@ -203,11 +204,11 @@ int anytone_transaction(RIG *rig, char *cmd, int cmd_len, int expected_len)
if (retval == RIG_OK && expected_len != 0)
{
char *buf = calloc(64, 1);
unsigned char *buf = calloc(64, 1);
int len = anytone_receive(rig, buf, 64, expected_len);
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): rx len=%d\n", __func__, __LINE__, len);
if (len == 16 && buf[0] == 0xaa && buf[1] == 0x53)
if (buf[0] == 0xaa && buf[1] == 0x53)
{
p->vfo_curr = buf[8] == 0x00 ? RIG_VFO_A : RIG_VFO_B;
}
@ -346,7 +347,7 @@ int anytone_get_vfo(RIG *rig, vfo_t *vfo)
{
anytone_priv_data_ptr p = (anytone_priv_data_ptr) rig->state.priv;
anytone_transaction(rig, cmd, sizeof(cmd), 16);
anytone_transaction(rig, cmd, sizeof(cmd), 17);
*vfo = p->vfo_curr;
}
@ -399,8 +400,8 @@ int anytone_set_vfo(RIG *rig, vfo_t vfo)
anytone_transaction(rig, buf1, 8, 0);
hl_usleep(100 * 1000);
anytone_transaction(rig, buf2, 8, 0);
unsigned char reply[16];
int nbytes = read_block(&rig->state.rigport, reply, 16);
unsigned char reply[17];
int nbytes = read_block(&rig->state.rigport, reply, 17);
rig_debug(RIG_DEBUG_ERR, "%s(%d): nbytes=%d\n", __func__, __LINE__, nbytes);
if (reply[8] == 0x00) { p->vfo_curr = RIG_VFO_A; }

Wyświetl plik

@ -138,11 +138,11 @@ again:
n = write(fd, buf, 1);
}
if (buf[4] == 0x0d) // set vfo
if (buf[4] == 0x20) // get vfo
{
printf("Set VFO key1=%d, curr_vfo=%d\n", buf[2], curr_vfo);
printf("Get VFO curr_vfo=%d\n", curr_vfo);
if (buf[2] == 0x00)
if (buf[4] == 0x20)
{
if (curr_vfo == 1)
{
@ -154,14 +154,14 @@ again:
}
}
printf("Set VFO key2=%d, curr_vfo=%d\n", buf[2], curr_vfo);
printf("Get VFO curr_vfo=%d\n", curr_vfo);
buf2[0] = 0xaa;
buf2[1] = 0x53;
buf2[2] = 0x00;
buf2[3] = 0x00;
buf2[4] = 0x00;
buf2[5] = 0x00;
buf2[6] = 0x00;
buf2[5] = 0x01;
buf2[6] = 0x01;
buf2[7] = 0x00;
buf2[8] = curr_vfo;
buf2[9] = 0x00;
@ -170,9 +170,10 @@ again:
buf2[12] = 0x00;
buf2[13] = 0x00;
buf2[14] = 0x00;
buf2[15] = 0x06;
buf2[15] = 0x00;
buf2[16] = 0x06;
if (buf[2] == 0x00) { n = write(fd, buf2, 16); }
if (buf[4] == 0x20) { n = write(fd, buf2, 17); }
else { n = 0; }
}