Convert all port references in amplifiers/ to pointers.

pull/1513/head
George Baltz N3GB 2024-02-15 21:50:21 -05:00
rodzic 8cc6ce1319
commit 878117ab1f
5 zmienionych plików z 28 dodań i 55 usunięć

Wyświetl plik

@ -74,7 +74,7 @@ int kpa_init(AMP *amp)
return -RIG_ENOMEM;
}
amp->state.ampport.type.rig = RIG_PORT_SERIAL;
AMPPORT(amp)->type.rig = RIG_PORT_SERIAL;
return RIG_OK;
}
@ -92,18 +92,14 @@ int kpa_close(AMP *amp)
int kpa_flushbuffer(AMP *amp)
{
struct amp_state *rs;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rs = &amp->state;
return rig_flush(&rs->ampport);
return rig_flush(AMPPORT(amp));
}
int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len)
{
struct amp_state *rs;
hamlib_port_t *ampp = AMPPORT(amp);
int err;
int len = 0;
int loop;
@ -114,19 +110,17 @@ int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len)
kpa_flushbuffer(amp);
rs = &amp->state;
loop = 3;
do // wake up the amp by sending ; until we receive ;
{
char c = ';';
rig_debug(RIG_DEBUG_VERBOSE, "%s waiting for ;\n", __func__);
err = write_block(&rs->ampport, (unsigned char *) &c, 1);
err = write_block(ampp, (unsigned char *) &c, 1);
if (err != RIG_OK) { return err; }
len = read_string(&rs->ampport, (unsigned char *) response, response_len, ";",
len = read_string(ampp, (unsigned char *) response, response_len, ";",
1, 0, 1);
if (len < 0) { return len; }
@ -134,14 +128,14 @@ int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len)
while (--loop > 0 && (len != 1 || response[0] != ';'));
// Now send our command
err = write_block(&rs->ampport, (unsigned char *) cmd, strlen(cmd));
err = write_block(ampp, (unsigned char *) cmd, strlen(cmd));
if (err != RIG_OK) { return err; }
if (response) // if response expected get it
{
response[0] = 0;
len = read_string(&rs->ampport, (unsigned char *) response, response_len, ";",
len = read_string(ampp, (unsigned char *) response, response_len, ";",
1, 0, 1);
if (len < 0)
@ -164,11 +158,11 @@ int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len)
{
char c = ';';
rig_debug(RIG_DEBUG_VERBOSE, "%s waiting for ;\n", __func__);
err = write_block(&rs->ampport, (unsigned char *) &c, 1);
err = write_block(ampp, (unsigned char *) &c, 1);
if (err != RIG_OK) { return err; }
len = read_string(&rs->ampport, (unsigned char *) responsebuf, KPABUFSZ, ";", 1,
len = read_string(ampp, (unsigned char *) responsebuf, KPABUFSZ, ";", 1,
0, 1);
if (len < 0) { return len; }
@ -277,7 +271,6 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
int pwrinput;
float float_value = 0;
int int_value = 0, int_value2 = 0;
struct amp_state *rs = &amp->state;
struct kpa_priv_data *priv = amp->state.priv;
@ -373,7 +366,7 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
//
do
{
retval = read_string(&rs->ampport, (unsigned char *) responsebuf,
retval = read_string(AMPPORT(amp), (unsigned char *) responsebuf,
sizeof(responsebuf), ";", 1, 0,
1);

Wyświetl plik

@ -109,7 +109,6 @@ const struct amp_caps kpa1500_amp_caps =
static int kpa1500_send_priv_cmd(AMP *amp, const char *cmdstr)
{
struct amp_state *rs;
int err;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -119,8 +118,7 @@ static int kpa1500_send_priv_cmd(AMP *amp, const char *cmdstr)
return -RIG_EINVAL;
}
rs = &amp->state;
err = write_block(&rs->ampport, cmdstr, strlen(cmdstr));
err = write_block(AMPPORT(amp), cmdstr, strlen(cmdstr));
if (err != RIG_OK)
{

Wyświetl plik

@ -76,7 +76,7 @@ int expert_init(AMP *amp)
return -RIG_ENOMEM;
}
amp->state.ampport.type.rig = RIG_PORT_SERIAL;
AMPPORT(amp)->type.rig = RIG_PORT_SERIAL;
return RIG_OK;
}
@ -111,19 +111,15 @@ int expert_close(AMP *amp)
int expert_flushbuffer(AMP *amp)
{
struct amp_state *rs;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rs = &amp->state;
return rig_flush(&rs->ampport);
return rig_flush(AMPPORT(amp));
}
int expert_transaction(AMP *amp, const unsigned char *cmd, int cmd_len,
unsigned char *response, int response_len)
{
struct amp_state *rs;
hamlib_port_t *ampp = AMPPORT(amp);
int err;
int len = 0;
char cmdbuf[64];
@ -140,8 +136,6 @@ int expert_transaction(AMP *amp, const unsigned char *cmd, int cmd_len,
expert_flushbuffer(amp);
rs = &amp->state;
cmdbuf[0] = cmdbuf[1] = cmdbuf[2] = 0x55;
for (int i = 0; i < cmd_len; ++i) { checksum += cmd[i]; }
@ -152,7 +146,7 @@ int expert_transaction(AMP *amp, const unsigned char *cmd, int cmd_len,
cmdbuf[3 + cmd_len + 1] = checksum;
// Now send our command
err = write_block(&rs->ampport, (unsigned char *) cmdbuf, 3 + cmd_len + 2);
err = write_block(ampp, (unsigned char *) cmdbuf, 3 + cmd_len + 2);
if (err != RIG_OK) { return err; }
@ -161,7 +155,7 @@ int expert_transaction(AMP *amp, const unsigned char *cmd, int cmd_len,
int bytes = 0;
response[0] = 0;
// read the 4-byte header x55x55x55xXX where XX is the hex # of bytes
len = read_block_direct(&rs->ampport, (unsigned char *) response, 4);
len = read_block_direct(ampp, (unsigned char *) response, 4);
rig_debug(RIG_DEBUG_ERR, "%s: len=%d, bytes=%02x\n", __func__, len,
response[3]);
@ -175,7 +169,7 @@ int expert_transaction(AMP *amp, const unsigned char *cmd, int cmd_len,
if (len == 4) { bytes = response[3]; }
rig_debug(RIG_DEBUG_ERR, "%s: bytes=%d\n", __func__, bytes);
len = read_block_direct(&rs->ampport, (unsigned char *) response, bytes - 3);
len = read_block_direct(ampp, (unsigned char *) response, bytes - 3);
dump_hex(response, len);
}
else // if no response expected try to get one
@ -188,11 +182,11 @@ int expert_transaction(AMP *amp, const unsigned char *cmd, int cmd_len,
{
char c = ';';
rig_debug(RIG_DEBUG_VERBOSE, "%s waiting for ;\n", __func__);
err = write_block(&rs->ampport, (unsigned char *) &c, 1);
err = write_block(ampp, (unsigned char *) &c, 1);
if (err != RIG_OK) { return err; }
len = read_string(&rs->ampport, (unsigned char *) responsebuf, KPABUFSZ, ";", 1,
len = read_string(ampp, (unsigned char *) responsebuf, KPABUFSZ, ";", 1,
0, 1);
if (len < 0) { return len; }
@ -302,7 +296,6 @@ int expert_get_level(AMP *amp, setting_t level, value_t *val)
int pwrinput;
float float_value = 0;
int int_value = 0, int_value2 = 0;
struct amp_state *rs = &amp->state;
struct expert_priv_data *priv = amp->state.priv;
@ -400,7 +393,7 @@ int expert_get_level(AMP *amp, setting_t level, value_t *val)
//
do
{
retval = read_string(&rs->ampport, (unsigned char *) responsebuf,
retval = read_string(AMPPORT(amp), (unsigned char *) responsebuf,
sizeof(responsebuf), ";", 1, 0,
1);
@ -723,7 +716,6 @@ const struct amp_caps expert_amp_caps =
static int expert_send_priv_cmd(AMP *amp, const char *cmdstr)
{
struct amp_state *rs;
int err;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -733,8 +725,7 @@ static int expert_send_priv_cmd(AMP *amp, const char *cmdstr)
return -RIG_EINVAL;
}
rs = &amp->state;
err = write_block(&rs->ampport, cmdstr, strlen(cmdstr));
err = write_block(AMPPORT(amp), cmdstr, strlen(cmdstr));
if (err != RIG_OK)
{

Wyświetl plik

@ -104,7 +104,6 @@ const struct amp_caps gemini_amp_caps =
static int gemini_send_priv_cmd(AMP *amp, const char *cmdstr)
{
struct amp_state *rs;
int err;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -114,8 +113,7 @@ static int gemini_send_priv_cmd(AMP *amp, const char *cmdstr)
return -RIG_EINVAL;
}
rs = &amp->state;
err = write_block(&rs->ampport, cmdstr, strlen(cmdstr));
err = write_block(AMPPORT(amp), cmdstr, strlen(cmdstr));
if (err != RIG_OK)
{

Wyświetl plik

@ -53,7 +53,7 @@ int gemini_init(AMP *amp)
return -RIG_ENOMEM;
}
amp->state.ampport.type.rig = RIG_PORT_NETWORK;
AMPPORT(amp)->type.rig = RIG_PORT_NETWORK;
return RIG_OK;
}
@ -71,20 +71,16 @@ int gemini_close(AMP *amp)
int gemini_flushbuffer(AMP *amp)
{
struct amp_state *rs;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rs = &amp->state;
return rig_flush(&rs->ampport);
return rig_flush(AMPPORT(amp));
}
int gemini_transaction(AMP *amp, const char *cmd, char *response,
int response_len)
{
struct amp_state *rs;
hamlib_port_t *ampp = AMPPORT(amp);
int err;
rig_debug(RIG_DEBUG_VERBOSE, "%s called, cmd=%s\n", __func__, cmd);
@ -93,19 +89,16 @@ int gemini_transaction(AMP *amp, const char *cmd, char *response,
gemini_flushbuffer(amp);
rs = &amp->state;
// Now send our command
err = write_block(&rs->ampport, (unsigned char *) cmd, strlen(cmd));
err = write_block(ampp, (unsigned char *) cmd, strlen(cmd));
if (err != RIG_OK) { return err; }
if (response) // if response expected get it
{
response[0] = 0;
int len = read_string(&rs->ampport, (unsigned char *) response, response_len,
"\n",
1, 0, 1);
int len = read_string(ampp, (unsigned char *) response, response_len,
"\n", 1, 0, 1);
if (len < 0)
{