kopia lustrzana https://github.com/Hamlib/Hamlib
Porównaj commity
15 Commity
1ea597b6e1
...
3967e41fcf
Autor | SHA1 | Data |
---|---|---|
Michael Black | 3967e41fcf | |
Mike Black W9MDB | 2849a75676 | |
Mike Black W9MDB | fff8e83c11 | |
Mike Black W9MDB | c23948c8f4 | |
Mike Black W9MDB | 911692c715 | |
Mike Black W9MDB | db6dc92513 | |
George Baltz N3GB | 8ff07c47f9 | |
George Baltz N3GB | f247ee2088 | |
George Baltz N3GB | 878117ab1f | |
Mike Black W9MDB | 8cc6ce1319 | |
Mike Black W9MDB | 91ec3afcda | |
Mike Black W9MDB | 1657a0e673 | |
Mike Black W9MDB | 81dae00ea0 | |
Mike Black W9MDB | 0902b32c45 | |
Mike Black W9MDB | 34d8b0eec3 |
|
@ -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 = &->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 = &->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 = &->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);
|
||||
|
||||
|
|
|
@ -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 = &->state;
|
||||
err = write_block(&rs->ampport, cmdstr, strlen(cmdstr));
|
||||
err = write_block(AMPPORT(amp), cmdstr, strlen(cmdstr));
|
||||
|
||||
if (err != RIG_OK)
|
||||
{
|
||||
|
|
|
@ -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 = &->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 = &->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 = &->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 = &->state;
|
||||
err = write_block(&rs->ampport, cmdstr, strlen(cmdstr));
|
||||
err = write_block(AMPPORT(amp), cmdstr, strlen(cmdstr));
|
||||
|
||||
if (err != RIG_OK)
|
||||
{
|
||||
|
|
|
@ -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 = &->state;
|
||||
err = write_block(&rs->ampport, cmdstr, strlen(cmdstr));
|
||||
err = write_block(AMPPORT(amp), cmdstr, strlen(cmdstr));
|
||||
|
||||
if (err != RIG_OK)
|
||||
{
|
||||
|
|
|
@ -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 = &->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 = &->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)
|
||||
{
|
||||
|
|
|
@ -2290,8 +2290,8 @@ static int icom_set_mode_x26(RIG *rig, vfo_t vfo, rmode_t mode,
|
|||
// Skip filter selection, because at least IC-7300 has a bug defaulting to filter 2 when changing mode
|
||||
// Tested on IC-7300 and IC-9700
|
||||
buf[2] = priv->filter;
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: mode=%ld, filters usbd=%d, usb=%d, cw=%d\n",
|
||||
__func__, mode, priv->filter_usbd, priv->filter_usb, priv->filter_cw);
|
||||
//rig_debug(RIG_DEBUG_TRACE, "%s: mode=%ld, filters usbd=%d, usb=%d, cw=%d\n",
|
||||
// __func__, mode, priv->filter_usbd, priv->filter_usb, priv->filter_cw);
|
||||
|
||||
if (priv->filter_usbd > 0 && (mode == RIG_MODE_PKTUSB
|
||||
|| mode == RIG_MODE_PKTLSB))
|
||||
|
|
|
@ -131,6 +131,32 @@ static int x108g_rig_open(RIG *rig)
|
|||
RETURNFUNC(RIG_OK);
|
||||
}
|
||||
|
||||
int xiegu_rig_open(RIG *rig)
|
||||
{
|
||||
int retval;
|
||||
unsigned char id[4];
|
||||
int id_len = 2;
|
||||
int cmd = 0x19;
|
||||
int subcmd = 0x00;
|
||||
unsigned short iid;
|
||||
retval = icom_transaction(rig, cmd, subcmd, NULL, 0, id, &id_len);
|
||||
|
||||
if (retval == RIG_OK)
|
||||
{
|
||||
iid = (((int)id[2]) << 8) + id[3];
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: Xiegu Radio ID=0x%04x\n", __func__, iid);
|
||||
switch(iid)
|
||||
{
|
||||
case 0x0090: rig_debug(RIG_DEBUG_VERBOSE, "%s: Xiegu model %s\n", __func__, "G90/G90S");break;
|
||||
case 0x0106: rig_debug(RIG_DEBUG_VERBOSE, "%s: Xiegu model %s\n", __func__, "G106/G106C");break;
|
||||
case 0x6100: rig_debug(RIG_DEBUG_VERBOSE, "%s: Xiegu model %s\n", __func__, "X6100");break;
|
||||
default: rig_debug(RIG_DEBUG_VERBOSE, "%s: Xiegu model %s\n", __func__, "Unknown");break;
|
||||
}
|
||||
}
|
||||
|
||||
return icom_rig_open(rig);
|
||||
}
|
||||
|
||||
/*
|
||||
* taken from IC-7000 rig capabilities.
|
||||
*
|
||||
|
@ -328,7 +354,7 @@ static struct icom_priv_caps x6100_priv_caps =
|
|||
0, /* no XCHG */
|
||||
ic7200_ts_sc_list,
|
||||
.x25x26_always = 0,
|
||||
.x25x26_possibly = 0,
|
||||
.x25x26_possibly = 1,
|
||||
.x1cx03_always = 0,
|
||||
.x1cx03_possibly = 0,
|
||||
.x1ax03_supported = 0,
|
||||
|
@ -341,7 +367,7 @@ struct rig_caps x6100_caps =
|
|||
RIG_MODEL(RIG_MODEL_X6100),
|
||||
.model_name = "X6100",
|
||||
.mfg_name = "Xiegu",
|
||||
.version = BACKEND_VER ".4",
|
||||
.version = BACKEND_VER ".5",
|
||||
.copyright = "LGPL",
|
||||
.status = RIG_STATUS_STABLE,
|
||||
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||
|
@ -463,7 +489,7 @@ struct rig_caps x6100_caps =
|
|||
.priv = (void *) &x6100_priv_caps,
|
||||
.rig_init = icom_init,
|
||||
.rig_cleanup = icom_cleanup,
|
||||
.rig_open = icom_rig_open,
|
||||
.rig_open = xiegu_rig_open,
|
||||
.rig_close = icom_rig_close,
|
||||
|
||||
.set_freq = icom_set_freq,
|
||||
|
@ -512,25 +538,6 @@ struct rig_caps x6100_caps =
|
|||
.hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS
|
||||
};
|
||||
|
||||
int g90_rig_open(RIG *rig)
|
||||
{
|
||||
int retval;
|
||||
unsigned char id[2];
|
||||
int id_len = 2;
|
||||
int cmd = 0x19;
|
||||
int subcmd = 0x1d;
|
||||
short iid;
|
||||
retval = icom_transaction(rig, cmd, subcmd, NULL, 0, id, &id_len);
|
||||
|
||||
if (retval == RIG_OK)
|
||||
{
|
||||
memcpy(&iid, id, 2);
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "Xiegu Radio ID=0x%04x\n", iid);
|
||||
}
|
||||
|
||||
return icom_rig_open(rig);
|
||||
}
|
||||
|
||||
struct rig_caps g90_caps =
|
||||
{
|
||||
RIG_MODEL(RIG_MODEL_G90),
|
||||
|
@ -658,7 +665,7 @@ struct rig_caps g90_caps =
|
|||
.priv = (void *)& x108g_priv_caps,
|
||||
.rig_init = icom_init,
|
||||
.rig_cleanup = icom_cleanup,
|
||||
.rig_open = g90_rig_open,
|
||||
.rig_open = xiegu_rig_open,
|
||||
.rig_close = icom_rig_close,
|
||||
|
||||
.set_freq = icom_set_freq,
|
||||
|
@ -833,7 +840,7 @@ struct rig_caps x5105_caps =
|
|||
.priv = (void *)& x108g_priv_caps,
|
||||
.rig_init = icom_init,
|
||||
.rig_cleanup = icom_cleanup,
|
||||
.rig_open = icom_rig_open,
|
||||
.rig_open = xiegu_rig_open,
|
||||
.rig_close = icom_rig_close,
|
||||
|
||||
.set_freq = icom_set_freq,
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
static int
|
||||
if100_set_position(ROT *rot, azimuth_t az, elevation_t el)
|
||||
{
|
||||
hamlib_port_t *port = &rot->state.rotport;
|
||||
hamlib_port_t *port = ROTPORT(rot);
|
||||
int retval;
|
||||
int az_i;
|
||||
int el_i;
|
||||
|
|
|
@ -19,12 +19,11 @@ static pthread_t apex_read_thread;
|
|||
static int apex_get_string(ROT *rot, char *s, int maxlen)
|
||||
{
|
||||
int retval = 0;
|
||||
struct rot_state *rs = &rot->state;
|
||||
char buf[64];
|
||||
|
||||
memset(s, 0, maxlen);
|
||||
|
||||
retval = read_string(&rs->rotport, (unsigned char *)buf,
|
||||
retval = read_string(ROTPORT(rot), (unsigned char *)buf,
|
||||
sizeof(buf),
|
||||
"\n", strlen("\n"), sizeof(buf), 1);
|
||||
strncpy(s, buf, 64);
|
||||
|
@ -98,13 +97,13 @@ int apex_open(ROT *rot)
|
|||
{
|
||||
int retval;
|
||||
char *cmdstr = "[GETVER]\r"; // does this work on all Apex controllers?
|
||||
struct rot_state *rs = &rot->state;
|
||||
hamlib_port_t *rotp = ROTPORT(rot);
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: entered\n", __func__);
|
||||
|
||||
apex_azimuth = -1; // we check to see if we've seen azimuth at least one time
|
||||
rig_flush(&rs->rotport);
|
||||
retval = write_block(&rs->rotport, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
rig_flush(rotp);
|
||||
retval = write_block(rotp, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
|
|
@ -25,7 +25,7 @@ int apex_shared_loop_set_position(ROT *rot, float az, float dummy)
|
|||
{
|
||||
char cmdstr[16];
|
||||
int retval;
|
||||
struct rot_state *rs = &rot->state;
|
||||
hamlib_port_t *rotp = ROTPORT(rot);
|
||||
int remainder = lround(az + 22.5) % 45;
|
||||
int apex_az = lround(az + 22.5) - remainder;
|
||||
|
||||
|
@ -53,9 +53,9 @@ int apex_shared_loop_set_position(ROT *rot, float az, float dummy)
|
|||
return -RIG_EINTERNAL;
|
||||
}
|
||||
|
||||
rig_flush(&rs->rotport);
|
||||
rig_flush(rotp);
|
||||
apex_azimuth = -1;
|
||||
retval = write_block(&rs->rotport, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
retval = write_block(rotp, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
*/
|
||||
#define CHKPPRET(a) \
|
||||
do { int _retval = a; if (_retval != RIG_OK) \
|
||||
{par_unlock (&rot->state.rotport);return _retval; }} while(0)
|
||||
{par_unlock (ROTPORT(rot));return _retval; }} while(0)
|
||||
|
||||
static int ars_init(ROT *rot);
|
||||
static int ars_cleanup(ROT *rot);
|
||||
|
@ -91,7 +91,7 @@ static void *handle_set_position(void *);
|
|||
|
||||
static int ars_clear_ctrl_pin(ROT *rot, unsigned char pin)
|
||||
{
|
||||
hamlib_port_t *pport = &rot->state.rotport;
|
||||
hamlib_port_t *pport = ROTPORT(rot);
|
||||
struct ars_priv_data *priv = (struct ars_priv_data *)rot->state.priv;
|
||||
|
||||
priv->pp_control &= ~pin;
|
||||
|
@ -101,7 +101,7 @@ static int ars_clear_ctrl_pin(ROT *rot, unsigned char pin)
|
|||
|
||||
static int ars_set_ctrl_pin(ROT *rot, unsigned char pin)
|
||||
{
|
||||
hamlib_port_t *pport = &rot->state.rotport;
|
||||
hamlib_port_t *pport = ROTPORT(rot);
|
||||
struct ars_priv_data *priv = (struct ars_priv_data *)rot->state.priv;
|
||||
|
||||
priv->pp_control |= pin;
|
||||
|
@ -111,7 +111,7 @@ static int ars_set_ctrl_pin(ROT *rot, unsigned char pin)
|
|||
|
||||
static int ars_clear_data_pin(ROT *rot, unsigned char pin)
|
||||
{
|
||||
hamlib_port_t *pport = &rot->state.rotport;
|
||||
hamlib_port_t *pport = ROTPORT(rot);
|
||||
struct ars_priv_data *priv = (struct ars_priv_data *)rot->state.priv;
|
||||
|
||||
priv->pp_data &= ~pin;
|
||||
|
@ -121,7 +121,7 @@ static int ars_clear_data_pin(ROT *rot, unsigned char pin)
|
|||
|
||||
static int ars_set_data_pin(ROT *rot, unsigned char pin)
|
||||
{
|
||||
hamlib_port_t *pport = &rot->state.rotport;
|
||||
hamlib_port_t *pport = ROTPORT(rot);
|
||||
struct ars_priv_data *priv = (struct ars_priv_data *)rot->state.priv;
|
||||
|
||||
priv->pp_data |= pin;
|
||||
|
@ -235,7 +235,7 @@ int
|
|||
ars_stop(ROT *rot)
|
||||
{
|
||||
struct ars_priv_data *priv = (struct ars_priv_data *)rot->state.priv;
|
||||
hamlib_port_t *pport = &rot->state.rotport;
|
||||
hamlib_port_t *pport = ROTPORT(rot);
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s called, brake was %s\n", __func__,
|
||||
priv->brake_off ? "OFF" : "ON");
|
||||
|
@ -265,7 +265,7 @@ int
|
|||
ars_move(ROT *rot, int direction, int speed)
|
||||
{
|
||||
struct ars_priv_data *priv = (struct ars_priv_data *)rot->state.priv;
|
||||
hamlib_port_t *pport = &rot->state.rotport;
|
||||
hamlib_port_t *pport = ROTPORT(rot);
|
||||
int need_settle_delay = 0;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s called%s%s%s%s%s\n", __func__,
|
||||
|
@ -608,7 +608,7 @@ ars_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
|
|||
{
|
||||
const struct ars_priv_data *priv = (struct ars_priv_data *)rot->state.priv;
|
||||
struct rot_state *rs = &rot->state;
|
||||
hamlib_port_t *pport = &rs->rotport;
|
||||
hamlib_port_t *pport = ROTPORT(rot);
|
||||
int i, num_sample;
|
||||
unsigned az_samples[NUM_SAMPLES], az_value;
|
||||
unsigned el_samples[NUM_SAMPLES], el_value;
|
||||
|
|
|
@ -50,20 +50,18 @@ static int
|
|||
celestron_transaction(ROT *rot, const char *cmdstr,
|
||||
char *data, size_t data_len)
|
||||
{
|
||||
struct rot_state *rs;
|
||||
hamlib_port_t *rotp = ROTPORT(rot);
|
||||
int retval;
|
||||
int retry_read = 0;
|
||||
char replybuf[BUFSZ];
|
||||
|
||||
rs = &rot->state;
|
||||
|
||||
transaction_write:
|
||||
|
||||
rig_flush(&rs->rotport);
|
||||
rig_flush(rotp);
|
||||
|
||||
if (cmdstr)
|
||||
{
|
||||
retval = write_block(&rs->rotport, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
retval = write_block(rotp, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -84,12 +82,12 @@ transaction_write:
|
|||
|
||||
/* the answer */
|
||||
memset(data, 0, data_len);
|
||||
retval = read_string(&rs->rotport, (unsigned char *) data, data_len,
|
||||
retval = read_string(rotp, (unsigned char *) data, data_len,
|
||||
ACK, strlen(ACK), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
if (retry_read++ < rot->state.rotport.retry)
|
||||
if (retry_read++ < rotp->retry)
|
||||
{
|
||||
goto transaction_write;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
static int
|
||||
easycomm_transaction(ROT *rot, const char *cmdstr, char *data, size_t data_len)
|
||||
{
|
||||
struct rot_state *rs;
|
||||
hamlib_port_t *rotp = ROTPORT(rot);
|
||||
int retval;
|
||||
int retry = rot->caps->retry;
|
||||
|
||||
|
@ -59,12 +59,10 @@ easycomm_transaction(ROT *rot, const char *cmdstr, char *data, size_t data_len)
|
|||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
rs = &rot->state;
|
||||
|
||||
do
|
||||
{
|
||||
rig_flush(&rs->rotport);
|
||||
retval = write_block(&rs->rotport, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
rig_flush(rotp);
|
||||
retval = write_block(rotp, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -76,7 +74,7 @@ easycomm_transaction(ROT *rot, const char *cmdstr, char *data, size_t data_len)
|
|||
return RIG_OK; /* don't want a reply */
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rotport, (unsigned char *) data, data_len,
|
||||
retval = read_string(rotp, (unsigned char *) data, data_len,
|
||||
"\n", 1, 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
|
|
|
@ -42,8 +42,9 @@
|
|||
static int ether_transaction(ROT *rot, char *cmd, int len, char *buf)
|
||||
{
|
||||
int ret;
|
||||
hamlib_port_t *rotp = ROTPORT(rot);
|
||||
|
||||
ret = write_block(&rot->state.rotport, (unsigned char *) cmd, len);
|
||||
ret = write_block(rotp, (unsigned char *) cmd, len);
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "function %s(1): ret=%d || send=%s\n", __func__,
|
||||
ret, cmd);
|
||||
|
||||
|
@ -52,7 +53,7 @@ static int ether_transaction(ROT *rot, char *cmd, int len, char *buf)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX,
|
||||
ret = read_string(rotp, (unsigned char *) buf, BUF_MAX,
|
||||
"\n", sizeof("\n"), 0, 1);
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "function %s(2): ret=%d || receive=%s\n", __func__,
|
||||
ret, buf);
|
||||
|
@ -118,7 +119,7 @@ static int ether_rot_close(ROT *rot)
|
|||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
/* clean signoff, no read back */
|
||||
write_block(&rot->state.rotport, (unsigned char *) "\n", 1);
|
||||
write_block(ROTPORT(rot), (unsigned char *) "\n", 1);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
|
|
@ -71,14 +71,15 @@ static int flir_request(ROT *rot, char *request, char *response,
|
|||
int resp_size)
|
||||
{
|
||||
int return_value = -RIG_EINVAL;
|
||||
hamlib_port_t *rotp = ROTPORT(rot);
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
rig_flush(&rot->state.rotport);
|
||||
rig_flush(rotp);
|
||||
|
||||
if (request)
|
||||
{
|
||||
return_value = write_block(&rot->state.rotport, (unsigned char *)request,
|
||||
return_value = write_block(rotp, (unsigned char *)request,
|
||||
strlen(request));
|
||||
|
||||
if (return_value != RIG_OK)
|
||||
|
@ -94,10 +95,10 @@ static int flir_request(ROT *rot, char *request, char *response,
|
|||
int retry_read = 0;
|
||||
int read_char;
|
||||
|
||||
while (retry_read < rot->state.rotport.retry)
|
||||
while (retry_read < rotp->retry)
|
||||
{
|
||||
memset(response, 0, (size_t)resp_size);
|
||||
read_char = read_string(&rot->state.rotport, (unsigned char *)response,
|
||||
read_char = read_string(rotp, (unsigned char *)response,
|
||||
resp_size,
|
||||
"\r\n", sizeof("\r\n"), 0, 1);
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ fodtrack_set_position(ROT *rot, azimuth_t az, elevation_t el)
|
|||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s called: %f %f\n", __func__, az, el);
|
||||
|
||||
pport = &rot->state.rotport;
|
||||
pport = ROTPORT(rot);
|
||||
|
||||
retval = setDirection(pport, el / (float)rot->state.max_el * 255.0, 0);
|
||||
|
||||
|
|
|
@ -116,6 +116,7 @@ grbl_request(ROT *rot, char *request, uint32_t req_size, char *response,
|
|||
uint32_t *resp_size)
|
||||
{
|
||||
static int fail_count = 0;
|
||||
hamlib_port_t *rotp = ROTPORT(rot);
|
||||
|
||||
rot_debug(RIG_DEBUG_ERR, "req: [%s][%d]\n", request, fail_count);
|
||||
|
||||
|
@ -125,7 +126,7 @@ grbl_request(ROT *rot, char *request, uint32_t req_size, char *response,
|
|||
int retval;
|
||||
//fprintf(stderr, "ctrl by serial/network\n");
|
||||
|
||||
if ((retval = write_block(&rot->state.rotport, (unsigned char *)request,
|
||||
if ((retval = write_block(rotp, (unsigned char *)request,
|
||||
req_size)) != RIG_OK)
|
||||
{
|
||||
rot_debug(RIG_DEBUG_ERR, "%s write_block fail!\n", __func__);
|
||||
|
@ -138,11 +139,11 @@ grbl_request(ROT *rot, char *request, uint32_t req_size, char *response,
|
|||
fail_count = 0;
|
||||
}
|
||||
|
||||
rig_flush(&rot->state.rotport);
|
||||
rig_flush(rotp);
|
||||
|
||||
usleep(300000);
|
||||
|
||||
if ((retval = read_string(&rot->state.rotport, (unsigned char *)response, 1024,
|
||||
if ((retval = read_string(rotp, (unsigned char *)response, 1024,
|
||||
"\n", 1, 0, 1)) < 0)
|
||||
{
|
||||
rot_debug(RIG_DEBUG_ERR, "%s read_string fail! (%d) \n", __func__, retval);
|
||||
|
@ -161,7 +162,7 @@ grbl_request(ROT *rot, char *request, uint32_t req_size, char *response,
|
|||
return -RIG_EPROTO;
|
||||
}
|
||||
|
||||
rig_flush(&rot->state.rotport);
|
||||
rig_flush(rotp);
|
||||
|
||||
rot_debug(RIG_DEBUG_ERR, "rsp: [%s]\n", response);
|
||||
//fprintf(stderr, "rsp: [%s]\n", response);
|
||||
|
@ -461,9 +462,9 @@ grbltrk_rot_init(ROT *rot)
|
|||
static int
|
||||
grbl_net_open(ROT *rot, int port)
|
||||
{
|
||||
//network_open(&rot->state.rotport, port);
|
||||
//network_open(ROTPORT(rot), port);
|
||||
|
||||
//rot_debug(RIG_DEBUG_ERR, "%s:%d network_fd: %d\n", __func__, __LINE__, (&rot->state.rotport)->fd);
|
||||
//rot_debug(RIG_DEBUG_ERR, "%s:%d network_fd: %d\n", __func__, __LINE__, ROTPORT(rot)->fd);
|
||||
rot_debug(RIG_DEBUG_ERR, "%s:%d \n", __func__, __LINE__);
|
||||
|
||||
return 0;
|
||||
|
@ -514,7 +515,7 @@ grbltrk_rot_open(ROT *rot)
|
|||
static void
|
||||
grbl_net_close(ROT *rot)
|
||||
{
|
||||
port_close(&rot->state.rotport, RIG_PORT_NETWORK);
|
||||
port_close(ROTPORT(rot), RIG_PORT_NETWORK);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -52,19 +52,17 @@ static int
|
|||
gs232_transaction(ROT *rot, const char *cmdstr,
|
||||
char *data, size_t data_len)
|
||||
{
|
||||
struct rot_state *rs;
|
||||
hamlib_port_t *rotp = ROTPORT(rot);
|
||||
int retval;
|
||||
int retry_read = 0;
|
||||
|
||||
rs = &rot->state;
|
||||
|
||||
transaction_write:
|
||||
|
||||
rig_flush(&rs->rotport);
|
||||
rig_flush(rotp);
|
||||
|
||||
if (cmdstr)
|
||||
{
|
||||
retval = write_block(&rs->rotport, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
retval = write_block(rotp, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -84,12 +82,12 @@ transaction_write:
|
|||
}
|
||||
|
||||
memset(data, 0, data_len);
|
||||
retval = read_string(&rs->rotport, (unsigned char *) data, data_len,
|
||||
retval = read_string(rotp, (unsigned char *) data, data_len,
|
||||
REPLY_EOM, strlen(REPLY_EOM), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
if (retry_read++ < rot->state.rotport.retry)
|
||||
if (retry_read++ < rotp->retry)
|
||||
{
|
||||
goto transaction_write;
|
||||
}
|
||||
|
@ -105,7 +103,7 @@ transaction_write:
|
|||
rig_debug(RIG_DEBUG_ERR, "%s: Command is not correctly terminated '%s'\n",
|
||||
__func__, data);
|
||||
|
||||
if (retry_read++ < rig->state.rotport.retry)
|
||||
if (retry_read++ < rotp->retry)
|
||||
{
|
||||
goto transaction_write;
|
||||
}
|
||||
|
@ -139,7 +137,7 @@ static int
|
|||
gs232_wo_transaction(ROT *rot, const char *cmdstr,
|
||||
char *data, size_t data_len)
|
||||
{
|
||||
return write_block(&rot->state.rotport, (unsigned char *) cmdstr,
|
||||
return write_block(ROTPORT(rot), (unsigned char *) cmdstr,
|
||||
strlen(cmdstr));
|
||||
}
|
||||
|
||||
|
|
|
@ -64,19 +64,17 @@ static int
|
|||
gs232a_transaction(ROT *rot, const char *cmdstr,
|
||||
char *data, size_t data_len, int no_reply)
|
||||
{
|
||||
struct rot_state *rs;
|
||||
hamlib_port_t *rotp = ROTPORT(rot);
|
||||
int retval;
|
||||
int retry_read = 0;
|
||||
|
||||
rs = &rot->state;
|
||||
|
||||
transaction_write:
|
||||
|
||||
rig_flush(&rs->rotport);
|
||||
rig_flush(rotp);
|
||||
|
||||
if (cmdstr)
|
||||
{
|
||||
retval = write_block(&rs->rotport, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
retval = write_block(rotp, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -98,7 +96,7 @@ transaction_write:
|
|||
if (!no_reply)
|
||||
{
|
||||
memset(data, 0, data_len);
|
||||
retval = read_string(&rs->rotport, (unsigned char *) data, data_len,
|
||||
retval = read_string(rotp, (unsigned char *) data, data_len,
|
||||
REPLY_EOM, strlen(REPLY_EOM), 0, 1);
|
||||
|
||||
if (strncmp(data, "\r\n", 2) == 0
|
||||
|
@ -112,7 +110,7 @@ transaction_write:
|
|||
|
||||
if (retval < 0)
|
||||
{
|
||||
if (retry_read++ < rot->state.rotport.retry)
|
||||
if (retry_read++ < rotp->retry)
|
||||
{
|
||||
goto transaction_write;
|
||||
}
|
||||
|
@ -129,7 +127,7 @@ transaction_write:
|
|||
rig_debug(RIG_DEBUG_ERR, "%s: Command is not correctly terminated '%s'\n",
|
||||
__func__, data);
|
||||
|
||||
if (retry_read++ < rig->state.rotport.retry)
|
||||
if (retry_read++ < rotp->retry)
|
||||
{
|
||||
goto transaction_write;
|
||||
}
|
||||
|
|
|
@ -60,19 +60,17 @@ static int
|
|||
gs232b_transaction(ROT *rot, const char *cmdstr,
|
||||
char *data, size_t data_len, int no_reply)
|
||||
{
|
||||
struct rot_state *rs;
|
||||
hamlib_port_t *rotp = ROTPORT(rot);
|
||||
int retval;
|
||||
int retry_read = 0;
|
||||
|
||||
rs = &rot->state;
|
||||
|
||||
transaction_write:
|
||||
|
||||
rig_flush(&rs->rotport);
|
||||
rig_flush(rotp);
|
||||
|
||||
if (cmdstr)
|
||||
{
|
||||
retval = write_block(&rs->rotport, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
retval = write_block(rotp, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -81,7 +79,7 @@ transaction_write:
|
|||
|
||||
if (!data)
|
||||
{
|
||||
write_block(&rs->rotport, (unsigned char *) EOM, strlen(EOM));
|
||||
write_block(rotp, (unsigned char *) EOM, strlen(EOM));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,7 +98,7 @@ transaction_write:
|
|||
|
||||
|
||||
memset(data, 0, data_len);
|
||||
retval = read_string(&rs->rotport, (unsigned char *) data, data_len,
|
||||
retval = read_string(rotp, (unsigned char *) data, data_len,
|
||||
REPLY_EOM, strlen(REPLY_EOM), 0, 1);
|
||||
|
||||
if (strncmp(data, "\r\n", 2) == 0 || strchr(data, '>'))
|
||||
|
@ -114,7 +112,7 @@ transaction_write:
|
|||
|
||||
if (retval < 0)
|
||||
{
|
||||
if (retry_read++ < rot->state.rotport.retry)
|
||||
if (retry_read++ < rotp->retry)
|
||||
{
|
||||
goto transaction_write;
|
||||
}
|
||||
|
@ -131,7 +129,7 @@ transaction_write:
|
|||
"%s: Command is not correctly terminated '%s'\n",
|
||||
__func__, data);
|
||||
|
||||
if (retry_read++ < rig->state.rotport.retry)
|
||||
if (retry_read++ < rotp->retry)
|
||||
{
|
||||
goto transaction_write;
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ static int hd1780_rot_init(ROT *rot)
|
|||
|
||||
priv = rot->state.priv;
|
||||
|
||||
rot->state.rotport.type.rig = RIG_PORT_SERIAL;
|
||||
ROTPORT(rot)->type.rig = RIG_PORT_SERIAL;
|
||||
|
||||
priv->az = 0;
|
||||
|
||||
|
@ -166,7 +166,6 @@ static int hd1780_rot_cleanup(ROT *rot)
|
|||
static int hd1780_rot_set_position(ROT *rot, azimuth_t azimuth,
|
||||
elevation_t elevation)
|
||||
{
|
||||
struct rot_state *rs;
|
||||
char cmdstr[8];
|
||||
const char execstr[5] = "\r", ok[3];
|
||||
int err;
|
||||
|
@ -203,8 +202,7 @@ static int hd1780_rot_set_position(ROT *rot, azimuth_t azimuth,
|
|||
/* We need to look for the <CR> +<LF> to signify that everything finished. The HD 1780
|
||||
* sends a <CR> when it is finished rotating.
|
||||
*/
|
||||
rs = &rot->state;
|
||||
err = read_block(&rs->rotport, (unsigned char *) ok, 2);
|
||||
err = read_block(ROTPORT(rot), (unsigned char *) ok, 2);
|
||||
|
||||
if (err != 2)
|
||||
{
|
||||
|
@ -231,7 +229,6 @@ static int hd1780_rot_set_position(ROT *rot, azimuth_t azimuth,
|
|||
static int hd1780_rot_get_position(ROT *rot, azimuth_t *azimuth,
|
||||
elevation_t *elevation)
|
||||
{
|
||||
struct rot_state *rs;
|
||||
const char cmdstr[3] = "b\r";
|
||||
char az[7]; /* read azimuth string */
|
||||
char *p;
|
||||
|
@ -252,8 +249,7 @@ static int hd1780_rot_get_position(ROT *rot, azimuth_t *azimuth,
|
|||
return err;
|
||||
}
|
||||
|
||||
rs = &rot->state;
|
||||
err = read_block(&rs->rotport, (unsigned char *) az, AZ_READ_LEN);
|
||||
err = read_block(ROTPORT(rot), (unsigned char *) az, AZ_READ_LEN);
|
||||
|
||||
if (err != AZ_READ_LEN)
|
||||
{
|
||||
|
@ -300,7 +296,6 @@ static int hd1780_rot_get_position(ROT *rot, azimuth_t *azimuth,
|
|||
|
||||
static int hd1780_send_priv_cmd(ROT *rot, const char *cmdstr)
|
||||
{
|
||||
struct rot_state *rs;
|
||||
int err;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
@ -310,9 +305,7 @@ static int hd1780_send_priv_cmd(ROT *rot, const char *cmdstr)
|
|||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
rs = &rot->state;
|
||||
|
||||
err = write_block(&rs->rotport, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
err = write_block(ROTPORT(rot), (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
|
||||
if (err != RIG_OK)
|
||||
{
|
||||
|
|
|
@ -63,19 +63,17 @@
|
|||
static int
|
||||
ioptron_transaction(ROT *rot, const char *cmdstr, char *data, size_t resp_len)
|
||||
{
|
||||
struct rot_state *rs;
|
||||
hamlib_port_t *rotp = ROTPORT(rot);
|
||||
int retval = 0;
|
||||
int retry_read;
|
||||
|
||||
rs = &rot->state;
|
||||
|
||||
for (retry_read = 0; retry_read <= rot->state.rotport.retry; retry_read++)
|
||||
for (retry_read = 0; retry_read <= rotp->retry; retry_read++)
|
||||
{
|
||||
rig_flush(&rs->rotport);
|
||||
rig_flush(rotp);
|
||||
|
||||
if (cmdstr)
|
||||
{
|
||||
retval = write_block(&rs->rotport, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
retval = write_block(rotp, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -85,7 +83,7 @@ ioptron_transaction(ROT *rot, const char *cmdstr, char *data, size_t resp_len)
|
|||
|
||||
/** the answer */
|
||||
memset(data, 0, resp_len + 1);
|
||||
retval = read_block(&rs->rotport, (unsigned char *) data, resp_len);
|
||||
retval = read_block(rotp, (unsigned char *) data, resp_len);
|
||||
|
||||
/** if expected number of bytes received, return OK status */
|
||||
if (retval == resp_len)
|
||||
|
|
|
@ -163,20 +163,18 @@ static int
|
|||
rc2800_transaction(ROT *rot, const char *cmdstr,
|
||||
char *data, size_t data_len)
|
||||
{
|
||||
struct rot_state *rs;
|
||||
hamlib_port_t *rotp = ROTPORT(rot);
|
||||
int retval;
|
||||
int retry_read = 0;
|
||||
char replybuf[BUFSZ];
|
||||
|
||||
rs = &rot->state;
|
||||
|
||||
transaction_write:
|
||||
|
||||
rig_flush(&rs->rotport);
|
||||
rig_flush(rotp);
|
||||
|
||||
if (cmdstr)
|
||||
{
|
||||
retval = write_block(&rs->rotport, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
retval = write_block(rotp, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -197,7 +195,7 @@ transaction_write:
|
|||
|
||||
/* then comes the answer */
|
||||
memset(data, 0, data_len);
|
||||
retval = read_string(&rs->rotport, (unsigned char *) data, data_len, CR LF,
|
||||
retval = read_string(rotp, (unsigned char *) data, data_len, CR LF,
|
||||
strlen(CR LF), 0, 1);
|
||||
|
||||
// some models seem to echo -- so we'll check and read again if echoed
|
||||
|
@ -205,7 +203,7 @@ transaction_write:
|
|||
if (cmdstr && strncmp(data, cmdstr, strlen(data) - 1) == 0)
|
||||
{
|
||||
memset(data, 0, data_len);
|
||||
retval = read_string(&rs->rotport, (unsigned char *) data, data_len, CR LF,
|
||||
retval = read_string(rotp, (unsigned char *) data, data_len, CR LF,
|
||||
strlen(CR LF), 0, 1);
|
||||
}
|
||||
|
||||
|
@ -213,13 +211,13 @@ transaction_write:
|
|||
if (strlen(data) == 1)
|
||||
{
|
||||
memset(data, 0, data_len);
|
||||
retval = read_string(&rs->rotport, (unsigned char *) data, data_len, CR LF,
|
||||
retval = read_string(rotp, (unsigned char *) data, data_len, CR LF,
|
||||
strlen(CR LF), 0, 1);
|
||||
}
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
if (retry_read++ < rot->state.rotport.retry)
|
||||
if (retry_read++ < rotp->retry)
|
||||
{
|
||||
goto transaction_write;
|
||||
}
|
||||
|
|
|
@ -96,20 +96,18 @@ struct meade_priv_data
|
|||
static int meade_transaction(ROT *rot, const char *cmdstr,
|
||||
char *data, size_t *data_len, size_t expected_return_length)
|
||||
{
|
||||
struct rot_state *rs;
|
||||
hamlib_port_t *rotp = ROTPORT(rot);
|
||||
int return_value;
|
||||
int retry_read = 0;
|
||||
|
||||
rs = &rot->state;
|
||||
|
||||
while (1)
|
||||
{
|
||||
transaction:
|
||||
rig_flush(&rs->rotport);
|
||||
rig_flush(rotp);
|
||||
|
||||
if (cmdstr)
|
||||
{
|
||||
return_value = write_block(&rs->rotport, (unsigned char *) cmdstr,
|
||||
return_value = write_block(rotp, (unsigned char *) cmdstr,
|
||||
strlen(cmdstr));
|
||||
|
||||
if (return_value != RIG_OK)
|
||||
|
@ -123,7 +121,7 @@ transaction:
|
|||
return value is expected, Strings end with '#' */
|
||||
if (data != NULL)
|
||||
{
|
||||
return_value = read_string(&rs->rotport, (unsigned char *) data,
|
||||
return_value = read_string(rotp, (unsigned char *) data,
|
||||
expected_return_length + 1,
|
||||
"\r\n", strlen("\r\n"), 0, 1);
|
||||
|
||||
|
@ -134,7 +132,7 @@ transaction:
|
|||
}
|
||||
else
|
||||
{
|
||||
if (retry_read++ >= rot->state.rotport.retry)
|
||||
if (retry_read++ >= rotp->retry)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: read_string error %s\n", __func__,
|
||||
rigerror(return_value));
|
||||
|
@ -173,7 +171,7 @@ static int meade_init(ROT *rot)
|
|||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called version %s\n", __func__,
|
||||
rot->caps->version);
|
||||
rot->state.rotport.type.rig = RIG_PORT_SERIAL;
|
||||
ROTPORT(rot)->type.rig = RIG_PORT_SERIAL;
|
||||
|
||||
priv->az = priv->el = 0;
|
||||
|
||||
|
|
|
@ -62,20 +62,18 @@ struct prosistel_rot_priv_caps
|
|||
static int prosistel_transaction(ROT *rot, const char *cmdstr,
|
||||
char *data, size_t data_len)
|
||||
{
|
||||
struct rot_state *rs;
|
||||
hamlib_port_t *rotp = ROTPORT(rot);
|
||||
int retval;
|
||||
int retry_read = 0;
|
||||
char replybuf[BUFSZ];
|
||||
|
||||
rs = &rot->state;
|
||||
|
||||
transaction_write:
|
||||
|
||||
rig_flush(&rs->rotport);
|
||||
rig_flush(rotp);
|
||||
|
||||
if (cmdstr)
|
||||
{
|
||||
retval = write_block(&rs->rotport, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
retval = write_block(rotp, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -95,12 +93,12 @@ transaction_write:
|
|||
}
|
||||
|
||||
// Remember to check for STXA,G,R or STXA,?,XXX,R 10 bytes
|
||||
retval = read_string(&rs->rotport, (unsigned char *) data, 20, CR, strlen(CR),
|
||||
retval = read_string(rotp, (unsigned char *) data, 20, CR, strlen(CR),
|
||||
0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
if (retry_read++ < rot->state.rotport.retry)
|
||||
if (retry_read++ < rotp->retry)
|
||||
{
|
||||
goto transaction_write;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
static int
|
||||
radant_transaction(ROT *rot, const char *cmdstr, char *data, size_t data_len)
|
||||
{
|
||||
struct rot_state *rs;
|
||||
hamlib_port_t *rotp = ROTPORT(rot);
|
||||
int retval;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s called: %s\n", __func__, cmdstr);
|
||||
|
@ -59,9 +59,8 @@ radant_transaction(ROT *rot, const char *cmdstr, char *data, size_t data_len)
|
|||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
rs = &rot->state;
|
||||
rig_flush(&rs->rotport);
|
||||
retval = write_block(&rs->rotport, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
rig_flush(rotp);
|
||||
retval = write_block(rotp, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -73,8 +72,7 @@ radant_transaction(ROT *rot, const char *cmdstr, char *data, size_t data_len)
|
|||
return RIG_OK; /* don't want a reply */
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rotport, (unsigned char *) data, data_len, "\n", 1, 0,
|
||||
1);
|
||||
retval = read_string(rotp, (unsigned char *) data, data_len, "\n", 1, 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -421,7 +421,7 @@ static int rotorez_rot_init(ROT *rot)
|
|||
return -RIG_ENOMEM;
|
||||
}
|
||||
|
||||
rot->state.rotport.type.rig = RIG_PORT_SERIAL;
|
||||
ROTPORT(rot)->type.rig = RIG_PORT_SERIAL;
|
||||
|
||||
((struct rotorez_rot_priv_data *)rot->state.priv)->az = 0;
|
||||
|
||||
|
@ -538,7 +538,7 @@ static int rt21_rot_set_position(ROT *rot, azimuth_t azimuth,
|
|||
return err;
|
||||
}
|
||||
|
||||
if (rot->state.rotport2.pathname[0] != 0)
|
||||
if (ROTPORT2(rot)->pathname[0] != 0)
|
||||
{
|
||||
SNPRINTF(cmdstr, sizeof(cmdstr), "AP1%05.1f\r;",
|
||||
elevation); /* Total field width of 5 chars */
|
||||
|
@ -565,7 +565,8 @@ static int rt21_rot_set_position(ROT *rot, azimuth_t azimuth,
|
|||
static int rotorez_rot_get_position(ROT *rot, azimuth_t *azimuth,
|
||||
elevation_t *elevation)
|
||||
{
|
||||
struct rot_state *rs;
|
||||
hamlib_port_t *rotp;
|
||||
hamlib_port_t *rotp2;
|
||||
const char cmdstr[5] = "AI1;";
|
||||
char az[5]; /* read azimuth string */
|
||||
char *p;
|
||||
|
@ -578,6 +579,8 @@ static int rotorez_rot_get_position(ROT *rot, azimuth_t *azimuth,
|
|||
{
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
rotp = ROTPORT(rot);
|
||||
rotp2 = ROTPORT2(rot);
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -588,9 +591,7 @@ static int rotorez_rot_get_position(ROT *rot, azimuth_t *azimuth,
|
|||
return err;
|
||||
}
|
||||
|
||||
rs = &rot->state;
|
||||
|
||||
err = read_block(&rs->rotport, (unsigned char *) az, AZ_READ_LEN);
|
||||
err = read_block(rotp, (unsigned char *) az, AZ_READ_LEN);
|
||||
|
||||
if (err != AZ_READ_LEN)
|
||||
{
|
||||
|
@ -653,7 +654,7 @@ static int rotorez_rot_get_position(ROT *rot, azimuth_t *azimuth,
|
|||
|
||||
*azimuth = tmp;
|
||||
|
||||
if (strlen(rot->state.rotport2.pathname) > 0)
|
||||
if (strlen(rotp2->pathname) > 0)
|
||||
{
|
||||
do
|
||||
{
|
||||
|
@ -664,9 +665,9 @@ static int rotorez_rot_get_position(ROT *rot, azimuth_t *azimuth,
|
|||
return err;
|
||||
}
|
||||
|
||||
rs = &rot->state;
|
||||
|
||||
err = read_block(&rs->rotport, (unsigned char *) az, AZ_READ_LEN);
|
||||
//TODO: Should this be rotp or rotp2????
|
||||
//err = read_block(&rs->rotport, (unsigned char *) az, AZ_READ_LEN);
|
||||
err = read_block(rotp, (unsigned char *) az, AZ_READ_LEN);
|
||||
|
||||
if (err != AZ_READ_LEN)
|
||||
{
|
||||
|
@ -732,7 +733,6 @@ static int rotorez_rot_get_position(ROT *rot, azimuth_t *azimuth,
|
|||
static int erc_rot_get_position(ROT *rot, azimuth_t *azimuth,
|
||||
elevation_t *elevation)
|
||||
{
|
||||
struct rot_state *rs;
|
||||
const char cmdstr[5] = "AI1;";
|
||||
char az[5]; /* read azimuth string */
|
||||
char *p;
|
||||
|
@ -755,9 +755,7 @@ static int erc_rot_get_position(ROT *rot, azimuth_t *azimuth,
|
|||
return err;
|
||||
}
|
||||
|
||||
rs = &rot->state;
|
||||
|
||||
err = read_block(&rs->rotport, (unsigned char *) az, AZ_READ_LEN);
|
||||
err = read_block(ROTPORT(rot), (unsigned char *) az, AZ_READ_LEN);
|
||||
|
||||
if (err != AZ_READ_LEN)
|
||||
{
|
||||
|
@ -850,7 +848,8 @@ static int erc_rot_get_position(ROT *rot, azimuth_t *azimuth,
|
|||
static int rt21_rot_get_position(ROT *rot, azimuth_t *azimuth,
|
||||
elevation_t *elevation)
|
||||
{
|
||||
struct rot_state *rs;
|
||||
hamlib_port_t *rotp;
|
||||
hamlib_port_t *rotp2;
|
||||
char az[8]; /* read azimuth string */
|
||||
int err;
|
||||
|
||||
|
@ -860,6 +859,8 @@ static int rt21_rot_get_position(ROT *rot, azimuth_t *azimuth,
|
|||
{
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
rotp = ROTPORT(rot);
|
||||
rotp2 = ROTPORT2(rot);
|
||||
|
||||
/* 'BI1' is an RT-21 specific command that queries for a floating
|
||||
* point position (to the tenth of a degree).
|
||||
|
@ -871,9 +872,7 @@ static int rt21_rot_get_position(ROT *rot, azimuth_t *azimuth,
|
|||
return err;
|
||||
}
|
||||
|
||||
rs = &rot->state;
|
||||
|
||||
err = read_string(&rs->rotport, (unsigned char *) az, RT21_AZ_LEN + 1, ";",
|
||||
err = read_string(rotp, (unsigned char *) az, RT21_AZ_LEN + 1, ";",
|
||||
strlen(";"), 0, 1);
|
||||
|
||||
if (err < 0) /* read_string returns negative on error. */
|
||||
|
@ -906,7 +905,7 @@ static int rt21_rot_get_position(ROT *rot, azimuth_t *azimuth,
|
|||
|
||||
*azimuth = tmp;
|
||||
|
||||
if (strlen(rot->state.rotport2.pathname) > 0)
|
||||
if (rotp2 && strlen(rotp2->pathname) > 0)
|
||||
{
|
||||
err = rotorez_send_priv_cmd2(rot, "BI1;");
|
||||
|
||||
|
@ -915,9 +914,7 @@ static int rt21_rot_get_position(ROT *rot, azimuth_t *azimuth,
|
|||
return err;
|
||||
}
|
||||
|
||||
rs = &rot->state;
|
||||
|
||||
err = read_string(&rs->rotport2, (unsigned char *) az, RT21_AZ_LEN + 1, ";",
|
||||
err = read_string(rotp2, (unsigned char *) az, RT21_AZ_LEN + 1, ";",
|
||||
strlen(";"), 0, 1);
|
||||
|
||||
if (err < 0) /* read_string returns negative on error. */
|
||||
|
@ -1134,7 +1131,6 @@ static const char *rotorez_rot_get_info(ROT *rot)
|
|||
|
||||
static int rotorez_send_priv_cmd(ROT *rot, const char *cmdstr)
|
||||
{
|
||||
struct rot_state *rs;
|
||||
int err;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
@ -1144,8 +1140,7 @@ static int rotorez_send_priv_cmd(ROT *rot, const char *cmdstr)
|
|||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
rs = &rot->state;
|
||||
err = write_block(&rs->rotport, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
err = write_block(ROTPORT(rot), (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
|
||||
if (err != RIG_OK)
|
||||
{
|
||||
|
@ -1158,7 +1153,6 @@ static int rotorez_send_priv_cmd(ROT *rot, const char *cmdstr)
|
|||
// send command to 2nd rotator port
|
||||
static int rotorez_send_priv_cmd2(ROT *rot, const char *cmdstr)
|
||||
{
|
||||
struct rot_state *rs;
|
||||
int err;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
@ -1168,8 +1162,7 @@ static int rotorez_send_priv_cmd2(ROT *rot, const char *cmdstr)
|
|||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
rs = &rot->state;
|
||||
err = write_block(&rs->rotport2, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
err = write_block(ROTPORT2(rot), (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
|
||||
if (err != RIG_OK)
|
||||
{
|
||||
|
@ -1193,7 +1186,6 @@ static int rotorez_send_priv_cmd2(ROT *rot, const char *cmdstr)
|
|||
|
||||
static int rotorez_flush_buffer(ROT *rot)
|
||||
{
|
||||
struct rot_state *rs;
|
||||
char garbage[32]; /* read buffer */
|
||||
int err = 0;
|
||||
size_t MAX = 31;
|
||||
|
@ -1205,11 +1197,9 @@ static int rotorez_flush_buffer(ROT *rot)
|
|||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
rs = &rot->state;
|
||||
|
||||
do
|
||||
{
|
||||
err = read_block(&rs->rotport, (unsigned char *) garbage, MAX);
|
||||
err = read_block(ROTPORT(rot), (unsigned char *) garbage, MAX);
|
||||
|
||||
/* Oops! An IO error was encountered. Bail out! */
|
||||
if (err == -RIG_EIO)
|
||||
|
|
|
@ -49,7 +49,7 @@ static int
|
|||
saebrtrack_transaction(ROT *rot, const char *cmdstr, char *data,
|
||||
size_t data_len)
|
||||
{
|
||||
struct rot_state *rs;
|
||||
hamlib_port_t *rotp = ROTPORT(rot);
|
||||
int retval;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s called: %s\n", __func__, cmdstr);
|
||||
|
@ -59,9 +59,8 @@ saebrtrack_transaction(ROT *rot, const char *cmdstr, char *data,
|
|||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
rs = &rot->state;
|
||||
rig_flush(&rs->rotport);
|
||||
retval = write_block(&rs->rotport, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
rig_flush(rotp);
|
||||
retval = write_block(rotp, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -73,7 +72,7 @@ saebrtrack_transaction(ROT *rot, const char *cmdstr, char *data,
|
|||
return RIG_OK; /* don't want a reply */
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rotport, (unsigned char *) data, data_len,
|
||||
retval = read_string(rotp, (unsigned char *) data, data_len,
|
||||
"\n", 1, 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
|
|
|
@ -124,7 +124,7 @@ static int sartek_rot_set_position(ROT *rot, azimuth_t azimuth,
|
|||
|
||||
SNPRINTF(cmdstr, sizeof(cmdstr), "P%c", (int)((azimuth * 255) / 360));
|
||||
|
||||
err = write_block(&rot->state.rotport, (unsigned char *) cmdstr,
|
||||
err = write_block(ROTPORT(rot), (unsigned char *) cmdstr,
|
||||
strlen(cmdstr));
|
||||
|
||||
if (err != RIG_OK)
|
||||
|
@ -147,7 +147,7 @@ static int sartek_rot_stop(ROT *rot)
|
|||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__);
|
||||
|
||||
err = write_block(&rot->state.rotport, (unsigned char *) "P\0", 2);
|
||||
err = write_block(ROTPORT(rot), (unsigned char *) "P\0", 2);
|
||||
|
||||
if (err != RIG_OK)
|
||||
{
|
||||
|
|
|
@ -109,17 +109,13 @@ struct satel_stat
|
|||
static int satel_cmd(ROT *rot, char *cmd, int cmdlen, char *res, int reslen)
|
||||
{
|
||||
int ret;
|
||||
struct rot_state *rs;
|
||||
|
||||
hamlib_port_t *rotp = ROTPORT(rot);
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
rig_flush(rotp);
|
||||
|
||||
rs = &rot->state;
|
||||
|
||||
rig_flush(&rs->rotport);
|
||||
|
||||
ret = write_block(&rs->rotport, (unsigned char *) cmd, cmdlen);
|
||||
ret = write_block(rotp, (unsigned char *) cmd, cmdlen);
|
||||
|
||||
if (ret != RIG_OK)
|
||||
{
|
||||
|
@ -128,7 +124,7 @@ static int satel_cmd(ROT *rot, char *cmd, int cmdlen, char *res, int reslen)
|
|||
|
||||
if (reslen > 0 && res != NULL)
|
||||
{
|
||||
ret = read_string(&rs->rotport, (unsigned char *) res, reslen, "\n", 1, 0, 1);
|
||||
ret = read_string(rotp, (unsigned char *) res, reslen, "\n", 1, 0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -146,16 +142,10 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
|
|||
char resbuf[BUF_SIZE];
|
||||
char *p;
|
||||
int ret;
|
||||
struct rot_state *rs;
|
||||
|
||||
|
||||
rs = &rot->state;
|
||||
|
||||
|
||||
hamlib_port_t *rotp = ROTPORT(rot);
|
||||
|
||||
// read motion state
|
||||
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0,
|
||||
1);
|
||||
ret = read_string(rotp, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -165,8 +155,7 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
|
|||
stat->motion_enabled = strcmp(resbuf, "Motion ENABLED") == 0 ? true : false;
|
||||
|
||||
// XXX skip mode
|
||||
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0,
|
||||
1);
|
||||
ret = read_string(rotp, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -174,8 +163,7 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
|
|||
}
|
||||
|
||||
// XXX skip time
|
||||
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0,
|
||||
1);
|
||||
ret = read_string(rotp, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -183,8 +171,7 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
|
|||
}
|
||||
|
||||
// read azimuth line
|
||||
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0,
|
||||
1);
|
||||
ret = read_string(rotp, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -196,8 +183,7 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
|
|||
stat->az = (int)strtof(p, NULL);
|
||||
|
||||
// read elevation line
|
||||
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0,
|
||||
1);
|
||||
ret = read_string(rotp, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -209,8 +195,7 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
|
|||
stat->el = (int)strtof(p, NULL);
|
||||
|
||||
// skip blank line
|
||||
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0,
|
||||
1);
|
||||
ret = read_string(rotp, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -218,15 +203,13 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
|
|||
}
|
||||
|
||||
// XXX skip stored position count
|
||||
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0,
|
||||
1);
|
||||
ret = read_string(rotp, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -306,7 +306,6 @@ static int spid_set_conf(ROT *rot, hamlib_token_t token, const char *val)
|
|||
static int spid_rot1prog_rot_set_position(ROT *rot, azimuth_t az,
|
||||
elevation_t el)
|
||||
{
|
||||
struct rot_state *rs = &rot->state;
|
||||
int retval;
|
||||
char cmdstr[13];
|
||||
unsigned int u_az;
|
||||
|
@ -329,7 +328,7 @@ static int spid_rot1prog_rot_set_position(ROT *rot, azimuth_t az,
|
|||
cmdstr[11] = 0x2F; /* K */
|
||||
cmdstr[12] = 0x20; /* END */
|
||||
|
||||
retval = spid_write(&rs->rotport, (unsigned char *) cmdstr, 13);
|
||||
retval = spid_write(ROTPORT(rot), (unsigned char *) cmdstr, 13);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -343,6 +342,7 @@ static int spid_rot2prog_rot_set_position(ROT *rot, azimuth_t az,
|
|||
elevation_t el)
|
||||
{
|
||||
struct rot_state *rs = &rot->state;
|
||||
hamlib_port_t *rotp = ROTPORT(rot);
|
||||
const struct spid_rot2prog_priv_data *priv = (struct spid_rot2prog_priv_data *)
|
||||
rs->priv;
|
||||
int retval;
|
||||
|
@ -356,7 +356,7 @@ static int spid_rot2prog_rot_set_position(ROT *rot, azimuth_t az,
|
|||
{
|
||||
do
|
||||
{
|
||||
retval = spid_write(&rs->rotport,
|
||||
retval = spid_write(rotp,
|
||||
(unsigned char *) "\x57\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1F\x20", 13);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -365,9 +365,9 @@ static int spid_rot2prog_rot_set_position(ROT *rot, azimuth_t az,
|
|||
}
|
||||
|
||||
memset(cmdstr, 0, 12);
|
||||
retval = read_r2p_frame(&rs->rotport, (unsigned char *) cmdstr, 12);
|
||||
retval = read_r2p_frame(rotp, (unsigned char *) cmdstr, 12);
|
||||
}
|
||||
while (retval < 0 && retry_read++ < rot->state.rotport.retry);
|
||||
while (retval < 0 && retry_read++ < rotp->retry);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
@ -397,7 +397,7 @@ static int spid_rot2prog_rot_set_position(ROT *rot, azimuth_t az,
|
|||
cmdstr[11] = 0x2F; /* K */
|
||||
cmdstr[12] = 0x20; /* END */
|
||||
|
||||
retval = spid_write(&rs->rotport, (unsigned char *) cmdstr, 13);
|
||||
retval = spid_write(rotp, (unsigned char *) cmdstr, 13);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -412,9 +412,9 @@ static int spid_rot2prog_rot_set_position(ROT *rot, azimuth_t az,
|
|||
|
||||
do
|
||||
{
|
||||
retval = read_r2p_frame(&rs->rotport, (unsigned char *) cmdstr, 12);
|
||||
retval = read_r2p_frame(rotp, (unsigned char *) cmdstr, 12);
|
||||
}
|
||||
while ((retval < 0) && (retry_read++ < rot->state.rotport.retry));
|
||||
while ((retval < 0) && (retry_read++ < rotp->retry));
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
|
@ -422,7 +422,7 @@ static int spid_rot2prog_rot_set_position(ROT *rot, azimuth_t az,
|
|||
|
||||
static int spid_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
|
||||
{
|
||||
struct rot_state *rs = &rot->state;
|
||||
hamlib_port_t *rotp = ROTPORT(rot);
|
||||
int retval;
|
||||
int retry_read = 0;
|
||||
char posbuf[12];
|
||||
|
@ -431,7 +431,7 @@ static int spid_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
|
|||
|
||||
do
|
||||
{
|
||||
retval = spid_write(&rs->rotport,
|
||||
retval = spid_write(rotp,
|
||||
(unsigned char *) "\x57\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1F\x20", 13);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -443,19 +443,19 @@ static int spid_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
|
|||
|
||||
if (rot->caps->rot_model == ROT_MODEL_SPID_ROT1PROG)
|
||||
{
|
||||
retval = read_r2p_frame(&rs->rotport, (unsigned char *) posbuf, 5);
|
||||
retval = read_r2p_frame(rotp, (unsigned char *) posbuf, 5);
|
||||
}
|
||||
else if (rot->caps->rot_model == ROT_MODEL_SPID_ROT2PROG ||
|
||||
rot->caps->rot_model == ROT_MODEL_SPID_MD01_ROT2PROG)
|
||||
{
|
||||
retval = read_r2p_frame(&rs->rotport, (unsigned char *) posbuf, 12);
|
||||
retval = read_r2p_frame(rotp, (unsigned char *) posbuf, 12);
|
||||
}
|
||||
else
|
||||
{
|
||||
retval = -RIG_EINVAL;
|
||||
}
|
||||
}
|
||||
while (retval < 0 && retry_read++ < rot->state.rotport.retry);
|
||||
while (retval < 0 && retry_read++ < rotp->retry);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
@ -494,7 +494,7 @@ static int spid_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
|
|||
|
||||
static int spid_rot_stop(ROT *rot)
|
||||
{
|
||||
struct rot_state *rs = &rot->state;
|
||||
hamlib_port_t *rotp = ROTPORT(rot);
|
||||
int retval;
|
||||
int retry_read = 0;
|
||||
char posbuf[12];
|
||||
|
@ -503,7 +503,7 @@ static int spid_rot_stop(ROT *rot)
|
|||
|
||||
do
|
||||
{
|
||||
retval = spid_write(&rs->rotport,
|
||||
retval = spid_write(rotp,
|
||||
(unsigned char *) "\x57\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0F\x20", 13);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -515,15 +515,15 @@ static int spid_rot_stop(ROT *rot)
|
|||
|
||||
if (rot->caps->rot_model == ROT_MODEL_SPID_ROT1PROG)
|
||||
{
|
||||
retval = read_r2p_frame(&rs->rotport, (unsigned char *) posbuf, 5);
|
||||
retval = read_r2p_frame(rotp, (unsigned char *) posbuf, 5);
|
||||
}
|
||||
else if (rot->caps->rot_model == ROT_MODEL_SPID_ROT2PROG ||
|
||||
rot->caps->rot_model == ROT_MODEL_SPID_MD01_ROT2PROG)
|
||||
{
|
||||
retval = read_r2p_frame(&rs->rotport, (unsigned char *) posbuf, 12);
|
||||
retval = read_r2p_frame(rotp, (unsigned char *) posbuf, 12);
|
||||
}
|
||||
}
|
||||
while (retval < 0 && retry_read++ < rot->state.rotport.retry);
|
||||
while (retval < 0 && retry_read++ < rotp->retry);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
@ -535,7 +535,6 @@ static int spid_rot_stop(ROT *rot)
|
|||
|
||||
static int spid_md01_rot2prog_rot_move(ROT *rot, int direction, int speed)
|
||||
{
|
||||
struct rot_state *rs = &rot->state;
|
||||
char dir = 0x00;
|
||||
int retval;
|
||||
char cmdstr[13];
|
||||
|
@ -578,7 +577,7 @@ static int spid_md01_rot2prog_rot_move(ROT *rot, int direction, int speed)
|
|||
moving at all), always send the stop command first. */
|
||||
spid_rot_stop(rot);
|
||||
|
||||
retval = spid_write(&rs->rotport, (unsigned char *) cmdstr, 13);
|
||||
retval = spid_write(ROTPORT(rot), (unsigned char *) cmdstr, 13);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ static int ts7400_rot_init(ROT *rot)
|
|||
|
||||
priv = rot->state.priv;
|
||||
|
||||
rot->state.rotport.type.rig = RIG_PORT_NONE;
|
||||
ROTPORT(rot)->type.rig = RIG_PORT_NONE;
|
||||
|
||||
priv->az = priv->el = 0;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ DISTCLEANFILES =
|
|||
|
||||
bin_PROGRAMS =
|
||||
|
||||
check_PROGRAMS = simelecraft simicgeneric simkenwood simyaesu simic9100 simic9700 simft991 simftdx1200 simftdx3000 simjupiter simpowersdr simid5100 simft736 simftdx5000 simtmd700 simrotorez simspid simft817 simts590 simft847 simic7300 simic7000 simic7100 simic7200 simatd578 simic905 simts450 simic7600 simic7610 simic705 simts950 simts990 simic7851 simftdx101 simxiegug90 simqrplabs simft818 simic275 simtrusdx simft1000 simtmd710 simts890 simxiegux108g
|
||||
check_PROGRAMS = simelecraft simicgeneric simkenwood simyaesu simic9100 simic9700 simft991 simftdx1200 simftdx3000 simjupiter simpowersdr simid5100 simft736 simftdx5000 simtmd700 simrotorez simspid simft817 simts590 simft847 simic7300 simic7000 simic7100 simic7200 simatd578 simic905 simts450 simic7600 simic7610 simic705 simts950 simts990 simic7851 simftdx101 simxiegug90 simqrplabs simft818 simic275 simtrusdx simft1000 simtmd710 simts890 simxiegux108g simxiegux6100
|
||||
|
||||
simelecraft_SOURCES = simelecraft.c
|
||||
simkenwood_SOURCES = simkenwood.c
|
||||
|
|
|
@ -115,7 +115,7 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
printf("%s\n", buf);
|
||||
hl_usleep(mysleep * 1000);
|
||||
pbuf = "RM5100000;";
|
||||
pbuf = "RM50005;";
|
||||
WRITE(fd, pbuf, strlen(pbuf));
|
||||
}
|
||||
|
||||
|
|
|
@ -277,6 +277,13 @@ void frameParse(int fd, unsigned char *frame, int len)
|
|||
write(fd, frame, 7);
|
||||
break;
|
||||
#endif
|
||||
case 0x19:
|
||||
frame[6] = 0x00;
|
||||
frame[7] = 0x80;
|
||||
frame[8] = 0xfd;
|
||||
write(fd, frame, 9);
|
||||
break;
|
||||
|
||||
|
||||
case 0x1a: // miscellaneous things
|
||||
switch (frame[5])
|
||||
|
|
|
@ -0,0 +1,505 @@
|
|||
// simicom will show the pts port to use for rigctl on Unix
|
||||
// using virtual serial ports on Windows is to be developed yet
|
||||
// Needs a lot of improvement to work on all Icoms
|
||||
// gcc -g -Wall -o simicom simicom.c -lhamlib
|
||||
// On mingw in the hamlib src directory
|
||||
// gcc -static -I../include -g -Wall -o simicom simicom.c -L../../build/src/.libs -lhamlib -lwsock32 -lws2_32
|
||||
#define _XOPEN_SOURCE 700
|
||||
// since we are POSIX here we need this
|
||||
#if 0
|
||||
struct ip_mreq
|
||||
{
|
||||
int dummy;
|
||||
};
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/time.h>
|
||||
#include <hamlib/rig.h>
|
||||
#include "../src/misc.h"
|
||||
|
||||
#define BUFSIZE 256
|
||||
#define X25
|
||||
|
||||
int civ_731_mode = 0;
|
||||
vfo_t current_vfo = RIG_VFO_A;
|
||||
int split = 0;
|
||||
|
||||
// we make B different from A to ensure we see a difference at startup
|
||||
float freqA = 14074000;
|
||||
float freqB = 14074500;
|
||||
mode_t modeA = RIG_MODE_CW;
|
||||
mode_t modeB = RIG_MODE_USB;
|
||||
int datamodeA = 0;
|
||||
int datamodeB = 0;
|
||||
pbwidth_t widthA = 0;
|
||||
pbwidth_t widthB = 1;
|
||||
ant_t ant_curr = 0;
|
||||
int ant_option = 0;
|
||||
int ptt = 0;
|
||||
int keyspd = 20;
|
||||
|
||||
void dumphex(const unsigned char *buf, int n)
|
||||
{
|
||||
for (int i = 0; i < n; ++i) { printf("%02x ", buf[i]); }
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int
|
||||
frameGet(int fd, unsigned char *buf)
|
||||
{
|
||||
int i = 0;
|
||||
memset(buf, 0, BUFSIZE);
|
||||
unsigned char c;
|
||||
|
||||
while (read(fd, &c, 1) > 0)
|
||||
{
|
||||
buf[i++] = c;
|
||||
//printf("i=%d, c=0x%02x\n",i,c);
|
||||
|
||||
if (c == 0xfd)
|
||||
{
|
||||
dumphex(buf, i);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
//printf("Error %s\n", strerror(errno));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void frameParse(int fd, unsigned char *frame, int len)
|
||||
{
|
||||
double freq;
|
||||
|
||||
dumphex(frame, len);
|
||||
|
||||
if (frame[0] != 0xfe && frame[1] != 0xfe)
|
||||
{
|
||||
printf("expected fe fe, got ");
|
||||
dumphex(frame, len);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (frame[4])
|
||||
{
|
||||
case 0x03:
|
||||
|
||||
//from_bcd(frameackbuf[2], (civ_731_mode ? 4 : 5) * 2);
|
||||
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN)
|
||||
{
|
||||
printf("get_freqA\n");
|
||||
to_bcd(&frame[5], (long long)freqA, (civ_731_mode ? 4 : 5) * 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("get_freqB\n");
|
||||
to_bcd(&frame[5], (long long)freqB, (civ_731_mode ? 4 : 5) * 2);
|
||||
}
|
||||
|
||||
frame[10] = 0xfd;
|
||||
write(fd, frame, 11);
|
||||
|
||||
break;
|
||||
|
||||
case 0x04:
|
||||
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN)
|
||||
{
|
||||
printf("get_modeA\n");
|
||||
frame[5] = modeA;
|
||||
frame[6] = widthA;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("get_modeB\n");
|
||||
frame[5] = modeB;
|
||||
frame[6] = widthB;
|
||||
}
|
||||
|
||||
frame[7] = 0xfd;
|
||||
write(fd, frame, 8);
|
||||
break;
|
||||
|
||||
case 0x05:
|
||||
freq = from_bcd(&frame[5], (civ_731_mode ? 4 : 5) * 2);
|
||||
printf("set_freq to %.0f\n", freq);
|
||||
|
||||
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { freqA = freq; }
|
||||
else { freqB = freq; }
|
||||
|
||||
frame[4] = 0xfb;
|
||||
frame[5] = 0xfd;
|
||||
write(fd, frame, 6);
|
||||
break;
|
||||
|
||||
case 0x06:
|
||||
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { modeA = frame[6]; }
|
||||
else { modeB = frame[6]; }
|
||||
|
||||
frame[4] = 0xfb;
|
||||
frame[5] = 0xfd;
|
||||
write(fd, frame, 6);
|
||||
break;
|
||||
|
||||
case 0x07:
|
||||
|
||||
switch (frame[5])
|
||||
{
|
||||
case 0x00: current_vfo = RIG_VFO_A; break;
|
||||
|
||||
case 0x01: current_vfo = RIG_VFO_B; break;
|
||||
|
||||
case 0xb0: freq = freqA; freqA = freqB; freqB = freq; break;
|
||||
|
||||
}
|
||||
|
||||
printf("set_vfo to %s\n", rig_strvfo(current_vfo));
|
||||
|
||||
frame[4] = 0xfb;
|
||||
frame[5] = 0xfd;
|
||||
write(fd, frame, 6);
|
||||
break;
|
||||
|
||||
case 0x0f:
|
||||
if (frame[5] == 0) { split = 0; }
|
||||
else { split = 1; }
|
||||
|
||||
printf("set split %d\n", 1);
|
||||
frame[4] = 0xfb;
|
||||
frame[5] = 0xfd;
|
||||
write(fd, frame, 6);
|
||||
break;
|
||||
|
||||
#if 0
|
||||
|
||||
case 0x12: // we're simulating the 3-byte version -- not the 2-byte
|
||||
if (frame[5] != 0xfd)
|
||||
{
|
||||
printf("Set ant %d\n", -1);
|
||||
ant_curr = frame[5];
|
||||
ant_option = frame[6];
|
||||
dump_hex(frame, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Get ant\n");
|
||||
}
|
||||
|
||||
frame[5] = ant_curr;
|
||||
frame[6] = ant_option;
|
||||
frame[7] = 0xfd;
|
||||
printf("n=write 8 bytes\n");
|
||||
dump_hex(frame, 8);
|
||||
write(fd, frame, 8);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case 0x14:
|
||||
switch (frame[5])
|
||||
{
|
||||
static int power_level = 0;
|
||||
static int level = 0;
|
||||
|
||||
case 0x01:
|
||||
level = 255;
|
||||
printf("Using AF level %d\n", level);
|
||||
to_bcd(&frame[6], (long long) level, 2);
|
||||
frame[8] = 0xfd;
|
||||
write(fd, frame, 9);
|
||||
break;
|
||||
|
||||
case 0x0a:
|
||||
printf("Using power level %d\n", power_level);
|
||||
power_level += 10;
|
||||
|
||||
if (power_level > 250) { power_level = 0; }
|
||||
|
||||
to_bcd(&frame[6], (long long)power_level, 2);
|
||||
frame[8] = 0xfd;
|
||||
write(fd, frame, 9);
|
||||
break;
|
||||
|
||||
case 0x0c:
|
||||
dumphex(frame, 10);
|
||||
printf("subcmd=0x0c #1\n");
|
||||
|
||||
if (frame[6] != 0xfd) // then we have data
|
||||
{
|
||||
printf("subcmd=0x0c #1\n");
|
||||
keyspd = from_bcd(&frame[6], 2);
|
||||
frame[6] = 0xfb;
|
||||
write(fd, frame, 7);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("subcmd=0x0c #1\n");
|
||||
to_bcd(&frame[6], keyspd, 2);
|
||||
frame[8] = 0xfd;
|
||||
write(fd, frame, 9);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case 0x15:
|
||||
switch (frame[5])
|
||||
{
|
||||
static int meter_level = 0;
|
||||
|
||||
case 0x11:
|
||||
printf("Using meter level %d\n", meter_level);
|
||||
meter_level += 10;
|
||||
|
||||
if (meter_level > 250) { meter_level = 0; }
|
||||
|
||||
to_bcd(&frame[6], (long long)meter_level, 2);
|
||||
frame[8] = 0xfd;
|
||||
write(fd, frame, 9);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
#if 0
|
||||
|
||||
case 0x18: // miscellaneous things
|
||||
frame[5] = 1;
|
||||
frame[6] = 0xfd;
|
||||
write(fd, frame, 7);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case 0x19:
|
||||
frame[6] = 0x61;
|
||||
frame[7] = 0x00;
|
||||
frame[8] = 0xfd;
|
||||
write(fd, frame, 9);
|
||||
break;
|
||||
|
||||
case 0x1a: // miscellaneous things
|
||||
switch (frame[5])
|
||||
{
|
||||
case 0x03: // width
|
||||
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { frame[6] = widthA; }
|
||||
else { frame[6] = widthB; }
|
||||
|
||||
frame[7] = 0xfd;
|
||||
write(fd, frame, 8);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x1c:
|
||||
switch (frame[5])
|
||||
{
|
||||
case 0:
|
||||
if (frame[6] == 0xfd)
|
||||
{
|
||||
frame[6] = ptt;
|
||||
frame[7] = 0xfd;
|
||||
write(fd, frame, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptt = frame[6];
|
||||
frame[7] = 0xfb;
|
||||
frame[8] = 0xfd;
|
||||
write(fd, frame, 9);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
#ifdef X25
|
||||
|
||||
case 0x25:
|
||||
if (frame[6] == 0xfd)
|
||||
{
|
||||
if (frame[5] == 0x00)
|
||||
{
|
||||
to_bcd(&frame[6], (long long)freqA, (civ_731_mode ? 4 : 5) * 2);
|
||||
printf("get_freqA=%.0f\n", freqA);
|
||||
}
|
||||
else
|
||||
{
|
||||
to_bcd(&frame[6], (long long)freqB, (civ_731_mode ? 4 : 5) * 2);
|
||||
printf("get_freqB=%.0f\n", freqB);
|
||||
}
|
||||
|
||||
frame[11] = 0xfd;
|
||||
write(fd, frame, 12);
|
||||
}
|
||||
else
|
||||
{
|
||||
freq = from_bcd(&frame[6], (civ_731_mode ? 4 : 5) * 2);
|
||||
printf("set_freq to %.0f\n", freq);
|
||||
|
||||
if (frame[5] == 0x00) { freqA = freq; }
|
||||
else { freqB = freq; }
|
||||
|
||||
frame[4] = 0xfb;
|
||||
frame[5] = 0xfd;
|
||||
write(fd, frame, 6);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x26:
|
||||
for (int i = 0; i < 6; ++i) { printf("%02x:", frame[i]); }
|
||||
|
||||
if (frame[6] == 0xfd) // then a query
|
||||
{
|
||||
for (int i = 0; i < 6; ++i) { printf("%02x:", frame[i]); }
|
||||
|
||||
frame[6] = frame[5] == 0 ? modeA : modeB;
|
||||
frame[7] = frame[5] == 0 ? datamodeA : datamodeB;
|
||||
frame[8] = 0xfb;
|
||||
frame[9] = 0xfd;
|
||||
write(fd, frame, 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < 12; ++i) { printf("%02x:", frame[i]); }
|
||||
|
||||
if (frame[5] == 0)
|
||||
{
|
||||
modeA = frame[6];
|
||||
datamodeA = frame[7];
|
||||
}
|
||||
else
|
||||
{
|
||||
modeB = frame[6];
|
||||
datamodeB = frame[7];
|
||||
}
|
||||
|
||||
frame[4] = 0xfb;
|
||||
frame[5] = 0xfd;
|
||||
write(fd, frame, 6);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
break;
|
||||
#else
|
||||
|
||||
case 0x25:
|
||||
frame[4] = 0xfa;
|
||||
frame[5] = 0xfd;
|
||||
break;
|
||||
|
||||
case 0x26:
|
||||
frame[4] = 0xfa;
|
||||
frame[5] = 0xfd;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default: printf("cmd 0x%02x unknown\n", frame[4]);
|
||||
}
|
||||
|
||||
// don't care about the rig type yet
|
||||
|
||||
}
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
int openPort(char *comport) // doesn't matter for using pts devices
|
||||
{
|
||||
int fd;
|
||||
fd = open(comport, O_RDWR);
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
perror(comport);
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
#else
|
||||
int openPort(char *comport) // doesn't matter for using pts devices
|
||||
{
|
||||
int fd = posix_openpt(O_RDWR);
|
||||
char *name = ptsname(fd);
|
||||
|
||||
if (name == NULL)
|
||||
{
|
||||
perror("pstname");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("name=%s\n", name);
|
||||
|
||||
if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1)
|
||||
{
|
||||
perror("posix_openpt");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
#endif
|
||||
|
||||
void rigStatus()
|
||||
{
|
||||
char vfoa = current_vfo == RIG_VFO_A ? '*' : ' ';
|
||||
char vfob = current_vfo == RIG_VFO_B ? '*' : ' ';
|
||||
printf("%cVFOA: mode=%d datamode=%d width=%ld freq=%.0f\n", vfoa, modeA,
|
||||
datamodeA,
|
||||
widthA,
|
||||
freqA);
|
||||
printf("%cVFOB: mode=%d datamode=%d width=%ld freq=%.0f\n", vfob, modeB,
|
||||
datamodeB,
|
||||
widthB,
|
||||
freqB);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
unsigned char buf[256];
|
||||
int fd = openPort(argv[1]);
|
||||
|
||||
printf("%s: %s\n", argv[0], rig_version());
|
||||
#ifdef X25
|
||||
printf("x25/x26 command recognized\n");
|
||||
#else
|
||||
printf("x25/x26 command rejected\n");
|
||||
#endif
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
printf("Missing comport argument\n");
|
||||
printf("%s [comport]\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
while (1)
|
||||
{
|
||||
int len = frameGet(fd, buf);
|
||||
|
||||
if (len <= 0)
|
||||
{
|
||||
close(fd);
|
||||
fd = openPort(argv[1]);
|
||||
}
|
||||
|
||||
frameParse(fd, buf, len);
|
||||
rigStatus();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
23
src/misc.c
23
src/misc.c
|
@ -498,7 +498,7 @@ static const struct
|
|||
{ RIG_MODE_IQ, "IQ"},
|
||||
{ RIG_MODE_ISBUSB, "ISBUSB"},
|
||||
{ RIG_MODE_ISBLSB, "ISBLSB"},
|
||||
{ RIG_MODE_NONE, "None" }, // so we can reutnr None when NONE is requested
|
||||
{ RIG_MODE_NONE, "None" }, // so we can return None when NONE is requested
|
||||
{ -1, "" }, // need to end list
|
||||
};
|
||||
|
||||
|
@ -3049,7 +3049,6 @@ int rig_get_band_rig(RIG *rig, freq_t freq, const char *band)
|
|||
// Returns RIG_OK if 2038 time routines pass tests
|
||||
int rig_test_2038(RIG *rig)
|
||||
{
|
||||
time_t x;
|
||||
|
||||
#if defined(_TIME_BITS)
|
||||
#if defined(__GLIBC_MINOR__)
|
||||
|
@ -3071,7 +3070,7 @@ int rig_test_2038(RIG *rig)
|
|||
|
||||
int failed = 0;
|
||||
#if defined(__MSVCRT_VERSION__)
|
||||
x = (__time64_t)((1UL << 31) - 1);
|
||||
__time64_t x = (__time64_t)0xffffffff;
|
||||
char s[64];
|
||||
_ctime64_s(s, sizeof(s), &x);
|
||||
|
||||
|
@ -3089,7 +3088,7 @@ int rig_test_2038(RIG *rig)
|
|||
return 1;
|
||||
}
|
||||
|
||||
x = (time_t)((1U << 63) - 1);
|
||||
time_t x = (time_t)0xF0000000;
|
||||
char *s = ctime(&x);
|
||||
|
||||
if (s == NULL) { failed = 1; }
|
||||
|
@ -3105,27 +3104,17 @@ int rig_test_2038(RIG *rig)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (!strstr(s, "2038")) { return 1; }
|
||||
if (strstr(s, "2097")) { return RIG_OK; }
|
||||
|
||||
x += 1;
|
||||
#if defined(__MSVCRT_VERSION__)
|
||||
_ctime64_s(s, sizeof(s), &x);
|
||||
#else
|
||||
s = ctime(&x);
|
||||
#endif
|
||||
|
||||
if (!strstr(s, "2038")) { return 1; }
|
||||
if (strstr(s, "2097")) { return RIG_OK; }
|
||||
|
||||
x += 1;
|
||||
#if defined(__MSVCRT_VERSION__)
|
||||
_ctime64_s(s, sizeof(s), &x);
|
||||
#else
|
||||
s = ctime(&x);
|
||||
#endif
|
||||
|
||||
if (!strstr(s, "2038")) { return 1; }
|
||||
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -493,14 +493,16 @@ int main(int argc, char *argv[])
|
|||
exit(2);
|
||||
}
|
||||
|
||||
#if 0
|
||||
retcode = -RIG_ENIMPL;
|
||||
// retcode = set_conf(my_rig, conf_parms);
|
||||
retcode = set_conf(my_rig, conf_parms);
|
||||
|
||||
if (retcode != RIG_OK)
|
||||
{
|
||||
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
||||
exit(2);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (my_model > 5 && !rig_file)
|
||||
{
|
||||
|
@ -665,7 +667,8 @@ static rmode_t ts2000_get_mode()
|
|||
pbwidth_t width;
|
||||
rig_get_mode(my_rig, vfo_fixup(my_rig, RIG_VFO_A, my_rig->state.cache.split),
|
||||
&mode, &width);
|
||||
|
||||
kwidth = width;
|
||||
#if 0
|
||||
// Perhaps we should emulate a rig that has PKT modes instead??
|
||||
int kwidth_ssb[] = { 10, 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
|
||||
int kwidth_am[] = { 10, 100, 200, 500 };
|
||||
|
@ -702,6 +705,45 @@ static rmode_t ts2000_get_mode()
|
|||
|
||||
default: mode = 0; break;
|
||||
}
|
||||
#else
|
||||
// Perhaps we should emulate a rig that has PKT modes instead??
|
||||
//int kwidth_ssb[] = { 10, 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
|
||||
//int kwidth_am[] = { 10, 100, 200, 500 };
|
||||
|
||||
// still need to cover packet filter 00=wide, 01=nar
|
||||
switch (mode)
|
||||
{
|
||||
case RIG_MODE_LSB: mode = 1; break;
|
||||
|
||||
case RIG_MODE_USB: mode = 2; break;
|
||||
|
||||
case RIG_MODE_CW: mode = 3;
|
||||
break; // is this correct?
|
||||
|
||||
case RIG_MODE_FM: mode = 4; break;
|
||||
|
||||
case RIG_MODE_AM: mode = 5; break;
|
||||
|
||||
case RIG_MODE_RTTY: mode = 6; break;
|
||||
|
||||
case RIG_MODE_CWR: mode = 7;
|
||||
break; // is this correct?
|
||||
|
||||
case RIG_MODE_NONE: mode = 8;
|
||||
break; // is this correct?
|
||||
|
||||
case RIG_MODE_RTTYR: mode = 9; break;
|
||||
|
||||
case RIG_MODE_PKTUSB: mode = 2;
|
||||
break; // need to change to a TS_2000 mode
|
||||
|
||||
case RIG_MODE_PKTLSB: mode = 1;;
|
||||
break; // need to change to a TS_2000 mode
|
||||
|
||||
default: mode = 0; break;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
return mode;
|
||||
}
|
||||
|
@ -745,27 +787,27 @@ static int handle_ts2000(void *arg)
|
|||
}
|
||||
else if (strcmp(arg, "IF;") == 0)
|
||||
{
|
||||
freq_t freq; // P1
|
||||
int freq_step = 10; // P2 just use default value for now
|
||||
int rit_xit_freq = 0; // P3 dummy value for now
|
||||
int rit = 0; // P4 dummy value for now
|
||||
int xit = 0; // P5 dummy value for now
|
||||
int bank1 = 0; // P6 dummy value for now
|
||||
int bank2 = 0; // P7 dummy value for now
|
||||
ptt_t ptt; // P8
|
||||
rmode_t mode; // P9
|
||||
vfo_t vfo; // P10
|
||||
int scan = 0; // P11 dummy value for now
|
||||
split_t split = 0; // P1 2
|
||||
int p13 = 0; // P13 Tone dummy value for now
|
||||
int p14 = 0; // P14 Tone Freq dummy value for now
|
||||
int p15 = 0; // P15 Shift status dummy value for now
|
||||
freq_t freq; // P1(11)
|
||||
int freq_step = 10; // P2(4) just use default value for now
|
||||
//int rit_xit_freq = 0; // P3(6) dummy value for now
|
||||
int rit = 0; // P4(1) dummy value for now
|
||||
int xit = 0; // P5(1) dummy value for now
|
||||
int bank1 = 0; // P6(1) dummy value for now
|
||||
int bank2 = 0; // P7(2) dummy value for now
|
||||
ptt_t ptt; // P8(1)
|
||||
rmode_t mode; // P9(1)
|
||||
vfo_t vfo; // P10(1)
|
||||
int scan = 0; // P11(1) dummy value for now
|
||||
split_t split = 0; // P12(1)
|
||||
int p13 = 0; // P13(1) Tone dummy value for now
|
||||
int p14 = 0; // P14(2) Tone Freq dummy value for now
|
||||
int p15 = 0; // P15(1) Shift status dummy value for now
|
||||
int retval = rig_get_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_A,
|
||||
my_rig->state.cache.split), &freq);
|
||||
char response[64];
|
||||
char *fmt =
|
||||
// cppcheck-suppress *
|
||||
"IF%011"PRIll"%04d+%05d%1d%1d%1d%02d%1d%1"PRIll"%1d%1d%1d%1d%02d%1d;";
|
||||
"IF%011"PRIll" %1d%1d%1d%02d%1d%1"PRIll"%1d%1d%1d%1d%02d%1d;";
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -793,7 +835,10 @@ static int handle_ts2000(void *arg)
|
|||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
vfo = RIG_VFO_A;
|
||||
#if 0 // so we work with rigs (like Icom) that have no get_vfo
|
||||
return retval;
|
||||
#endif
|
||||
}
|
||||
|
||||
switch (vfo)
|
||||
|
@ -821,7 +866,6 @@ static int handle_ts2000(void *arg)
|
|||
fmt,
|
||||
(uint64_t)freq,
|
||||
freq_step,
|
||||
rit_xit_freq,
|
||||
rit, xit,
|
||||
bank1,
|
||||
bank2,
|
||||
|
@ -960,9 +1004,12 @@ static int handle_ts2000(void *arg)
|
|||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
vfo = RIG_VFO_A;
|
||||
#if 0 // so we work with rigs (like Icom) that have no get_vfo
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: get vfo failed: %s\n", __func__,
|
||||
rigerror(retval));
|
||||
return retval;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue