diff --git a/rotators/apex/apex.c b/rotators/apex/apex.c index 37b2bec23..04f803f05 100644 --- a/rotators/apex/apex.c +++ b/rotators/apex/apex.c @@ -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) { diff --git a/rotators/apex/sharedloop.c b/rotators/apex/sharedloop.c index d8b9d3bad..5fa8eb865 100644 --- a/rotators/apex/sharedloop.c +++ b/rotators/apex/sharedloop.c @@ -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) { diff --git a/rotators/flir/flir.c b/rotators/flir/flir.c index c2de2baae..9d3c3a2da 100644 --- a/rotators/flir/flir.c +++ b/rotators/flir/flir.c @@ -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); diff --git a/rotators/prosistel/prosistel.c b/rotators/prosistel/prosistel.c index de0c85077..7bf7871a2 100644 --- a/rotators/prosistel/prosistel.c +++ b/rotators/prosistel/prosistel.c @@ -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; } diff --git a/rotators/radant/radant.c b/rotators/radant/radant.c index 52985ab21..b8203ef1f 100644 --- a/rotators/radant/radant.c +++ b/rotators/radant/radant.c @@ -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) { diff --git a/rotators/rotorez/rotorez.c b/rotators/rotorez/rotorez.c index 371e10f45..ec4e559ca 100644 --- a/rotators/rotorez/rotorez.c +++ b/rotators/rotorez/rotorez.c @@ -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) diff --git a/rotators/saebrtrack/saebrtrack.c b/rotators/saebrtrack/saebrtrack.c index 5ecdb35cc..4baa4a8f9 100644 --- a/rotators/saebrtrack/saebrtrack.c +++ b/rotators/saebrtrack/saebrtrack.c @@ -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) diff --git a/rotators/sartek/sartek.c b/rotators/sartek/sartek.c index 363064260..baeb5716c 100644 --- a/rotators/sartek/sartek.c +++ b/rotators/sartek/sartek.c @@ -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) { diff --git a/rotators/satel/satel.c b/rotators/satel/satel.c index 7d13c2b82..aa90d8db7 100644 --- a/rotators/satel/satel.c +++ b/rotators/satel/satel.c @@ -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; } diff --git a/rotators/spid/spid.c b/rotators/spid/spid.c index a8689bbc4..e0dd0d712 100644 --- a/rotators/spid/spid.c +++ b/rotators/spid/spid.c @@ -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; } diff --git a/rotators/ts7400/ts7400.c b/rotators/ts7400/ts7400.c index f8abef74d..953504c91 100644 --- a/rotators/ts7400/ts7400.c +++ b/rotators/ts7400/ts7400.c @@ -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;