Finish rotators/

pull/1513/head
George Baltz N3GB 2024-02-18 05:47:04 -05:00
rodzic f247ee2088
commit 8ff07c47f9
11 zmienionych plików z 81 dodań i 114 usunięć

Wyświetl plik

@ -19,12 +19,11 @@ static pthread_t apex_read_thread;
static int apex_get_string(ROT *rot, char *s, int maxlen) static int apex_get_string(ROT *rot, char *s, int maxlen)
{ {
int retval = 0; int retval = 0;
struct rot_state *rs = &rot->state;
char buf[64]; char buf[64];
memset(s, 0, maxlen); memset(s, 0, maxlen);
retval = read_string(&rs->rotport, (unsigned char *)buf, retval = read_string(ROTPORT(rot), (unsigned char *)buf,
sizeof(buf), sizeof(buf),
"\n", strlen("\n"), sizeof(buf), 1); "\n", strlen("\n"), sizeof(buf), 1);
strncpy(s, buf, 64); strncpy(s, buf, 64);
@ -98,13 +97,13 @@ int apex_open(ROT *rot)
{ {
int retval; int retval;
char *cmdstr = "[GETVER]\r"; // does this work on all Apex controllers? 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__); 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 apex_azimuth = -1; // we check to see if we've seen azimuth at least one time
rig_flush(&rs->rotport); rig_flush(rotp);
retval = write_block(&rs->rotport, (unsigned char *) cmdstr, strlen(cmdstr)); retval = write_block(rotp, (unsigned char *) cmdstr, strlen(cmdstr));
if (retval != RIG_OK) if (retval != RIG_OK)
{ {

Wyświetl plik

@ -25,7 +25,7 @@ int apex_shared_loop_set_position(ROT *rot, float az, float dummy)
{ {
char cmdstr[16]; char cmdstr[16];
int retval; int retval;
struct rot_state *rs = &rot->state; hamlib_port_t *rotp = ROTPORT(rot);
int remainder = lround(az + 22.5) % 45; int remainder = lround(az + 22.5) % 45;
int apex_az = lround(az + 22.5) - remainder; 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; return -RIG_EINTERNAL;
} }
rig_flush(&rs->rotport); rig_flush(rotp);
apex_azimuth = -1; 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) if (retval != RIG_OK)
{ {

Wyświetl plik

@ -71,14 +71,15 @@ static int flir_request(ROT *rot, char *request, char *response,
int resp_size) int resp_size)
{ {
int return_value = -RIG_EINVAL; int return_value = -RIG_EINVAL;
hamlib_port_t *rotp = ROTPORT(rot);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rig_flush(&rot->state.rotport); rig_flush(rotp);
if (request) if (request)
{ {
return_value = write_block(&rot->state.rotport, (unsigned char *)request, return_value = write_block(rotp, (unsigned char *)request,
strlen(request)); strlen(request));
if (return_value != RIG_OK) if (return_value != RIG_OK)
@ -94,10 +95,10 @@ static int flir_request(ROT *rot, char *request, char *response,
int retry_read = 0; int retry_read = 0;
int read_char; int read_char;
while (retry_read < rot->state.rotport.retry) while (retry_read < rotp->retry)
{ {
memset(response, 0, (size_t)resp_size); 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, resp_size,
"\r\n", sizeof("\r\n"), 0, 1); "\r\n", sizeof("\r\n"), 0, 1);

Wyświetl plik

@ -62,20 +62,18 @@ struct prosistel_rot_priv_caps
static int prosistel_transaction(ROT *rot, const char *cmdstr, static int prosistel_transaction(ROT *rot, const char *cmdstr,
char *data, size_t data_len) char *data, size_t data_len)
{ {
struct rot_state *rs; hamlib_port_t *rotp = ROTPORT(rot);
int retval; int retval;
int retry_read = 0; int retry_read = 0;
char replybuf[BUFSZ]; char replybuf[BUFSZ];
rs = &rot->state;
transaction_write: transaction_write:
rig_flush(&rs->rotport); rig_flush(rotp);
if (cmdstr) 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) if (retval != RIG_OK)
{ {
@ -95,12 +93,12 @@ transaction_write:
} }
// Remember to check for STXA,G,R or STXA,?,XXX,R 10 bytes // 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); 0, 1);
if (retval < 0) if (retval < 0)
{ {
if (retry_read++ < rot->state.rotport.retry) if (retry_read++ < rotp->retry)
{ {
goto transaction_write; goto transaction_write;
} }

Wyświetl plik

@ -49,7 +49,7 @@
static int static int
radant_transaction(ROT *rot, const char *cmdstr, char *data, size_t data_len) 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; int retval;
rig_debug(RIG_DEBUG_TRACE, "%s called: %s\n", __func__, cmdstr); 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; return -RIG_EINVAL;
} }
rs = &rot->state; rig_flush(rotp);
rig_flush(&rs->rotport); retval = write_block(rotp, (unsigned char *) cmdstr, strlen(cmdstr));
retval = write_block(&rs->rotport, (unsigned char *) cmdstr, strlen(cmdstr));
if (retval != RIG_OK) 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 */ return RIG_OK; /* don't want a reply */
} }
retval = read_string(&rs->rotport, (unsigned char *) data, data_len, "\n", 1, 0, retval = read_string(rotp, (unsigned char *) data, data_len, "\n", 1, 0, 1);
1);
if (retval < 0) if (retval < 0)
{ {

Wyświetl plik

@ -421,7 +421,7 @@ static int rotorez_rot_init(ROT *rot)
return -RIG_ENOMEM; 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; ((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; return err;
} }
if (rot->state.rotport2.pathname[0] != 0) if (ROTPORT2(rot)->pathname[0] != 0)
{ {
SNPRINTF(cmdstr, sizeof(cmdstr), "AP1%05.1f\r;", SNPRINTF(cmdstr, sizeof(cmdstr), "AP1%05.1f\r;",
elevation); /* Total field width of 5 chars */ 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, static int rotorez_rot_get_position(ROT *rot, azimuth_t *azimuth,
elevation_t *elevation) elevation_t *elevation)
{ {
struct rot_state *rs; hamlib_port_t *rotp;
hamlib_port_t *rotp2;
const char cmdstr[5] = "AI1;"; const char cmdstr[5] = "AI1;";
char az[5]; /* read azimuth string */ char az[5]; /* read azimuth string */
char *p; char *p;
@ -578,6 +579,8 @@ static int rotorez_rot_get_position(ROT *rot, azimuth_t *azimuth,
{ {
return -RIG_EINVAL; return -RIG_EINVAL;
} }
rotp = ROTPORT(rot);
rotp2 = ROTPORT2(rot);
do do
{ {
@ -588,9 +591,7 @@ static int rotorez_rot_get_position(ROT *rot, azimuth_t *azimuth,
return err; return err;
} }
rs = &rot->state; err = read_block(rotp, (unsigned char *) az, AZ_READ_LEN);
err = read_block(&rs->rotport, (unsigned char *) az, AZ_READ_LEN);
if (err != 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; *azimuth = tmp;
if (strlen(rot->state.rotport2.pathname) > 0) if (strlen(rotp2->pathname) > 0)
{ {
do do
{ {
@ -664,9 +665,9 @@ static int rotorez_rot_get_position(ROT *rot, azimuth_t *azimuth,
return err; return err;
} }
rs = &rot->state; //TODO: Should this be rotp or rotp2????
//err = read_block(&rs->rotport, (unsigned char *) az, AZ_READ_LEN);
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) 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, static int erc_rot_get_position(ROT *rot, azimuth_t *azimuth,
elevation_t *elevation) elevation_t *elevation)
{ {
struct rot_state *rs;
const char cmdstr[5] = "AI1;"; const char cmdstr[5] = "AI1;";
char az[5]; /* read azimuth string */ char az[5]; /* read azimuth string */
char *p; char *p;
@ -755,9 +755,7 @@ static int erc_rot_get_position(ROT *rot, azimuth_t *azimuth,
return err; return err;
} }
rs = &rot->state; err = read_block(ROTPORT(rot), (unsigned char *) az, AZ_READ_LEN);
err = read_block(&rs->rotport, (unsigned char *) az, AZ_READ_LEN);
if (err != 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, static int rt21_rot_get_position(ROT *rot, azimuth_t *azimuth,
elevation_t *elevation) elevation_t *elevation)
{ {
struct rot_state *rs; hamlib_port_t *rotp;
hamlib_port_t *rotp2;
char az[8]; /* read azimuth string */ char az[8]; /* read azimuth string */
int err; int err;
@ -860,6 +859,8 @@ static int rt21_rot_get_position(ROT *rot, azimuth_t *azimuth,
{ {
return -RIG_EINVAL; return -RIG_EINVAL;
} }
rotp = ROTPORT(rot);
rotp2 = ROTPORT2(rot);
/* 'BI1' is an RT-21 specific command that queries for a floating /* 'BI1' is an RT-21 specific command that queries for a floating
* point position (to the tenth of a degree). * 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; return err;
} }
rs = &rot->state; err = read_string(rotp, (unsigned char *) az, RT21_AZ_LEN + 1, ";",
err = read_string(&rs->rotport, (unsigned char *) az, RT21_AZ_LEN + 1, ";",
strlen(";"), 0, 1); strlen(";"), 0, 1);
if (err < 0) /* read_string returns negative on error. */ 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; *azimuth = tmp;
if (strlen(rot->state.rotport2.pathname) > 0) if (rotp2 && strlen(rotp2->pathname) > 0)
{ {
err = rotorez_send_priv_cmd2(rot, "BI1;"); err = rotorez_send_priv_cmd2(rot, "BI1;");
@ -915,9 +914,7 @@ static int rt21_rot_get_position(ROT *rot, azimuth_t *azimuth,
return err; return err;
} }
rs = &rot->state; err = read_string(rotp2, (unsigned char *) az, RT21_AZ_LEN + 1, ";",
err = read_string(&rs->rotport2, (unsigned char *) az, RT21_AZ_LEN + 1, ";",
strlen(";"), 0, 1); strlen(";"), 0, 1);
if (err < 0) /* read_string returns negative on error. */ 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) static int rotorez_send_priv_cmd(ROT *rot, const char *cmdstr)
{ {
struct rot_state *rs;
int err; int err;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); 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; return -RIG_EINVAL;
} }
rs = &rot->state; err = write_block(ROTPORT(rot), (unsigned char *) cmdstr, strlen(cmdstr));
err = write_block(&rs->rotport, (unsigned char *) cmdstr, strlen(cmdstr));
if (err != RIG_OK) 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 // send command to 2nd rotator port
static int rotorez_send_priv_cmd2(ROT *rot, const char *cmdstr) static int rotorez_send_priv_cmd2(ROT *rot, const char *cmdstr)
{ {
struct rot_state *rs;
int err; int err;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); 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; return -RIG_EINVAL;
} }
rs = &rot->state; err = write_block(ROTPORT2(rot), (unsigned char *) cmdstr, strlen(cmdstr));
err = write_block(&rs->rotport2, (unsigned char *) cmdstr, strlen(cmdstr));
if (err != RIG_OK) 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) static int rotorez_flush_buffer(ROT *rot)
{ {
struct rot_state *rs;
char garbage[32]; /* read buffer */ char garbage[32]; /* read buffer */
int err = 0; int err = 0;
size_t MAX = 31; size_t MAX = 31;
@ -1205,11 +1197,9 @@ static int rotorez_flush_buffer(ROT *rot)
return -RIG_EINVAL; return -RIG_EINVAL;
} }
rs = &rot->state;
do 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! */ /* Oops! An IO error was encountered. Bail out! */
if (err == -RIG_EIO) if (err == -RIG_EIO)

Wyświetl plik

@ -49,7 +49,7 @@ static int
saebrtrack_transaction(ROT *rot, const char *cmdstr, char *data, saebrtrack_transaction(ROT *rot, const char *cmdstr, char *data,
size_t data_len) size_t data_len)
{ {
struct rot_state *rs; hamlib_port_t *rotp = ROTPORT(rot);
int retval; int retval;
rig_debug(RIG_DEBUG_TRACE, "%s called: %s\n", __func__, cmdstr); 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; return -RIG_EINVAL;
} }
rs = &rot->state; rig_flush(rotp);
rig_flush(&rs->rotport); retval = write_block(rotp, (unsigned char *) cmdstr, strlen(cmdstr));
retval = write_block(&rs->rotport, (unsigned char *) cmdstr, strlen(cmdstr));
if (retval != RIG_OK) 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 */ 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); "\n", 1, 0, 1);
if (retval < 0) if (retval < 0)

Wyświetl plik

@ -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)); 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)); strlen(cmdstr));
if (err != RIG_OK) if (err != RIG_OK)
@ -147,7 +147,7 @@ static int sartek_rot_stop(ROT *rot)
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__); 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) if (err != RIG_OK)
{ {

Wyświetl plik

@ -109,17 +109,13 @@ struct satel_stat
static int satel_cmd(ROT *rot, char *cmd, int cmdlen, char *res, int reslen) static int satel_cmd(ROT *rot, char *cmd, int cmdlen, char *res, int reslen)
{ {
int ret; int ret;
struct rot_state *rs; hamlib_port_t *rotp = ROTPORT(rot);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rig_flush(rotp);
rs = &rot->state; ret = write_block(rotp, (unsigned char *) cmd, cmdlen);
rig_flush(&rs->rotport);
ret = write_block(&rs->rotport, (unsigned char *) cmd, cmdlen);
if (ret != RIG_OK) 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) 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) if (ret < 0)
{ {
@ -146,16 +142,10 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
char resbuf[BUF_SIZE]; char resbuf[BUF_SIZE];
char *p; char *p;
int ret; int ret;
struct rot_state *rs; hamlib_port_t *rotp = ROTPORT(rot);
rs = &rot->state;
// read motion state // read motion state
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, ret = read_string(rotp, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
1);
if (ret < 0) 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; stat->motion_enabled = strcmp(resbuf, "Motion ENABLED") == 0 ? true : false;
// XXX skip mode // XXX skip mode
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, ret = read_string(rotp, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
1);
if (ret < 0) if (ret < 0)
{ {
@ -174,8 +163,7 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
} }
// XXX skip time // XXX skip time
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, ret = read_string(rotp, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
1);
if (ret < 0) if (ret < 0)
{ {
@ -183,8 +171,7 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
} }
// read azimuth line // read azimuth line
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, ret = read_string(rotp, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
1);
if (ret < 0) if (ret < 0)
{ {
@ -196,8 +183,7 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
stat->az = (int)strtof(p, NULL); stat->az = (int)strtof(p, NULL);
// read elevation line // read elevation line
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, ret = read_string(rotp, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
1);
if (ret < 0) if (ret < 0)
{ {
@ -209,8 +195,7 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
stat->el = (int)strtof(p, NULL); stat->el = (int)strtof(p, NULL);
// skip blank line // skip blank line
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, ret = read_string(rotp, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
1);
if (ret < 0) if (ret < 0)
{ {
@ -218,15 +203,13 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
} }
// XXX skip stored position count // XXX skip stored position count
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, ret = read_string(rotp, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
1);
if (ret < 0) if (ret < 0)
{ {
return ret; return ret;
} }
return RIG_OK; return RIG_OK;
} }

Wyświetl plik

@ -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, static int spid_rot1prog_rot_set_position(ROT *rot, azimuth_t az,
elevation_t el) elevation_t el)
{ {
struct rot_state *rs = &rot->state;
int retval; int retval;
char cmdstr[13]; char cmdstr[13];
unsigned int u_az; 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[11] = 0x2F; /* K */
cmdstr[12] = 0x20; /* END */ 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) if (retval != RIG_OK)
{ {
@ -343,6 +342,7 @@ static int spid_rot2prog_rot_set_position(ROT *rot, azimuth_t az,
elevation_t el) elevation_t el)
{ {
struct rot_state *rs = &rot->state; struct rot_state *rs = &rot->state;
hamlib_port_t *rotp = ROTPORT(rot);
const struct spid_rot2prog_priv_data *priv = (struct spid_rot2prog_priv_data *) const struct spid_rot2prog_priv_data *priv = (struct spid_rot2prog_priv_data *)
rs->priv; rs->priv;
int retval; int retval;
@ -356,7 +356,7 @@ static int spid_rot2prog_rot_set_position(ROT *rot, azimuth_t az,
{ {
do 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); (unsigned char *) "\x57\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1F\x20", 13);
if (retval != RIG_OK) if (retval != RIG_OK)
@ -365,9 +365,9 @@ static int spid_rot2prog_rot_set_position(ROT *rot, azimuth_t az,
} }
memset(cmdstr, 0, 12); 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) if (retval < 0)
{ {
@ -397,7 +397,7 @@ static int spid_rot2prog_rot_set_position(ROT *rot, azimuth_t az,
cmdstr[11] = 0x2F; /* K */ cmdstr[11] = 0x2F; /* K */
cmdstr[12] = 0x20; /* END */ 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) if (retval != RIG_OK)
{ {
@ -412,9 +412,9 @@ static int spid_rot2prog_rot_set_position(ROT *rot, azimuth_t az,
do 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; 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) 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 retval;
int retry_read = 0; int retry_read = 0;
char posbuf[12]; char posbuf[12];
@ -431,7 +431,7 @@ static int spid_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
do 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); (unsigned char *) "\x57\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1F\x20", 13);
if (retval != RIG_OK) 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) 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 || else if (rot->caps->rot_model == ROT_MODEL_SPID_ROT2PROG ||
rot->caps->rot_model == ROT_MODEL_SPID_MD01_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 else
{ {
retval = -RIG_EINVAL; retval = -RIG_EINVAL;
} }
} }
while (retval < 0 && retry_read++ < rot->state.rotport.retry); while (retval < 0 && retry_read++ < rotp->retry);
if (retval < 0) 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) static int spid_rot_stop(ROT *rot)
{ {
struct rot_state *rs = &rot->state; hamlib_port_t *rotp = ROTPORT(rot);
int retval; int retval;
int retry_read = 0; int retry_read = 0;
char posbuf[12]; char posbuf[12];
@ -503,7 +503,7 @@ static int spid_rot_stop(ROT *rot)
do 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); (unsigned char *) "\x57\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0F\x20", 13);
if (retval != RIG_OK) if (retval != RIG_OK)
@ -515,15 +515,15 @@ static int spid_rot_stop(ROT *rot)
if (rot->caps->rot_model == ROT_MODEL_SPID_ROT1PROG) 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 || else if (rot->caps->rot_model == ROT_MODEL_SPID_ROT2PROG ||
rot->caps->rot_model == ROT_MODEL_SPID_MD01_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) 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) static int spid_md01_rot2prog_rot_move(ROT *rot, int direction, int speed)
{ {
struct rot_state *rs = &rot->state;
char dir = 0x00; char dir = 0x00;
int retval; int retval;
char cmdstr[13]; 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. */ moving at all), always send the stop command first. */
spid_rot_stop(rot); spid_rot_stop(rot);
retval = spid_write(&rs->rotport, (unsigned char *) cmdstr, 13); retval = spid_write(ROTPORT(rot), (unsigned char *) cmdstr, 13);
return retval; return retval;
} }

Wyświetl plik

@ -59,7 +59,7 @@ static int ts7400_rot_init(ROT *rot)
priv = rot->state.priv; priv = rot->state.priv;
rot->state.rotport.type.rig = RIG_PORT_NONE; ROTPORT(rot)->type.rig = RIG_PORT_NONE;
priv->az = priv->el = 0; priv->az = priv->el = 0;