kopia lustrzana https://github.com/Hamlib/Hamlib
astyle for gs232b.c and minor changes to debug msgs
rodzic
ed2e552852
commit
aa3a701248
|
@ -74,11 +74,17 @@ transaction_write:
|
||||||
|
|
||||||
serial_flush(&rs->rotport);
|
serial_flush(&rs->rotport);
|
||||||
|
|
||||||
if (cmdstr) {
|
if (cmdstr)
|
||||||
|
{
|
||||||
retval = write_block(&rs->rotport, cmdstr, strlen(cmdstr));
|
retval = write_block(&rs->rotport, cmdstr, strlen(cmdstr));
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
|
{
|
||||||
goto transaction_quit;
|
goto transaction_quit;
|
||||||
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
|
noreply = 1; // we will check for connectivity though
|
||||||
}
|
}
|
||||||
|
@ -86,40 +92,66 @@ transaction_write:
|
||||||
|
|
||||||
/* 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)
|
||||||
|
{
|
||||||
data = replybuf;
|
data = replybuf;
|
||||||
|
}
|
||||||
|
|
||||||
if (!data_len)
|
if (!data_len)
|
||||||
|
{
|
||||||
data_len = BUFSZ;
|
data_len = BUFSZ;
|
||||||
|
}
|
||||||
|
|
||||||
memset(data, 0, data_len);
|
memset(data, 0, data_len);
|
||||||
retval = read_string(&rs->rotport, data, data_len, REPLY_EOM, strlen(REPLY_EOM));
|
retval =
|
||||||
if (retval < 0) {
|
read_string(&rs->rotport, data, data_len, REPLY_EOM, strlen(REPLY_EOM));
|
||||||
|
|
||||||
|
if (retval < 0)
|
||||||
|
{
|
||||||
if (retry_read++ < rot->state.rotport.retry)
|
if (retry_read++ < rot->state.rotport.retry)
|
||||||
|
{
|
||||||
goto transaction_write;
|
goto transaction_write;
|
||||||
|
}
|
||||||
|
|
||||||
goto transaction_quit;
|
goto transaction_quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* Check that command termination is correct */
|
/* Check that command termination is correct */
|
||||||
|
|
||||||
if (strchr(REPLY_EOM, data[strlen(data)-1])==NULL) {
|
if (strchr(REPLY_EOM, data[strlen(data) - 1]) == NULL)
|
||||||
rig_debug(RIG_DEBUG_ERR, "%s: Command is not correctly terminated '%s'\n", __FUNCTION__, data);
|
{
|
||||||
|
rig_debug(RIG_DEBUG_ERR,
|
||||||
|
"%s: Command is not correctly terminated '%s'\n",
|
||||||
|
__FUNCTION__, data);
|
||||||
|
|
||||||
if (retry_read++ < rig->state.rotport.retry)
|
if (retry_read++ < rig->state.rotport.retry)
|
||||||
|
{
|
||||||
goto transaction_write;
|
goto transaction_write;
|
||||||
|
}
|
||||||
|
|
||||||
retval = -RIG_EPROTO;
|
retval = -RIG_EPROTO;
|
||||||
goto transaction_quit;
|
goto transaction_quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
if (noreply) { // we don't expect a reply...just a prompt return
|
if (noreply)
|
||||||
if (strncmp(data,"?>",2) != 0) {
|
{
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: Expected '?>' but got '%s' from cmd '%s'\n",
|
// 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);
|
__FUNCTION__, data, cmdstr);
|
||||||
return -RIG_EPROTO;
|
return -RIG_EPROTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
if (data[0] == '?') {
|
|
||||||
|
if (data[0] == '?')
|
||||||
|
{
|
||||||
/* Invalid command */
|
/* Invalid command */
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: Error for '%s': '%s'\n",
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: Error for '%s': '%s'\n",
|
||||||
__FUNCTION__, cmdstr, data);
|
__FUNCTION__, cmdstr, data);
|
||||||
|
@ -140,17 +172,21 @@ gs232b_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: az=.0f el=%.0f\n", __FUNCTION__, az, el);
|
||||||
if (az < 0.0){
|
|
||||||
|
if (az < 0.0)
|
||||||
|
{
|
||||||
az = az + 360.0;
|
az = az + 360.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
u_az = (unsigned) rint(az);
|
u_az = (unsigned) rint(az);
|
||||||
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, NULL, 0);
|
||||||
|
|
||||||
if (retval != RIG_OK) {
|
if (retval != RIG_OK)
|
||||||
|
{
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +202,9 @@ 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));
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,14 +213,17 @@ 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) {
|
if (sscanf(posbuf, "AZ=%d EL=%d", &int_az, &int_el) != 2)
|
||||||
rig_debug(RIG_DEBUG_ERR, "%s: wrong reply '%s'\n", __FUNCTION__, posbuf);
|
{
|
||||||
|
rig_debug(RIG_DEBUG_ERR, "%s: wrong reply '%s'\n", __FUNCTION__,
|
||||||
|
posbuf);
|
||||||
return -RIG_EPROTO;
|
return -RIG_EPROTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
*az = (azimuth_t) int_az;
|
*az = (azimuth_t) int_az;
|
||||||
*el = (elevation_t) int_el;
|
*el = (elevation_t) int_el;
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_TRACE, "%s: (az, el) = (%.1f, %.1f)\n",
|
rig_debug(RIG_DEBUG_TRACE, "%s: (az, el) = (%.0f, %.0f)\n",
|
||||||
__FUNCTION__, *az, *el);
|
__FUNCTION__, *az, *el);
|
||||||
|
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
|
@ -197,8 +238,11 @@ gs232b_rot_stop(ROT *rot)
|
||||||
|
|
||||||
/* All Stop */
|
/* All Stop */
|
||||||
retval = gs232b_transaction(rot, "S" EOM, NULL, 0);
|
retval = gs232b_transaction(rot, "S" EOM, NULL, 0);
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
|
{
|
||||||
return retval;
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
@ -219,22 +263,30 @@ 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);
|
||||||
if (retval != RIG_OK)
|
|
||||||
return retval;
|
|
||||||
|
|
||||||
switch (direction) {
|
if (retval != RIG_OK)
|
||||||
|
{
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (direction)
|
||||||
|
{
|
||||||
case ROT_MOVE_UP: /* Elevation increase */
|
case ROT_MOVE_UP: /* Elevation increase */
|
||||||
sprintf(cmdstr, "U" EOM);
|
sprintf(cmdstr, "U" EOM);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ROT_MOVE_DOWN: /* Elevation decrease */
|
case ROT_MOVE_DOWN: /* Elevation decrease */
|
||||||
sprintf(cmdstr, "D" EOM);
|
sprintf(cmdstr, "D" EOM);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ROT_MOVE_LEFT: /* Azimuth decrease */
|
case ROT_MOVE_LEFT: /* Azimuth decrease */
|
||||||
sprintf(cmdstr, "L" EOM);
|
sprintf(cmdstr, "L" EOM);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ROT_MOVE_RIGHT: /* Azimuth increase */
|
case ROT_MOVE_RIGHT: /* Azimuth increase */
|
||||||
sprintf(cmdstr, "R" EOM);
|
sprintf(cmdstr, "R" EOM);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
rig_debug(RIG_DEBUG_ERR, "%s: Invalid direction value! (%d)\n",
|
rig_debug(RIG_DEBUG_ERR, "%s: Invalid direction value! (%d)\n",
|
||||||
__FUNCTION__, direction);
|
__FUNCTION__, direction);
|
||||||
|
@ -242,8 +294,11 @@ gs232b_rot_move(ROT *rot, int direction, int speed)
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = gs232b_transaction(rot, cmdstr, NULL, 0);
|
retval = gs232b_transaction(rot, cmdstr, NULL, 0);
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
|
{
|
||||||
return retval;
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
@ -253,7 +308,8 @@ gs232b_rot_move(ROT *rot, int direction, int speed)
|
||||||
* Generic GS232B rotator capabilities.
|
* Generic GS232B rotator capabilities.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const struct rot_caps gs232b_rot_caps = {
|
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",
|
||||||
|
@ -285,4 +341,3 @@ const struct rot_caps gs232b_rot_caps = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* end of file */
|
/* end of file */
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue