kopia lustrzana https://github.com/Hamlib/Hamlib
Fixes go gs232 rotors
commit
2c707c13be
|
@ -59,7 +59,7 @@
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
gs232a_transaction (ROT *rot, const char *cmdstr,
|
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;
|
struct rot_state *rs;
|
||||||
int retval;
|
int retval;
|
||||||
|
@ -84,11 +84,14 @@ transaction_write:
|
||||||
if (!data_len)
|
if (!data_len)
|
||||||
data_len = BUFSZ;
|
data_len = BUFSZ;
|
||||||
|
|
||||||
retval = read_string(&rs->rotport, data, data_len, REPLY_EOM, strlen(REPLY_EOM));
|
if (!no_reply) {
|
||||||
if (retval < 0) {
|
memset(data,0,data_len);
|
||||||
if (retry_read++ < rot->state.rotport.retry)
|
retval = read_string(&rs->rotport, data, data_len, REPLY_EOM, strlen(REPLY_EOM));
|
||||||
goto transaction_write;
|
if (retval < 0) {
|
||||||
goto transaction_quit;
|
if (retry_read++ < rot->state.rotport.retry)
|
||||||
|
goto transaction_write;
|
||||||
|
goto transaction_quit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -123,7 +126,7 @@ gs232a_rot_set_position(ROT *rot, azimuth_t az, elevation_t el)
|
||||||
int retval;
|
int retval;
|
||||||
unsigned u_az, u_el;
|
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) {
|
if (az < 0.0) {
|
||||||
az = az + 360.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);
|
u_el = (unsigned)rint(el);
|
||||||
|
|
||||||
sprintf(cmdstr, "W%03u %03u" EOM, u_az, u_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) {
|
if (retval != RIG_OK) {
|
||||||
return retval;
|
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__);
|
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) {
|
if (retval != RIG_OK || strlen(posbuf) < 10) {
|
||||||
return retval < 0 ? retval : -RIG_EPROTO;
|
return retval < 0 ? retval : -RIG_EPROTO;
|
||||||
}
|
}
|
||||||
|
@ -180,7 +183,7 @@ gs232a_rot_stop(ROT *rot)
|
||||||
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __FUNCTION__);
|
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __FUNCTION__);
|
||||||
|
|
||||||
/* All Stop */
|
/* All Stop */
|
||||||
retval = gs232a_transaction(rot, "S" EOM, NULL, 0);
|
retval = gs232a_transaction(rot, "S" EOM, NULL, 0, 0);
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
|
@ -202,7 +205,7 @@ gs232a_rot_move(ROT *rot, int direction, int speed)
|
||||||
|
|
||||||
/* between 1 (slowest) and 4 (fastest) */
|
/* between 1 (slowest) and 4 (fastest) */
|
||||||
sprintf(cmdstr, "X%u" EOM, x_speed);
|
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)
|
if (retval != RIG_OK)
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
|
@ -225,7 +228,7 @@ gs232a_rot_move(ROT *rot, int direction, int speed)
|
||||||
return -RIG_EINVAL;
|
return -RIG_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = gs232a_transaction(rot, cmdstr, NULL, 0);
|
retval = gs232a_transaction(rot, cmdstr, NULL, 0, 1);
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
|
@ -241,7 +244,7 @@ const struct rot_caps gs23_rot_caps = {
|
||||||
.rot_model = ROT_MODEL_GS23,
|
.rot_model = ROT_MODEL_GS23,
|
||||||
.model_name = "GS-23",
|
.model_name = "GS-23",
|
||||||
.mfg_name = "Yaesu/Kenpro",
|
.mfg_name = "Yaesu/Kenpro",
|
||||||
.version = "0.1",
|
.version = "0.2",
|
||||||
.copyright = "LGPL",
|
.copyright = "LGPL",
|
||||||
.status = RIG_STATUS_ALPHA,
|
.status = RIG_STATUS_ALPHA,
|
||||||
.rot_type = ROT_TYPE_AZEL,
|
.rot_type = ROT_TYPE_AZEL,
|
||||||
|
@ -278,7 +281,7 @@ const struct rot_caps gs232_rot_caps = {
|
||||||
.mfg_name = "Yaesu/Kenpro",
|
.mfg_name = "Yaesu/Kenpro",
|
||||||
.version = "0.1",
|
.version = "0.1",
|
||||||
.copyright = "LGPL",
|
.copyright = "LGPL",
|
||||||
.status = RIG_STATUS_ALPHA,
|
.status = RIG_STATUS_BETA,
|
||||||
.rot_type = ROT_TYPE_AZEL,
|
.rot_type = ROT_TYPE_AZEL,
|
||||||
.port_type = RIG_PORT_SERIAL,
|
.port_type = RIG_PORT_SERIAL,
|
||||||
.serial_rate_min = 150,
|
.serial_rate_min = 150,
|
||||||
|
|
|
@ -60,12 +60,11 @@
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
gs232b_transaction(ROT *rot, const char *cmdstr,
|
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;
|
struct rot_state *rs;
|
||||||
int retval;
|
int retval;
|
||||||
int retry_read = 0;
|
int retry_read = 0;
|
||||||
int noreply = 0;
|
|
||||||
char replybuf[BUFSZ];
|
char replybuf[BUFSZ];
|
||||||
|
|
||||||
rs = &rot->state;
|
rs = &rot->state;
|
||||||
|
@ -86,10 +85,11 @@ transaction_write:
|
||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
write_block(&rs->rotport, EOM, strlen(EOM));
|
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 */
|
/* Always read the reply to know whether the cmd went OK */
|
||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
|
@ -101,8 +101,9 @@ transaction_write:
|
||||||
data_len = BUFSZ;
|
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)
|
if (retval < 0)
|
||||||
{
|
{
|
||||||
|
@ -134,19 +135,15 @@ transaction_write:
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// If asked for we will check for connection
|
||||||
if (noreply)
|
// 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
|
rig_debug(RIG_DEBUG_VERBOSE,
|
||||||
if (strncmp(data, "?>", 2) != 0)
|
"%s: Expected '?>' but got '%s' from cmd '%s'\n",
|
||||||
{
|
__FUNCTION__, data, cmdstr);
|
||||||
rig_debug(RIG_DEBUG_VERBOSE,
|
return -RIG_EPROTO;
|
||||||
"%s: Expected '?>' but got '%s' from cmd '%s'\n",
|
|
||||||
__FUNCTION__, data, cmdstr);
|
|
||||||
return -RIG_EPROTO;
|
|
||||||
}
|
|
||||||
|
|
||||||
return RIG_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data[0] == '?')
|
if (data[0] == '?')
|
||||||
|
@ -167,11 +164,12 @@ transaction_quit:
|
||||||
static int
|
static int
|
||||||
gs232b_rot_set_position(ROT *rot, azimuth_t az, elevation_t el)
|
gs232b_rot_set_position(ROT *rot, azimuth_t az, elevation_t el)
|
||||||
{
|
{
|
||||||
|
char buf[32];
|
||||||
char cmdstr[64];
|
char cmdstr[64];
|
||||||
int retval;
|
int retval;
|
||||||
unsigned u_az, u_el;
|
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)
|
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);
|
u_el = (unsigned) rint(el);
|
||||||
|
|
||||||
sprintf(cmdstr, "W%03u %03u" EOM, u_az, u_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)
|
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__);
|
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)
|
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
|
static int
|
||||||
gs232b_rot_stop(ROT *rot)
|
gs232b_rot_stop(ROT *rot)
|
||||||
{
|
{
|
||||||
|
char buf[32];
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __FUNCTION__);
|
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __FUNCTION__);
|
||||||
|
|
||||||
/* All Stop */
|
/* All Stop */
|
||||||
retval = gs232b_transaction(rot, "S" EOM, NULL, 0);
|
retval = gs232b_transaction(rot, "S" EOM, buf, sizeof(buf), 0);
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -261,7 +260,7 @@ gs232b_rot_move(ROT *rot, int direction, int speed)
|
||||||
|
|
||||||
/* between 1 (slowest) and 4 (fastest) */
|
/* between 1 (slowest) and 4 (fastest) */
|
||||||
sprintf(cmdstr, "X%u" EOM, x_speed);
|
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)
|
if (retval != RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -292,7 +291,7 @@ gs232b_rot_move(ROT *rot, int direction, int speed)
|
||||||
return -RIG_EINVAL;
|
return -RIG_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = gs232b_transaction(rot, cmdstr, NULL, 0);
|
retval = gs232b_transaction(rot, cmdstr, NULL, 0, 1);
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -312,9 +311,9 @@ const struct rot_caps gs232b_rot_caps =
|
||||||
.rot_model = ROT_MODEL_GS232B,
|
.rot_model = ROT_MODEL_GS232B,
|
||||||
.model_name = "GS-232B",
|
.model_name = "GS-232B",
|
||||||
.mfg_name = "Yaesu",
|
.mfg_name = "Yaesu",
|
||||||
.version = "0.4",
|
.version = "0.5",
|
||||||
.copyright = "LGPL",
|
.copyright = "LGPL",
|
||||||
.status = RIG_STATUS_BETA,
|
.status = RIG_STATUS_STABLE,
|
||||||
.rot_type = ROT_TYPE_OTHER,
|
.rot_type = ROT_TYPE_OTHER,
|
||||||
.port_type = RIG_PORT_SERIAL,
|
.port_type = RIG_PORT_SERIAL,
|
||||||
.serial_rate_min = 1200,
|
.serial_rate_min = 1200,
|
||||||
|
|
|
@ -385,7 +385,8 @@ const char * HAMLIB_API rig_strrmode(rmode_t mode)
|
||||||
{
|
{
|
||||||
int i;
|
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)
|
if (mode == RIG_MODE_NONE)
|
||||||
{
|
{
|
||||||
|
@ -572,7 +573,8 @@ const char * HAMLIB_API rig_strfunc(setting_t func)
|
||||||
{
|
{
|
||||||
int i;
|
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)
|
if (func == RIG_FUNC_NONE)
|
||||||
{
|
{
|
||||||
|
|
Ładowanie…
Reference in New Issue