Start converting rigs/*

This commit does rigs/adat/, rigs/alinco/ and rigs/aor/.
pull/1508/head
George Baltz N3GB 2024-01-25 18:09:44 -05:00
rodzic 4a1fa678ea
commit 02f0ad067a
10 zmienionych plików z 71 dodań i 83 usunięć

Wyświetl plik

@ -1233,7 +1233,7 @@ int adat_send(RIG *pRig,
char *pcData)
{
int nRC = RIG_OK;
struct rig_state *pRigState = &pRig->state;
hamlib_port_t *pRigPort = RIGPORT(pRig);
gFnLevel++;
@ -1241,9 +1241,9 @@ int adat_send(RIG *pRig,
"*** ADAT: %d %s (%s:%d): ENTRY. Params: pRig = %p, pcData = %s\n",
gFnLevel, __func__, __FILE__, __LINE__, pRig, pcData);
rig_flush(&pRigState->rigport);
rig_flush(pRigPort);
nRC = write_block(&pRigState->rigport, (unsigned char *) pcData,
nRC = write_block(pRigPort, (unsigned char *) pcData,
strlen(pcData));
rig_debug(RIG_DEBUG_TRACE,
@ -1264,7 +1264,6 @@ int adat_receive(RIG *pRig,
char *pcData)
{
int nRC = RIG_OK;
struct rig_state *pRigState = &pRig->state;
gFnLevel++;
@ -1272,7 +1271,7 @@ int adat_receive(RIG *pRig,
"*** ADAT: %d %s (%s:%d): ENTRY. Params: pRig = %p\n",
gFnLevel, __func__, __FILE__, __LINE__, pRig);
nRC = read_string(&pRigState->rigport, (unsigned char *) pcData, ADAT_RESPSZ,
nRC = read_string(RIGPORT(pRig), (unsigned char *) pcData, ADAT_RESPSZ,
ADAT_EOL, 1, 0, 1);
if (nRC > 0)
@ -1428,7 +1427,6 @@ int adat_get_single_cmd_result(RIG *pRig)
else
{
adat_priv_data_ptr pPriv = (adat_priv_data_ptr) pRig->state.priv;
struct rig_state *pRigState = &pRig->state;
nRC = adat_send(pRig, pPriv->acCmd);
@ -1526,7 +1524,7 @@ int adat_get_single_cmd_result(RIG *pRig)
}
}
rig_flush(&pRigState->rigport);
rig_flush(RIGPORT(pRig));
pPriv->nRC = nRC;
}

Wyświetl plik

@ -301,7 +301,7 @@ int dx77_transaction(RIG *rig,
{
int retval;
struct rig_state *rs;
hamlib_port_t *rp = RIGPORT(rig);
char echobuf[BUFSZ + 1];
if (cmd == NULL)
@ -311,11 +311,9 @@ int dx77_transaction(RIG *rig,
return -RIG_EINTERNAL;
}
rs = &rig->state;
rig_flush(rp);
rig_flush(&rs->rigport);
retval = write_block(&rs->rigport, (unsigned char *) cmd, cmd_len);
retval = write_block(rp, (unsigned char *) cmd, cmd_len);
if (retval != RIG_OK)
{
@ -326,7 +324,7 @@ int dx77_transaction(RIG *rig,
* Transceiver sends an echo of cmd followed by a CR/LF
* TODO: check whether cmd and echobuf match (optional)
*/
retval = read_string(&rs->rigport, (unsigned char *) echobuf, BUFSZ,
retval = read_string(rp, (unsigned char *) echobuf, BUFSZ,
LF, strlen(LF), 0, 1);
if (retval < 0)
@ -343,7 +341,7 @@ int dx77_transaction(RIG *rig,
/* no data expected, check for OK returned */
if (data == NULL)
{
retval = read_string(&rs->rigport, (unsigned char *) echobuf, BUFSZ,
retval = read_string(rp, (unsigned char *) echobuf, BUFSZ,
LF, strlen(LF), 0, 1);
if (retval < 0)
@ -365,7 +363,7 @@ int dx77_transaction(RIG *rig,
}
}
retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ,
retval = read_string(rp, (unsigned char *) data, BUFSZ,
LF, strlen(LF), 0, 1);
if (retval < 0)

Wyświetl plik

@ -235,7 +235,7 @@ int dxsr8_transaction(RIG *rig,
{
int retval;
struct rig_state *rs;
hamlib_port_t *rp = RIGPORT(rig);
char replybuf[BUFSZ + 1];
int reply_len;
@ -246,11 +246,9 @@ int dxsr8_transaction(RIG *rig,
return -RIG_EINTERNAL;
}
rs = &rig->state;
rig_flush(rp);
rig_flush(&rs->rigport);
retval = write_block(&rs->rigport, (unsigned char *) cmd, cmd_len);
retval = write_block(rp, (unsigned char *) cmd, cmd_len);
if (retval != RIG_OK)
{
@ -261,7 +259,7 @@ int dxsr8_transaction(RIG *rig,
* Transceiver sends an echo of cmd followed by a CR/LF
* TODO: check whether cmd and echobuf match (optional)
*/
retval = read_string(&rs->rigport, (unsigned char *) replybuf, BUFSZ,
retval = read_string(rp, (unsigned char *) replybuf, BUFSZ,
LF, strlen(LF), 0, 1);
if (retval < 0)
@ -270,7 +268,7 @@ int dxsr8_transaction(RIG *rig,
}
retval = read_string(&rs->rigport, (unsigned char *) replybuf, BUFSZ,
retval = read_string(rp, (unsigned char *) replybuf, BUFSZ,
LF, strlen(LF), 0, 1);
if (retval < 0)

Wyświetl plik

@ -67,15 +67,13 @@ static int aor_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
int *data_len)
{
int retval;
struct rig_state *rs;
hamlib_port_t *rp = RIGPORT(rig);
char ackbuf[BUFSZ];
int ack_len;
rs = &rig->state;
rig_flush(rp);
rig_flush(&rs->rigport);
retval = write_block(&rs->rigport, (unsigned char *) cmd, cmd_len);
retval = write_block(rp, (unsigned char *) cmd, cmd_len);
if (retval != RIG_OK)
{
@ -95,7 +93,7 @@ static int aor_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
/*
* Do wait for a reply
*/
retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ, EOM,
retval = read_string(rp, (unsigned char *) data, BUFSZ, EOM,
strlen(EOM), 0, 1);
if (retval < 0)
@ -124,7 +122,7 @@ static int aor_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
if (retval >= 1 && data[0] == '?')
{
/* command failed? resync with radio */
write_block(&rs->rigport, (unsigned char *) EOM, 1);
write_block(rp, (unsigned char *) EOM, 1);
return -RIG_EPROTO;
}
@ -144,7 +142,7 @@ int aor_close(RIG *rig)
* since no reply is to be expected.
*/
return write_block(&rig->state.rigport, (unsigned char *) "EX" EOM, 3);
return write_block(RIGPORT(rig), (unsigned char *) "EX" EOM, 3);
}
static int format_freq(char *buf, int buf_len, freq_t freq)
@ -1423,7 +1421,7 @@ int aor_get_chan_all_cb(RIG *rig, vfo_t vfo, chan_cb_t chan_cb, rig_ptr_t arg)
/*
* get next line
*/
retval = read_string(&rig->state.rigport, (unsigned char *) chanbuf, BUFSZ,
retval = read_string(RIGPORT(rig), (unsigned char *) chanbuf, BUFSZ,
EOM, strlen(EOM), 0, 1);
if (retval < 0)

Wyświetl plik

@ -185,13 +185,11 @@ static int ar3k_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
int *data_len)
{
int retval;
struct rig_state *rs;
hamlib_port_t *rp = RIGPORT(rig);
rs = &rig->state;
rig_flush(rp);
rig_flush(&rs->rigport);
retval = write_block(&rs->rigport, (unsigned char *) cmd, cmd_len);
retval = write_block(rp, (unsigned char *) cmd, cmd_len);
if (retval != RIG_OK)
{
@ -204,7 +202,7 @@ static int ar3k_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
return RIG_OK;
}
retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ,
retval = read_string(rp, (unsigned char *) data, BUFSZ,
EOM, strlen(EOM), 0, 1);
if (retval == -RIG_ETIMEOUT)

Wyświetl plik

@ -216,22 +216,20 @@ static int ar3030_transaction(RIG *rig, const char *cmd, int cmd_len,
char *data, int *data_len)
{
int retval;
struct rig_state *rs;
hamlib_port_t *rp = RIGPORT(rig);
int retry = 3;
char tmpdata[BUFSZ];
rs = &rig->state;
if (data == NULL)
{
data = tmpdata;
}
rig_flush(&rs->rigport);
rig_flush(rp);
do
{
retval = write_block(&rs->rigport, (unsigned char *) cmd, cmd_len);
retval = write_block(rp, (unsigned char *) cmd, cmd_len);
if (retval != RIG_OK)
{
@ -242,7 +240,7 @@ static int ar3030_transaction(RIG *rig, const char *cmd, int cmd_len,
if (data)
{
/* expecting 0x0d0x0a on all commands so wait for the 0x0a */
retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ,
retval = read_string(rp, (unsigned char *) data, BUFSZ,
"\x0a", 1, 0, 1);
if (retval == -RIG_ETIMEOUT)
@ -307,12 +305,10 @@ int ar3030_cleanup(RIG *rig)
int ar3030_close(RIG *rig)
{
int retval;
struct rig_state *rs;
rig_debug(RIG_DEBUG_TRACE, "%s:\n", __func__);
rs = &rig->state;
rig_flush(&rs->rigport);
rig_flush(RIGPORT(rig));
retval = ar3030_transaction(rig, "Q" CR, strlen("Q" CR), NULL, NULL);
rig_debug(RIG_DEBUG_TRACE, "%s: retval=%d\n", __func__, retval);

Wyświetl plik

@ -66,7 +66,7 @@
static int rxr_writeByte(RIG *rig, unsigned char c)
{
return write_block(&rig->state.rigport, &c, 1);
return write_block(RIGPORT(rig), &c, 1);
}
@ -75,14 +75,14 @@ static int rxr_readByte(RIG *rig)
unsigned char response[1];
const unsigned char buf[] = {0x71}; // Read command
int retval;
retval = write_block(&rig->state.rigport, buf, 1);
retval = write_block(RIGPORT(rig), buf, 1);
if (retval != RIG_OK)
{
return retval;
}
retval = read_block(&rig->state.rigport, response, 1);
retval = read_block(RIGPORT(rig), response, 1);
if (retval != RIG_OK)
{
@ -270,16 +270,17 @@ static void Execute_Routine_6_1(RIG *rig, char mp, char ad, int numSteps)
static int Execute_Routine_14(RIG *rig)
{
unsigned char response[1];
hamlib_port_t *rp = RIGPORT(rig);
const unsigned char buf[] = {0x2e}; // Read command
int retval;
retval = write_block(&rig->state.rigport, buf, 1);
retval = write_block(rp, buf, 1);
if (retval != RIG_OK)
{
return retval;
}
retval = read_block(&rig->state.rigport, response, 1);
retval = read_block(rp, response, 1);
if (retval != RIG_OK)
{

Wyświetl plik

@ -266,7 +266,7 @@ static int ar7030p_init(RIG *rig)
rig->state.priv = (void *) priv;
rig->state.rigport.type.rig = RIG_PORT_SERIAL;
RIGPORT(rig)->type.rig = RIG_PORT_SERIAL;
priv->powerstat = RIG_POWER_ON;
priv->bank = 0;

Wyświetl plik

@ -56,7 +56,7 @@ int NOP(RIG *rig, unsigned char x)
assert(NULL != rig);
rc = write_block(&rig->state.rigport, (char *) &op, 1);
rc = write_block(RIGPORT(rig), (char *) &op, 1);
if (0 != rc)
{
@ -78,7 +78,7 @@ int SRH(RIG *rig, unsigned char x)
assert(NULL != rig);
rc = write_block(&rig->state.rigport, (char *) &op, 1);
rc = write_block(RIGPORT(rig), (char *) &op, 1);
if (0 != rc)
{
@ -108,7 +108,7 @@ int PGE(RIG *rig, enum PAGE_e page)
case EEPROM2:
case EEPROM3:
case ROM:
rc = write_block(&rig->state.rigport, (char *) &op, 1);
rc = write_block(RIGPORT(rig), (char *) &op, 1);
if (0 != rc)
{
@ -141,7 +141,7 @@ int ADR(RIG *rig, unsigned char x)
assert(NULL != rig);
rc = write_block(&rig->state.rigport, (char *) &op, 1);
rc = write_block(RIGPORT(rig), (char *) &op, 1);
if (0 != rc)
{
@ -163,7 +163,7 @@ int ADH(RIG *rig, unsigned char x)
assert(NULL != rig);
rc = write_block(&rig->state.rigport, (char *) &op, 1);
rc = write_block(RIGPORT(rig), (char *) &op, 1);
if (0 != rc)
{
@ -187,7 +187,7 @@ int WRD(RIG *rig, unsigned char out)
assert(NULL != rig);
rc = write_block(&rig->state.rigport, (char *) &op, 1);
rc = write_block(RIGPORT(rig), (char *) &op, 1);
if (0 != rc)
{
@ -210,7 +210,7 @@ int MSK(RIG *rig, unsigned char mask)
assert(NULL != rig);
rc = write_block(&rig->state.rigport, (char *) &op, 1);
rc = write_block(RIGPORT(rig), (char *) &op, 1);
if (0 != rc)
{
@ -248,7 +248,7 @@ int EXE(RIG *rig, enum ROUTINE_e routine)
case DISP_BUFF:
case READ_SIGNAL:
case READ_BTNS:
rc = write_block(&rig->state.rigport, (char *) &op, 1);
rc = write_block(RIGPORT(rig), (char *) &op, 1);
if (0 != rc)
{
@ -280,7 +280,7 @@ int RDD(RIG *rig, unsigned char len)
assert(NULL != rig);
rc = write_block(&rig->state.rigport, (char *) &op, 1);
rc = write_block(RIGPORT(rig), (char *) &op, 1);
if (0 != rc)
{
@ -288,7 +288,7 @@ int RDD(RIG *rig, unsigned char len)
}
else
{
rc = read_block(&rig->state.rigport, (char *) &inChr, len);
rc = read_block(RIGPORT(rig), (char *) &inChr, len);
if (1 != rc)
{
@ -321,7 +321,7 @@ int LOC(RIG *rig, enum LOCK_LVL_e level)
case LOCK_1:
case LOCK_2:
case LOCK_3:
rc = write_block(&rig->state.rigport, (char *) &op, 1);
rc = write_block(RIGPORT(rig), (char *) &op, 1);
if (0 != rc)
{
@ -366,7 +366,7 @@ int BUT(RIG *rig, enum BUTTON_e button)
case BTN_STAR:
case BTN_MENU:
case BTN_POWER:
rc = write_block(&rig->state.rigport, (char *) &op, 1);
rc = write_block(RIGPORT(rig), (char *) &op, 1);
if (0 != rc)
{
@ -403,7 +403,7 @@ int execRoutine(RIG *rig, enum ROUTINE_e rtn)
assert(NULL != rig);
if (0 == write_block(&rig->state.rigport, &v, 1))
if (0 == write_block(RIGPORT(rig), &v, 1))
{
rc = RIG_OK;
@ -428,6 +428,7 @@ int execRoutine(RIG *rig, enum ROUTINE_e rtn)
static int setAddr(RIG *rig, enum PAGE_e page, unsigned int addr)
{
int rc = RIG_OK;
hamlib_port_t *rp = RIGPORT(rig);
unsigned char v;
assert(NULL != rig);
@ -440,7 +441,7 @@ static int setAddr(RIG *rig, enum PAGE_e page, unsigned int addr)
{
v = PGE(page);
if (0 == write_block(&rig->state.rigport, &v, 1))
if (0 == write_block(rp, &v, 1))
{
curPage = page;
rc = RIG_OK;
@ -457,7 +458,7 @@ static int setAddr(RIG *rig, enum PAGE_e page, unsigned int addr)
{
v = SRH((0x0f0 & addr) >> 4);
rc = write_block(&rig->state.rigport, &v, 1);
rc = write_block(rp, &v, 1);
if (rc != RIG_OK)
{
@ -466,13 +467,13 @@ static int setAddr(RIG *rig, enum PAGE_e page, unsigned int addr)
v = ADR((0x00f & addr));
if (0 == write_block(&rig->state.rigport, &v, 1))
if (0 == write_block(rp, &v, 1))
{
if (0xff < addr)
{
v = ADH((0xf00 & addr) >> 8);
if (0 == write_block(&rig->state.rigport, &v, 1))
if (0 == write_block(rp, &v, 1))
{
curAddr = addr;
rc = RIG_OK;
@ -525,6 +526,7 @@ static int setAddr(RIG *rig, enum PAGE_e page, unsigned int addr)
int writeByte(RIG *rig, enum PAGE_e page, unsigned int addr, unsigned char x)
{
int rc;
hamlib_port_t *rp = RIGPORT(rig);
unsigned char hi = SRH((x & 0xf0) >> 4);
unsigned char lo = WRD(x & 0x0f);
@ -536,9 +538,9 @@ int writeByte(RIG *rig, enum PAGE_e page, unsigned int addr, unsigned char x)
{
rc = -RIG_EIO;
if (0 == write_block(&rig->state.rigport, &hi, 1))
if (0 == write_block(rp, &hi, 1))
{
if (0 == write_block(&rig->state.rigport, &lo, 1))
if (0 == write_block(rp, &lo, 1))
{
rc = RIG_OK;
curAddr++;
@ -667,6 +669,7 @@ int writeInt(RIG *rig, enum PAGE_e page, unsigned int addr, unsigned int x)
int readByte(RIG *rig, enum PAGE_e page, unsigned int addr, unsigned char *x)
{
int rc = RIG_OK;
hamlib_port_t *rp = RIGPORT(rig);
unsigned char v = RDD(1); // Read command
assert(NULL != rig);
@ -678,9 +681,9 @@ int readByte(RIG *rig, enum PAGE_e page, unsigned int addr, unsigned char *x)
{
rc = -RIG_EIO;
if (0 == write_block(&rig->state.rigport, &v, 1))
if (0 == write_block(rp, &v, 1))
{
if (1 == read_block(&rig->state.rigport, x, 1))
if (1 == read_block(rp, x, 1))
{
curAddr++;
rc = RIG_OK;
@ -841,7 +844,7 @@ int readSignal(RIG *rig, unsigned char *x)
if (RIG_OK == rc)
{
if (1 == read_block(&rig->state.rigport, x, 1))
if (1 == read_block(RIGPORT(rig), x, 1))
{
rc = RIG_OK;
@ -867,7 +870,7 @@ int flushBuffer(RIG *rig)
assert(NULL != rig);
if (0 == write_block(&rig->state.rigport, &v, 1))
if (0 == write_block(RIGPORT(rig), &v, 1))
{
rc = RIG_OK;
}
@ -896,7 +899,7 @@ int lockRx(RIG *rig, enum LOCK_LVL_e level)
{
v = LOC(level);
if (0 == write_block(&rig->state.rigport, &v, 1))
if (0 == write_block(RIGPORT(rig), &v, 1))
{
rc = RIG_OK;

Wyświetl plik

@ -274,15 +274,13 @@ static int sr2200_transaction(RIG *rig, const char *cmd, int cmd_len,
char *data, int *data_len)
{
int retval;
struct rig_state *rs;
hamlib_port_t *rp = RIGPORT(rig);
char ackbuf[BUFSZ];
int ack_len;
rs = &rig->state;
rig_flush(rp);
rig_flush(&rs->rigport);
retval = write_block(&rs->rigport, (unsigned char *) cmd, cmd_len);
retval = write_block(rp, (unsigned char *) cmd, cmd_len);
if (retval != RIG_OK)
{
@ -302,7 +300,7 @@ static int sr2200_transaction(RIG *rig, const char *cmd, int cmd_len,
/*
* Do wait for a reply
*/
retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ, EOM,
retval = read_string(rp, (unsigned char *) data, BUFSZ, EOM,
strlen(EOM), 0, 1);
if (retval < 0)
@ -324,7 +322,7 @@ static int sr2200_transaction(RIG *rig, const char *cmd, int cmd_len,
if (data[0] == '?')
{
/* command failed? resync with radio */
write_block(&rs->rigport, (unsigned char *) EOM, 1);
write_block(rp, (unsigned char *) EOM, 1);
return -RIG_EPROTO;
}