Convert first part of rotators/

pull/1513/head
George Baltz N3GB 2024-02-16 05:23:20 -05:00
rodzic 878117ab1f
commit f247ee2088
14 zmienionych plików z 73 dodań i 94 usunięć

Wyświetl plik

@ -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;

Wyświetl plik

@ -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;

Wyświetl plik

@ -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;
}

Wyświetl plik

@ -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)

Wyświetl plik

@ -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;
}

Wyświetl plik

@ -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);

Wyświetl plik

@ -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

Wyświetl plik

@ -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));
}

Wyświetl plik

@ -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;
}

Wyświetl plik

@ -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;
}

Wyświetl plik

@ -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)
{

Wyświetl plik

@ -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)

Wyświetl plik

@ -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;
}

Wyświetl plik

@ -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;