kopia lustrzana https://github.com/Hamlib/Hamlib
Change gs232b parsing to mandate at least AZ= and make EL= optional
This covers the 12PR1A rotor which claims gs232b compatibility The 12PR1A also claims gs232a compability which is wrong as the AZ= EL= format is gs232b https://github.com/Hamlib/Hamlib/issues/309 Simplify gs232a parsing but mandate both arguments in +0xxx+0xxx formatpull/314/head
rodzic
7dedf007a1
commit
786c1ae925
|
@ -180,33 +180,27 @@ static int
|
||||||
gs232a_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
|
gs232a_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
|
||||||
{
|
{
|
||||||
char posbuf[32];
|
char posbuf[32];
|
||||||
int retval, angle;
|
int retval, int_az, int_el = 0;
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__);
|
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__);
|
||||||
|
|
||||||
retval = gs232a_transaction(rot, "C2" EOM, posbuf, sizeof(posbuf), 0);
|
retval = gs232a_transaction(rot, "C2" EOM, posbuf, sizeof(posbuf), 0);
|
||||||
|
|
||||||
if (retval != RIG_OK || strlen(posbuf) < 10)
|
if (retval != RIG_OK)
|
||||||
{
|
{
|
||||||
return retval < 0 ? retval : -RIG_EPROTO;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* parse "+0aaa+0eee" */
|
// parse "+0aaa+0eee" and expect both arguments
|
||||||
if (sscanf(posbuf + 2, "%d", &angle) != 1)
|
if (sscanf(posbuf, "+0%d+0%d", &int_az, &int_el) != 2)
|
||||||
{
|
{
|
||||||
rig_debug(RIG_DEBUG_ERR, "%s: wrong reply '%s'\n", __func__, posbuf);
|
rig_debug(RIG_DEBUG_ERR, "%s: wrong reply '%s', not +0xxx+0xxx format?\n",
|
||||||
|
__func__, posbuf);
|
||||||
return -RIG_EPROTO;
|
return -RIG_EPROTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
*az = (azimuth_t)angle;
|
*az = (azimuth_t) int_az;
|
||||||
|
*el = (elevation_t) int_el;
|
||||||
if (sscanf(posbuf + 7, "%d", &angle) != 1)
|
|
||||||
{
|
|
||||||
rig_debug(RIG_DEBUG_ERR, "%s: wrong reply '%s'\n", __func__, posbuf);
|
|
||||||
return -RIG_EPROTO;
|
|
||||||
}
|
|
||||||
|
|
||||||
*el = (elevation_t)angle;
|
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_TRACE, "%s: (az, el) = (%.1f, %.1f)\n",
|
rig_debug(RIG_DEBUG_TRACE, "%s: (az, el) = (%.1f, %.1f)\n",
|
||||||
__func__, *az, *el);
|
__func__, *az, *el);
|
||||||
|
@ -298,9 +292,9 @@ 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 = "20200505.0",
|
.version = "20200617.0",
|
||||||
.copyright = "LGPL",
|
.copyright = "LGPL",
|
||||||
.status = RIG_STATUS_ALPHA,
|
.status = RIG_STATUS_STABLE,
|
||||||
.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,
|
||||||
|
|
|
@ -141,7 +141,8 @@ transaction_write:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
https://github.com/Hamlib/Hamlib/issues/272
|
https://github.com/Hamlib/Hamlib/issues/272
|
||||||
|
|
||||||
// If asked for we will check for connection
|
// If asked for we will check for connection
|
||||||
// we don't expect a reply...just a prompt return
|
// we don't expect a reply...just a prompt return
|
||||||
// Seems some GS232B's only echo the CR
|
// Seems some GS232B's only echo the CR
|
||||||
|
@ -152,6 +153,7 @@ transaction_write:
|
||||||
__func__, data, cmdstr);
|
__func__, data, cmdstr);
|
||||||
return -RIG_EPROTO;
|
return -RIG_EPROTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (data[0] == '?')
|
if (data[0] == '?')
|
||||||
|
@ -207,7 +209,7 @@ static int
|
||||||
gs232b_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
|
gs232b_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
|
||||||
{
|
{
|
||||||
char posbuf[32];
|
char posbuf[32];
|
||||||
int retval, int_az, int_el;
|
int retval, int_az = 0, int_el = 0;
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__);
|
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__);
|
||||||
|
|
||||||
|
@ -223,9 +225,10 @@ gs232b_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
|
||||||
/* With the format string containing a space character as one of the
|
/* With the format string containing a space character as one of the
|
||||||
* directives, any amount of space is matched, including none in the input.
|
* directives, any amount of space is matched, including none in the input.
|
||||||
*/
|
*/
|
||||||
if (sscanf(posbuf, "AZ=%d EL=%d", &int_az, &int_el) != 2)
|
// There's a 12PR1A rotor that only returns AZ so we may only get AZ=xxx
|
||||||
{
|
if (sscanf(posbuf, "AZ=%d EL=%d", &int_az, &int_el) == 0)
|
||||||
rig_debug(RIG_DEBUG_ERR, "%s: wrong reply '%s'\n", __func__,
|
{ // only give error if we didn't parse anything
|
||||||
|
rig_debug(RIG_DEBUG_ERR, "%s: wrong reply '%s', expected AZ=xxx EL=xxx\n", __func__,
|
||||||
posbuf);
|
posbuf);
|
||||||
return -RIG_EPROTO;
|
return -RIG_EPROTO;
|
||||||
}
|
}
|
||||||
|
@ -324,7 +327,7 @@ 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 = "20200615.0",
|
.version = "20200617.0",
|
||||||
.copyright = "LGPL",
|
.copyright = "LGPL",
|
||||||
.status = RIG_STATUS_STABLE,
|
.status = RIG_STATUS_STABLE,
|
||||||
.rot_type = ROT_TYPE_OTHER,
|
.rot_type = ROT_TYPE_OTHER,
|
||||||
|
|
Ładowanie…
Reference in New Issue