astyle gs232 files

pull/145/head
Michael Black 2019-11-23 22:19:56 -06:00
rodzic 2c707c13be
commit 243fe294f4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6599353EC683404D
2 zmienionych plików z 351 dodań i 297 usunięć

276
gs232a/gs232a.c 100755 → 100644
Wyświetl plik

@ -58,8 +58,8 @@
* recognized by rig. * recognized by rig.
*/ */
static int static int
gs232a_transaction (ROT *rot, const char *cmdstr, gs232a_transaction(ROT *rot, const char *cmdstr,
char *data, size_t data_len, int no_reply) char *data, size_t data_len, int no_reply)
{ {
struct rot_state *rs; struct rot_state *rs;
int retval; int retval;
@ -72,45 +72,70 @@ 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;
}
} }
/* 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) }
data_len = BUFSZ;
if (!no_reply) { if (!data_len)
memset(data,0,data_len); {
retval = read_string(&rs->rotport, data, data_len, REPLY_EOM, strlen(REPLY_EOM)); data_len = BUFSZ;
if (retval < 0) { }
if (!no_reply)
{
memset(data, 0, data_len);
retval = 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 (data[0] == '?') { if (data[0] == '?')
/* Invalid command */ {
rig_debug(RIG_DEBUG_VERBOSE, "%s: Error for '%s': '%s'\n", /* Invalid command */
__FUNCTION__, cmdstr, data); rig_debug(RIG_DEBUG_VERBOSE, "%s: Error for '%s': '%s'\n",
retval = -RIG_EPROTO; __FUNCTION__, cmdstr, data);
goto transaction_quit; retval = -RIG_EPROTO;
goto transaction_quit;
} }
retval = RIG_OK; retval = RIG_OK;
@ -127,16 +152,20 @@ gs232a_rot_set_position(ROT *rot, azimuth_t az, elevation_t el)
unsigned u_az, u_el; unsigned u_az, u_el;
rig_debug(RIG_DEBUG_TRACE, "%s called: %.02f %.02f\n", __FUNCTION__, az, el); rig_debug(RIG_DEBUG_TRACE, "%s called: %.02f %.02f\n", __FUNCTION__, az, el);
if (az < 0.0) {
az = az + 360.0; if (az < 0.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 = gs232a_transaction(rot, cmdstr, NULL, 0, 0); retval = gs232a_transaction(rot, cmdstr, NULL, 0, 0);
if (retval != RIG_OK) { if (retval != RIG_OK)
{
return retval; return retval;
} }
@ -152,25 +181,31 @@ 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), 0); 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;
} }
/* parse "+0aaa+0eee" */ /* parse "+0aaa+0eee" */
if (sscanf(posbuf+2, "%d", &angle) != 1) { if (sscanf(posbuf + 2, "%d", &angle) != 1)
{
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)angle; *az = (azimuth_t)angle;
if (sscanf(posbuf+7, "%d", &angle) != 1) { if (sscanf(posbuf + 7, "%d", &angle) != 1)
{
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;
} }
*el = (elevation_t)angle; *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",
__FUNCTION__, *az, *el); __FUNCTION__, *az, *el);
return RIG_OK; return RIG_OK;
} }
@ -184,8 +219,11 @@ gs232a_rot_stop(ROT *rot)
/* All Stop */ /* All Stop */
retval = gs232a_transaction(rot, "S" EOM, NULL, 0, 0); retval = gs232a_transaction(rot, "S" EOM, NULL, 0, 0);
if (retval != RIG_OK) if (retval != RIG_OK)
{
return retval; return retval;
}
return RIG_OK; return RIG_OK;
} }
@ -199,38 +237,49 @@ gs232a_rot_move(ROT *rot, int direction, int speed)
unsigned x_speed; unsigned x_speed;
rig_debug(RIG_DEBUG_TRACE, "%s called %d %d\n", __FUNCTION__, rig_debug(RIG_DEBUG_TRACE, "%s called %d %d\n", __FUNCTION__,
direction, speed); direction, speed);
x_speed = (3*speed)/100 + 1; x_speed = (3 * speed) / 100 + 1;
/* 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, 1); retval = gs232a_transaction(rot, cmdstr, NULL, 0, 1);
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);
return -RIG_EINVAL; return -RIG_EINVAL;
} }
retval = gs232a_transaction(rot, cmdstr, NULL, 0, 1); retval = gs232a_transaction(rot, cmdstr, NULL, 0, 1);
if (retval != RIG_OK) if (retval != RIG_OK)
{
return retval; return retval;
}
return RIG_OK; return RIG_OK;
} }
@ -240,34 +289,35 @@ gs232a_rot_move(ROT *rot, int direction, int speed)
* Generic GS23 rotator capabilities. * Generic GS23 rotator capabilities.
*/ */
const struct rot_caps gs23_rot_caps = { const struct rot_caps gs23_rot_caps =
.rot_model = ROT_MODEL_GS23, {
.model_name = "GS-23", .rot_model = ROT_MODEL_GS23,
.mfg_name = "Yaesu/Kenpro", .model_name = "GS-23",
.version = "0.2", .mfg_name = "Yaesu/Kenpro",
.copyright = "LGPL", .version = "0.2",
.status = RIG_STATUS_ALPHA, .copyright = "LGPL",
.rot_type = ROT_TYPE_AZEL, .status = RIG_STATUS_ALPHA,
.port_type = RIG_PORT_SERIAL, .rot_type = ROT_TYPE_AZEL,
.serial_rate_min = 150, .port_type = RIG_PORT_SERIAL,
.serial_rate_max = 9600, .serial_rate_min = 150,
.serial_data_bits = 8, .serial_rate_max = 9600,
.serial_stop_bits = 1, .serial_data_bits = 8,
.serial_parity = RIG_PARITY_NONE, .serial_stop_bits = 1,
.serial_handshake = RIG_HANDSHAKE_NONE, .serial_parity = RIG_PARITY_NONE,
.write_delay = 0, .serial_handshake = RIG_HANDSHAKE_NONE,
.post_write_delay = 0, .write_delay = 0,
.timeout = 400, .post_write_delay = 0,
.retry = 3, .timeout = 400,
.retry = 3,
.min_az = -180.0, .min_az = -180.0,
.max_az = 450.0, /* vary according to rotator type */ .max_az = 450.0, /* vary according to rotator type */
.min_el = 0.0, .min_el = 0.0,
.max_el = 180.0, .max_el = 180.0,
.get_position = gs232a_rot_get_position, .get_position = gs232a_rot_get_position,
.set_position = gs232a_rot_set_position, .set_position = gs232a_rot_set_position,
.stop = gs232a_rot_stop, .stop = gs232a_rot_stop,
}; };
/* ************************************************************************* */ /* ************************************************************************* */
@ -275,34 +325,35 @@ const struct rot_caps gs23_rot_caps = {
* Generic GS232 rotator capabilities. * Generic GS232 rotator capabilities.
*/ */
const struct rot_caps gs232_rot_caps = { const struct rot_caps gs232_rot_caps =
.rot_model = ROT_MODEL_GS232, {
.model_name = "GS-232", .rot_model = ROT_MODEL_GS232,
.mfg_name = "Yaesu/Kenpro", .model_name = "GS-232",
.version = "0.1", .mfg_name = "Yaesu/Kenpro",
.copyright = "LGPL", .version = "0.1",
.status = RIG_STATUS_BETA, .copyright = "LGPL",
.rot_type = ROT_TYPE_AZEL, .status = RIG_STATUS_BETA,
.port_type = RIG_PORT_SERIAL, .rot_type = ROT_TYPE_AZEL,
.serial_rate_min = 150, .port_type = RIG_PORT_SERIAL,
.serial_rate_max = 9600, .serial_rate_min = 150,
.serial_data_bits = 8, .serial_rate_max = 9600,
.serial_stop_bits = 1, .serial_data_bits = 8,
.serial_parity = RIG_PARITY_NONE, .serial_stop_bits = 1,
.serial_handshake = RIG_HANDSHAKE_NONE, .serial_parity = RIG_PARITY_NONE,
.write_delay = 0, .serial_handshake = RIG_HANDSHAKE_NONE,
.post_write_delay = 0, .write_delay = 0,
.timeout = 400, .post_write_delay = 0,
.retry = 3, .timeout = 400,
.retry = 3,
.min_az = -180.0, .min_az = -180.0,
.max_az = 450.0, /* vary according to rotator type */ .max_az = 450.0, /* vary according to rotator type */
.min_el = 0.0, .min_el = 0.0,
.max_el = 180.0, .max_el = 180.0,
.get_position = gs232a_rot_get_position, .get_position = gs232a_rot_get_position,
.set_position = gs232a_rot_set_position, .set_position = gs232a_rot_set_position,
.stop = gs232a_rot_stop, .stop = gs232a_rot_stop,
}; };
/* ************************************************************************* */ /* ************************************************************************* */
@ -310,35 +361,36 @@ const struct rot_caps gs232_rot_caps = {
* Generic GS232A rotator capabilities. * Generic GS232A rotator capabilities.
*/ */
const struct rot_caps gs232a_rot_caps = { const struct rot_caps gs232a_rot_caps =
.rot_model = ROT_MODEL_GS232A, {
.model_name = "GS-232A", .rot_model = ROT_MODEL_GS232A,
.mfg_name = "Yaesu", .model_name = "GS-232A",
.version = "0.5", .mfg_name = "Yaesu",
.copyright = "LGPL", .version = "0.5",
.status = RIG_STATUS_BETA, .copyright = "LGPL",
.rot_type = ROT_TYPE_OTHER, .status = RIG_STATUS_BETA,
.port_type = RIG_PORT_SERIAL, .rot_type = ROT_TYPE_OTHER,
.serial_rate_min = 150, .port_type = RIG_PORT_SERIAL,
.serial_rate_max = 9600, .serial_rate_min = 150,
.serial_data_bits = 8, .serial_rate_max = 9600,
.serial_stop_bits = 1, .serial_data_bits = 8,
.serial_parity = RIG_PARITY_NONE, .serial_stop_bits = 1,
.serial_handshake = RIG_HANDSHAKE_NONE, .serial_parity = RIG_PARITY_NONE,
.write_delay = 0, .serial_handshake = RIG_HANDSHAKE_NONE,
.post_write_delay = 0, .write_delay = 0,
.timeout = 400, .post_write_delay = 0,
.retry = 3, .timeout = 400,
.retry = 3,
.min_az = -180.0, .min_az = -180.0,
.max_az = 450.0, /* vary according to rotator type */ .max_az = 450.0, /* vary according to rotator type */
.min_el = 0.0, .min_el = 0.0,
.max_el = 180.0, /* requires G-5400B, G-5600B, G-5500, or G-500/G-550 */ .max_el = 180.0, /* requires G-5400B, G-5600B, G-5500, or G-500/G-550 */
.get_position = gs232a_rot_get_position, .get_position = gs232a_rot_get_position,
.set_position = gs232a_rot_set_position, .set_position = gs232a_rot_set_position,
.stop = gs232a_rot_stop, .stop = gs232a_rot_stop,
.move = gs232a_rot_move, .move = gs232a_rot_move,
}; };
@ -350,7 +402,7 @@ const struct rot_caps gs232a_rot_caps = {
DECLARE_INITROT_BACKEND(gs232a) DECLARE_INITROT_BACKEND(gs232a)
{ {
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __FUNCTION__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __FUNCTION__);
rot_register(&gs232a_rot_caps); rot_register(&gs232a_rot_caps);
rot_register(&gs232_generic_rot_caps); rot_register(&gs232_generic_rot_caps);
@ -360,7 +412,7 @@ DECLARE_INITROT_BACKEND(gs232a)
rot_register(&gs232_rot_caps); rot_register(&gs232_rot_caps);
rot_register(&amsat_lvb_rot_caps); rot_register(&amsat_lvb_rot_caps);
rot_register(&st2_rot_caps); rot_register(&st2_rot_caps);
return RIG_OK; return RIG_OK;
} }

Wyświetl plik

@ -62,243 +62,245 @@ static int
gs232b_transaction(ROT *rot, const char *cmdstr, gs232b_transaction(ROT *rot, const char *cmdstr,
char *data, size_t data_len, int no_reply) 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;
char replybuf[BUFSZ]; char replybuf[BUFSZ];
rs = &rot->state; rs = &rot->state;
transaction_write: transaction_write:
serial_flush(&rs->rotport); serial_flush(&rs->rotport);
if (cmdstr) if (cmdstr)
{
retval = write_block(&rs->rotport, cmdstr, strlen(cmdstr));
if (retval != RIG_OK)
{ {
goto transaction_quit; retval = write_block(&rs->rotport, cmdstr, strlen(cmdstr));
if (retval != RIG_OK)
{
goto transaction_quit;
}
if (!data)
{
write_block(&rs->rotport, EOM, strlen(EOM));
}
} }
if (no_reply) { return RIG_OK; } // nothing expected so return
/* Always read the reply to know whether the cmd went OK */
if (!data) if (!data)
{ {
write_block(&rs->rotport, EOM, strlen(EOM)); data = replybuf;
} }
}
if (no_reply) return RIG_OK; // nothing expected so return if (!data_len)
/* Always read the reply to know whether the cmd went OK */
if (!data)
{
data = replybuf;
}
if (!data_len)
{
data_len = BUFSZ;
}
memset(data, 0, data_len);
retval = read_string(&rs->rotport, data, data_len, REPLY_EOM, strlen(REPLY_EOM));
if (retval < 0)
{
if (retry_read++ < rot->state.rotport.retry)
{ {
goto transaction_write; data_len = BUFSZ;
} }
goto transaction_quit;
} memset(data, 0, data_len);
retval = read_string(&rs->rotport, data, data_len, REPLY_EOM,
strlen(REPLY_EOM));
if (retval < 0)
{
if (retry_read++ < rot->state.rotport.retry)
{
goto transaction_write;
}
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);
if (retry_read++ < rig->state.rotport.retry)
{ {
goto transaction_write; rig_debug(RIG_DEBUG_ERR,
} "%s: Command is not correctly terminated '%s'\n",
__FUNCTION__, data);
retval = -RIG_EPROTO; if (retry_read++ < rig->state.rotport.retry)
goto transaction_quit; {
} goto transaction_write;
}
retval = -RIG_EPROTO;
goto transaction_quit;
}
#endif #endif
// 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
if (data == replybuf && (strncmp(data, "?>", 2) != 0) && data[0] != 0x0d) if (data == replybuf && (strncmp(data, "?>", 2) != 0) && data[0] != 0x0d)
{ {
rig_debug(RIG_DEBUG_VERBOSE, rig_debug(RIG_DEBUG_VERBOSE,
"%s: Expected '?>' but got '%s' from cmd '%s'\n", "%s: Expected '?>' but got '%s' from cmd '%s'\n",
__FUNCTION__, data, cmdstr); __FUNCTION__, data, cmdstr);
return -RIG_EPROTO; return -RIG_EPROTO;
} }
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);
retval = -RIG_EPROTO; retval = -RIG_EPROTO;
goto transaction_quit; goto transaction_quit;
} }
retval = RIG_OK; retval = RIG_OK;
transaction_quit: transaction_quit:
return retval; return retval;
} }
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 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=%.02f el=%.02f\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)
{ {
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, buf, sizeof(buf), 0); retval = gs232b_transaction(rot, cmdstr, buf, sizeof(buf), 0);
if (retval != RIG_OK) if (retval != RIG_OK)
{ {
return retval; return retval;
} }
return RIG_OK; return RIG_OK;
} }
static int 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, int_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), 0); retval = gs232b_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;
} }
/* parse "AZ=aaa EL=eee" */ /* parse "AZ=aaa EL=eee" */
/* 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__, rig_debug(RIG_DEBUG_ERR, "%s: wrong reply '%s'\n", __FUNCTION__,
posbuf); 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) = (%.0f, %.0f)\n", rig_debug(RIG_DEBUG_TRACE, "%s: (az, el) = (%.0f, %.0f)\n",
__FUNCTION__, *az, *el); __FUNCTION__, *az, *el);
return RIG_OK; return RIG_OK;
} }
static int static int
gs232b_rot_stop(ROT *rot) gs232b_rot_stop(ROT *rot)
{ {
char buf[32]; 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, buf, sizeof(buf), 0); retval = gs232b_transaction(rot, "S" EOM, buf, sizeof(buf), 0);
if (retval != RIG_OK) if (retval != RIG_OK)
{ {
return retval; return retval;
} }
return RIG_OK; return RIG_OK;
} }
static int static int
gs232b_rot_move(ROT *rot, int direction, int speed) gs232b_rot_move(ROT *rot, int direction, int speed)
{ {
char cmdstr[24]; char cmdstr[24];
int retval; int retval;
unsigned x_speed; unsigned x_speed;
rig_debug(RIG_DEBUG_TRACE, "%s called %d %d\n", __FUNCTION__, rig_debug(RIG_DEBUG_TRACE, "%s called %d %d\n", __FUNCTION__,
direction, speed); direction, speed);
x_speed = (3 * speed) / 100 + 1; x_speed = (3 * speed) / 100 + 1;
/* 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, 1); retval = gs232b_transaction(rot, cmdstr, NULL, 0, 1);
if (retval != RIG_OK) if (retval != RIG_OK)
{ {
return retval; return retval;
} }
switch (direction) 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);
return -RIG_EINVAL; return -RIG_EINVAL;
} }
retval = gs232b_transaction(rot, cmdstr, NULL, 0, 1); retval = gs232b_transaction(rot, cmdstr, NULL, 0, 1);
if (retval != RIG_OK) if (retval != RIG_OK)
{ {
return retval; return retval;
} }
return RIG_OK; return RIG_OK;
} }
/* ************************************************************************* */ /* ************************************************************************* */
@ -308,34 +310,34 @@ gs232b_rot_move(ROT *rot, int direction, int speed)
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",
.version = "0.5", .version = "0.5",
.copyright = "LGPL", .copyright = "LGPL",
.status = RIG_STATUS_STABLE, .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,
.serial_rate_max = 9600, .serial_rate_max = 9600,
.serial_data_bits = 8, .serial_data_bits = 8,
.serial_stop_bits = 1, .serial_stop_bits = 1,
.serial_parity = RIG_PARITY_NONE, .serial_parity = RIG_PARITY_NONE,
.serial_handshake = RIG_HANDSHAKE_NONE, .serial_handshake = RIG_HANDSHAKE_NONE,
.write_delay = 0, .write_delay = 0,
.post_write_delay = 0, .post_write_delay = 0,
.timeout = 400, .timeout = 400,
.retry = 3, .retry = 3,
.min_az = -180.0, .min_az = -180.0,
.max_az = 450.0, /* vary according to rotator type */ .max_az = 450.0, /* vary according to rotator type */
.min_el = 0.0, .min_el = 0.0,
.max_el = 180.0, /* requires G-5400B, G-5600B, G-5500, or G-500/G-550 */ .max_el = 180.0, /* requires G-5400B, G-5600B, G-5500, or G-500/G-550 */
.get_position = gs232b_rot_get_position, .get_position = gs232b_rot_get_position,
.set_position = gs232b_rot_set_position, .set_position = gs232b_rot_set_position,
.stop = gs232b_rot_stop, .stop = gs232b_rot_stop,
.move = gs232b_rot_move, .move = gs232b_rot_move,
}; };
/* end of file */ /* end of file */