Fixes go gs232 rotors

This commit is contained in:
Michael Black 2019-11-23 22:19:24 -06:00
commit 2c707c13be
No known key found for this signature in database
GPG Key ID: 6599353EC683404D
3 changed files with 45 additions and 41 deletions

31
gs232a/gs232a.c Normal file → Executable file
View File

@ -59,7 +59,7 @@
*/
static int
gs232a_transaction (ROT *rot, const char *cmdstr,
char *data, size_t data_len)
char *data, size_t data_len, int no_reply)
{
struct rot_state *rs;
int retval;
@ -84,11 +84,14 @@ transaction_write:
if (!data_len)
data_len = BUFSZ;
retval = read_string(&rs->rotport, data, data_len, REPLY_EOM, strlen(REPLY_EOM));
if (retval < 0) {
if (retry_read++ < rot->state.rotport.retry)
goto transaction_write;
goto transaction_quit;
if (!no_reply) {
memset(data,0,data_len);
retval = read_string(&rs->rotport, data, data_len, REPLY_EOM, strlen(REPLY_EOM));
if (retval < 0) {
if (retry_read++ < rot->state.rotport.retry)
goto transaction_write;
goto transaction_quit;
}
}
#if 0
@ -123,7 +126,7 @@ gs232a_rot_set_position(ROT *rot, azimuth_t az, elevation_t el)
int retval;
unsigned u_az, u_el;
rig_debug(RIG_DEBUG_TRACE, "%s called: %f %f\n", __FUNCTION__, az, el);
rig_debug(RIG_DEBUG_TRACE, "%s called: %.02f %.02f\n", __FUNCTION__, az, el);
if (az < 0.0) {
az = az + 360.0;
}
@ -131,7 +134,7 @@ gs232a_rot_set_position(ROT *rot, azimuth_t az, elevation_t el)
u_el = (unsigned)rint(el);
sprintf(cmdstr, "W%03u %03u" EOM, u_az, u_el);
retval = gs232a_transaction(rot, cmdstr, NULL, 0);
retval = gs232a_transaction(rot, cmdstr, NULL, 0, 0);
if (retval != RIG_OK) {
return retval;
@ -148,7 +151,7 @@ gs232a_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __FUNCTION__);
retval = gs232a_transaction(rot, "C2" EOM, posbuf, sizeof(posbuf));
retval = gs232a_transaction(rot, "C2" EOM, posbuf, sizeof(posbuf), 0);
if (retval != RIG_OK || strlen(posbuf) < 10) {
return retval < 0 ? retval : -RIG_EPROTO;
}
@ -180,7 +183,7 @@ gs232a_rot_stop(ROT *rot)
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __FUNCTION__);
/* All Stop */
retval = gs232a_transaction(rot, "S" EOM, NULL, 0);
retval = gs232a_transaction(rot, "S" EOM, NULL, 0, 0);
if (retval != RIG_OK)
return retval;
@ -202,7 +205,7 @@ gs232a_rot_move(ROT *rot, int direction, int speed)
/* between 1 (slowest) and 4 (fastest) */
sprintf(cmdstr, "X%u" EOM, x_speed);
retval = gs232a_transaction(rot, cmdstr, NULL, 0);
retval = gs232a_transaction(rot, cmdstr, NULL, 0, 1);
if (retval != RIG_OK)
return retval;
@ -225,7 +228,7 @@ gs232a_rot_move(ROT *rot, int direction, int speed)
return -RIG_EINVAL;
}
retval = gs232a_transaction(rot, cmdstr, NULL, 0);
retval = gs232a_transaction(rot, cmdstr, NULL, 0, 1);
if (retval != RIG_OK)
return retval;
@ -241,7 +244,7 @@ const struct rot_caps gs23_rot_caps = {
.rot_model = ROT_MODEL_GS23,
.model_name = "GS-23",
.mfg_name = "Yaesu/Kenpro",
.version = "0.1",
.version = "0.2",
.copyright = "LGPL",
.status = RIG_STATUS_ALPHA,
.rot_type = ROT_TYPE_AZEL,
@ -278,7 +281,7 @@ const struct rot_caps gs232_rot_caps = {
.mfg_name = "Yaesu/Kenpro",
.version = "0.1",
.copyright = "LGPL",
.status = RIG_STATUS_ALPHA,
.status = RIG_STATUS_BETA,
.rot_type = ROT_TYPE_AZEL,
.port_type = RIG_PORT_SERIAL,
.serial_rate_min = 150,

View File

@ -60,12 +60,11 @@
*/
static int
gs232b_transaction(ROT *rot, const char *cmdstr,
char *data, size_t data_len)
char *data, size_t data_len, int no_reply)
{
struct rot_state *rs;
int retval;
int retry_read = 0;
int noreply = 0;
char replybuf[BUFSZ];
rs = &rot->state;
@ -86,10 +85,11 @@ transaction_write:
if (!data)
{
write_block(&rs->rotport, EOM, strlen(EOM));
noreply = 1; // we will check for connectivity though
}
}
if (no_reply) return RIG_OK; // nothing expected so return
/* Always read the reply to know whether the cmd went OK */
if (!data)
{
@ -101,8 +101,9 @@ transaction_write:
data_len = BUFSZ;
}
retval =
read_string(&rs->rotport, data, data_len, REPLY_EOM, strlen(REPLY_EOM));
memset(data, 0, data_len);
retval = read_string(&rs->rotport, data, data_len, REPLY_EOM, strlen(REPLY_EOM));
if (retval < 0)
{
@ -134,19 +135,15 @@ transaction_write:
#endif
if (noreply)
// If asked for we will check for connection
// we don't expect a reply...just a prompt return
// Seems some GS232B's only echo the CR
if (data == replybuf && (strncmp(data, "?>", 2) != 0) && data[0] != 0x0d)
{
// we don't expect a reply...just a prompt return
if (strncmp(data, "?>", 2) != 0)
{
rig_debug(RIG_DEBUG_VERBOSE,
"%s: Expected '?>' but got '%s' from cmd '%s'\n",
__FUNCTION__, data, cmdstr);
return -RIG_EPROTO;
}
return RIG_OK;
rig_debug(RIG_DEBUG_VERBOSE,
"%s: Expected '?>' but got '%s' from cmd '%s'\n",
__FUNCTION__, data, cmdstr);
return -RIG_EPROTO;
}
if (data[0] == '?')
@ -167,11 +164,12 @@ transaction_quit:
static int
gs232b_rot_set_position(ROT *rot, azimuth_t az, elevation_t el)
{
char buf[32];
char cmdstr[64];
int retval;
unsigned u_az, u_el;
rig_debug(RIG_DEBUG_TRACE, "%s called: az=.0f el=%.0f\n", __FUNCTION__, az, el);
rig_debug(RIG_DEBUG_TRACE, "%s called: az=%.02f el=%.02f\n", __FUNCTION__, az, el);
if (az < 0.0)
{
@ -182,7 +180,7 @@ gs232b_rot_set_position(ROT *rot, azimuth_t az, elevation_t el)
u_el = (unsigned) rint(el);
sprintf(cmdstr, "W%03u %03u" EOM, u_az, u_el);
retval = gs232b_transaction(rot, cmdstr, NULL, 0);
retval = gs232b_transaction(rot, cmdstr, buf, sizeof(buf), 0);
if (retval != RIG_OK)
{
@ -200,7 +198,7 @@ gs232b_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __FUNCTION__);
retval = gs232b_transaction(rot, "C2" EOM, posbuf, sizeof(posbuf));
retval = gs232b_transaction(rot, "C2" EOM, posbuf, sizeof(posbuf), 0);
if (retval != RIG_OK || strlen(posbuf) < 10)
{
@ -231,12 +229,13 @@ gs232b_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
static int
gs232b_rot_stop(ROT *rot)
{
char buf[32];
int retval;
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __FUNCTION__);
/* All Stop */
retval = gs232b_transaction(rot, "S" EOM, NULL, 0);
retval = gs232b_transaction(rot, "S" EOM, buf, sizeof(buf), 0);
if (retval != RIG_OK)
{
@ -261,7 +260,7 @@ gs232b_rot_move(ROT *rot, int direction, int speed)
/* between 1 (slowest) and 4 (fastest) */
sprintf(cmdstr, "X%u" EOM, x_speed);
retval = gs232b_transaction(rot, cmdstr, NULL, 0);
retval = gs232b_transaction(rot, cmdstr, NULL, 0, 1);
if (retval != RIG_OK)
{
@ -292,7 +291,7 @@ gs232b_rot_move(ROT *rot, int direction, int speed)
return -RIG_EINVAL;
}
retval = gs232b_transaction(rot, cmdstr, NULL, 0);
retval = gs232b_transaction(rot, cmdstr, NULL, 0, 1);
if (retval != RIG_OK)
{
@ -312,9 +311,9 @@ const struct rot_caps gs232b_rot_caps =
.rot_model = ROT_MODEL_GS232B,
.model_name = "GS-232B",
.mfg_name = "Yaesu",
.version = "0.4",
.version = "0.5",
.copyright = "LGPL",
.status = RIG_STATUS_BETA,
.status = RIG_STATUS_STABLE,
.rot_type = ROT_TYPE_OTHER,
.port_type = RIG_PORT_SERIAL,
.serial_rate_min = 1200,

View File

@ -385,7 +385,8 @@ const char * HAMLIB_API rig_strrmode(rmode_t mode)
{
int i;
rig_debug(RIG_DEBUG_TRACE, "%s called mode=0x%"PRXll"\n", __func__, mode);
// only enable it needed for debugging -- too verbose otherwise
//rig_debug(RIG_DEBUG_TRACE, "%s called mode=0x%"PRXll"\n", __func__, mode);
if (mode == RIG_MODE_NONE)
{
@ -572,7 +573,8 @@ const char * HAMLIB_API rig_strfunc(setting_t func)
{
int i;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
// too verbose to keep on unless debugging this in particular
//rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (func == RIG_FUNC_NONE)
{