easycomm patch from Steve Conklin, AI4QR

The attached patch restores what I think is the original easycomm
rotator interface functionality. It eliminates the conditional code
for USE_CUSTOM_CODE and USE_TEST_CODE.

Apparently for a very long time, the easycomm back end has been build
with USE_CUSTOM_CODE hardcoded in the source file. This generated code
that issued commands not even remotely similar to what's specified in
the easycommII protocol, which is documented in the easycomm directory
for hamlib.

It appears that at some point someone used the easycomm back end to
implement some custom tests for something, and it was committed and
has been carried this way ever since.

This restored what I think is proper functionality according to the
easycomm spec.

If you are a user of the easycomm back end, or you know of any
easycomm compatible rotor controllers that can be used for testing,
let me know and I can be more thorough about this.

Notes and disclaimers:

0. The original easycomm spec author seems to be unavailable.

1. I don't think that there was valid code to parse the position data
returned from the rotor controller. What was actually getting compiled
simply set some hard-coded values. I replaced it with what I think is
called for by the spec.

2. The easycomm spec is vague about what is supposed to be returned
for any command, so I may still not be parsing position information
correctly as it comes from other easycomm controllers.

3. I wrote my own rotator controller code based upon an interpretation
of the easycomm II spec. This back end for rotctl works with my
implementation. I don't have access to any other easycomm controllers
or even know whether any exist, so I am unable to test this against
any other implementation of easycomm.

4. Even when you select EASYCOMM II as the back end, it sends commands
which are only supposed to be valid for easycomm I according to the
spec (i.e. the position set command includes uplink and downlink
frequency and mode information fields). My rotor controller handles
these, so I didn't change the position set portion of the code.

I understand if there's concern for breaking rotator control for
existing users of the easycomm back end (if any actually exist). If
this patch is too risky, I'll either rewrite my controller to use
another protocol, or add another back end for my own newly invented
protocol "ai4qrcomm" (and document it better than easycomm).

Thanks,

Steve, AI4QR

Signed-off-by: Nate Bargmann <n0nb@n0nb.us>
Hamlib-3.0
Steve Conklin 2013-09-05 18:21:04 -05:00 zatwierdzone przez Nate Bargmann
rodzic 332a04b7cd
commit e6889901da
1 zmienionych plików z 5 dodań i 43 usunięć

Wyświetl plik

@ -37,8 +37,6 @@
#include "easycomm.h"
#define USE_CUSTOM_CODE 1
/* ************************************************************************* */
/**
* easycomm_transaction
@ -97,58 +95,23 @@ easycomm_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
{
char cmdstr[16], ackbuf[32];
int retval;
int t;
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __FUNCTION__);
#ifdef USE_CUSTOM_CODE
sprintf(cmdstr, "!"); /* Custom implementation: Remove later */
#else
sprintf(cmdstr, "AZ EL \n");
#endif
retval = easycomm_transaction(rot, cmdstr, ackbuf, sizeof(ackbuf));
if (retval != RIG_OK) {
return retval;
return retval;
}
/* Parse parse string to extract AZ,EL values */
#ifdef USE_CUSTOM_CODE
retval = sscanf(ackbuf, "TM%i AZ%f EL%f", &t, az, el);
if (retval != 3) {
rig_debug(RIG_DEBUG_ERR, "%s: unknown replay (%s)\n", __FUNCTION__, ackbuf);
retval = sscanf(ackbuf, "AZ%f EL%f", az, el);
if (retval != 2) {
rig_debug(RIG_DEBUG_ERR, "%s: unknown response (%s)\n", __FUNCTION__, ackbuf);
return -RIG_ERJCTED;
}
#ifndef USETESTCODE
/* Correct for desimal point. */
*az /= 10.0;
*el /= 10.0;
#else
/* Debugging code, remove later */
rig_debug(RIG_DEBUG_TRACE, " (az, el) = (%.1f, %.1f)\n", *az, *el);
*az /= 10.0;
*el /= 10.0;
rig_debug(RIG_DEBUG_TRACE, " (az, el) = (%f, %f)\n", *az, *el);
rig_debug(RIG_DEBUG_TRACE, " (az, el) = (%.2f, %.2f)\n", *az, *el);
/* Note: For some reason I found that the result of this expression
* does not give accurate results.
* The first printf give the correct value.
* The second printf give incorrect value, while
* the third printf give correct values.
*
* I get az = 42.79999 when it should be 42.8
*/
#endif
#else
*az = 45.3;
*el = 10.3;
#endif
return RIG_OK;
return RIG_OK;
}
static int
@ -328,4 +291,3 @@ DECLARE_INITROT_BACKEND(easycomm)
/* ************************************************************************* */
/* end of file */