kopia lustrzana https://github.com/Hamlib/Hamlib
gs232b.c: Improve get_position string parsing
I've found a problem with my setup. I'm using a Yaesu G-5500 with an arduino running: http://blog.radioartisan.com/yaesu-rotator-computer-serial-interface/ to emulate a GS232b. The problem is that the Elevation in rotctl was incorrectly reported, with the least significant digit show. The problem I've found is some incompatibility between the format of the answer and the parser. Here I'm pasting a new version of gs232b_rot_get_position() which both solves my issue and should be a bit more reliable to protocol differences, while simpler than the previous. (a white space in sscanf() matches none or any number of whitespaces, my emulated GS232B was reporting AZ=123EL=033 with no spaces. This got broken recently, and I haven't touched the code running in the arduino). Signed-off-by: Nate Bargmann <n0nb@n0nb.us>Hamlib-3.0
rodzic
61ce272911
commit
7a7813cb48
|
@ -146,7 +146,7 @@ static int
|
|||
gs232b_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
|
||||
{
|
||||
char posbuf[32];
|
||||
int retval, angle;
|
||||
int retval, int_az, int_el;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __FUNCTION__);
|
||||
|
||||
|
@ -156,17 +156,16 @@ gs232b_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
|
|||
}
|
||||
|
||||
/* parse "AZ=aaa EL=eee" */
|
||||
if (sscanf(posbuf+3, "%d", &angle) != 1) {
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: wrong reply '%s'\n", __FUNCTION__, posbuf);
|
||||
return -RIG_EPROTO;
|
||||
}
|
||||
*az = (azimuth_t)angle;
|
||||
|
||||
if (sscanf(posbuf+11, "%d", &angle) != 1) {
|
||||
/* With the format string containing a space character as one of the
|
||||
* directives, any amount of space is matched, including none in the input.
|
||||
*/
|
||||
if (sscanf(posbuf, "AZ=%d EL=%d", &int_az, &int_el) != 2) {
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: wrong reply '%s'\n", __FUNCTION__, posbuf);
|
||||
return -RIG_EPROTO;
|
||||
}
|
||||
*el = (elevation_t)angle;
|
||||
*az = (azimuth_t)int_az;
|
||||
*el = (elevation_t)int_el;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: (az, el) = (%.1f, %.1f)\n",
|
||||
__FUNCTION__, *az, *el);
|
||||
|
|
Ładowanie…
Reference in New Issue