Merge pull request #7 from alexschultze/master

Rework of easycomm, fix get_info, implement get and set config features seperately
Hamlib-3.0
Nate Bargmann 2015-04-05 11:28:16 -05:00
commit feda2e4834
3 zmienionych plików z 169 dodań i 21 usunięć

Wyświetl plik

@ -2,6 +2,7 @@
* Hamlib Rotator backend - Easycom
* Copyright (c) 2001-2003 by Stephane Fillod
* Contributed by Francois Retief <fgretief@sun.ac.za>
* Copyright (c) 2014 by Alexander Schultze <alexschultze@gmail.com>
*
*
* This library is free software; you can redistribute it and/or
@ -241,24 +242,115 @@ easycomm_rot_move_velocity(ROT *rot, int direction, int speed)
return RIG_OK;
}
easycomm_rot_get_info(ROT *rot)
/*
* Get Info
* returns the model name string
*/
static const char * easycomm_rot_get_info(ROT *rot)
{
char cmdstr[16], ackbuf[32];
int retval;
const struct rot_caps *rc;
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __FUNCTION__);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
sprintf(cmdstr, "IN\n");
if (!rot)
return (const char *)-RIG_EINVAL;
retval = easycomm_transaction(rot, cmdstr, ackbuf, sizeof(ackbuf));
rc = rot->caps;
return rc->model_name;
}
/*
* Receive status / configuration / output
*
* For configuration registers, *val must contain string of register e.g. '0'-'f'
*/
static int easycomm_rot_get_conf(ROT *rot, token_t token, char *val) {
char cmdstr[16], ackbuf[32];
int retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rig_debug(RIG_DEBUG_TRACE, "%s: token = %d", __func__, token);
if (!rot)
return -RIG_EINVAL;
switch(token) {
case TOK_GET_STATUS:
sprintf(cmdstr, "GS\n;");
break;
case TOK_GET_ERRORS:
sprintf(cmdstr, "GE\n;");
break;
case TOK_GET_INPUT:
sprintf(cmdstr, "IP\n;");
break;
case TOK_GET_ANALOG_INPUT:
sprintf(cmdstr, "AN\n;");
break;
case TOK_GET_VERSION:
sprintf(cmdstr, "VE\n;");
break;
case TOK_GET_CONFIG:
sprintf(cmdstr, "CR %c\n;",*val);
break;
default:
return -RIG_EINVAL;
}
rig_debug(RIG_DEBUG_TRACE, "%s: cmdstr = %s, *val = %c\n", __func__, cmdstr, *val);
retval = easycomm_transaction(rot, cmdstr, ackbuf, sizeof(ackbuf));
if (retval != RIG_OK) {
rig_debug(RIG_DEBUG_TRACE, "%s got error: %d\n", __FUNCTION__, retval);
return retval;
}
/* Parse parse string to extract AZ,EL values */
rig_debug(RIG_DEBUG_TRACE, "%s got response: %s\n", __FUNCTION__, ackbuf);
return ackbuf;
/* Return given string at correct position*/
val = &ackbuf[2]; /* CCxxxxxx */
return RIG_OK;
}
/*
* Set configuration
*
* For configuration registers, *val must contain char of register e.g. '0'-'f' followed by setting
* e.g. x,yyyyy
*/
static int easycomm_rot_set_conf(ROT *rot, token_t token, const char *val) {
char cmdstr[16], ackbuf[32];
int retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rig_debug(RIG_DEBUG_TRACE, "%s: token = %d", __func__, token);
if (!rot)
return -RIG_EINVAL;
switch(token) {
case TOK_SET_CONFIG:
sprintf(cmdstr, "CW%s\n;",val);
break;
default:
return -RIG_EINVAL;
}
rig_debug(RIG_DEBUG_TRACE, "%s: cmdstr = %s, *val = %c\n", __func__, cmdstr, *val);
retval = easycomm_transaction(rot, cmdstr, ackbuf, sizeof(ackbuf));
if (retval != RIG_OK) {
rig_debug(RIG_DEBUG_TRACE, "%s got error: %d\n", __FUNCTION__, retval);
return retval;
}
return RIG_OK;
}
/* ************************************************************************* */
@ -274,7 +366,7 @@ const struct rot_caps easycomm1_rot_caps = {
.rot_model = ROT_MODEL_EASYCOMM1,
.model_name = "EasycommI",
.mfg_name = "Hamlib",
.version = "0.3",
.version = "0.4",
.copyright = "LGPL",
.status = RIG_STATUS_BETA,
.rot_type = ROT_TYPE_OTHER,
@ -299,6 +391,7 @@ const struct rot_caps easycomm1_rot_caps = {
.set_position = easycomm_rot_set_position,
.stop = easycomm_rot_stop,
.get_info = easycomm_rot_get_info,
};
/* EasycommII implement most of the functions. Again the radio tags
@ -308,7 +401,7 @@ const struct rot_caps easycomm2_rot_caps = {
.rot_model = ROT_MODEL_EASYCOMM2,
.model_name = "EasycommII",
.mfg_name = "Hamlib",
.version = "0.3",
.version = "0.4",
.copyright = "LGPL",
.status = RIG_STATUS_BETA,
.rot_type = ROT_TYPE_OTHER,
@ -342,8 +435,9 @@ const struct rot_caps easycomm2_rot_caps = {
.park = easycomm_rot_park,
.reset = easycomm_rot_reset,
.move = easycomm_rot_move,
.get_info = NULL,
.set_conf = easycomm_rot_set_conf,
.get_conf = easycomm_rot_get_conf,
.get_info = easycomm_rot_get_info,
};
/* EasycommIII provides changes Moving functions and info.
@ -352,7 +446,7 @@ const struct rot_caps easycomm3_rot_caps = {
.rot_model = ROT_MODEL_EASYCOMM3,
.model_name = "EasycommIII",
.mfg_name = "Hamlib",
.version = "0.3",
.version = "0.4",
.copyright = "LGPL",
.status = RIG_STATUS_ALPHA,
.rot_type = ROT_TYPE_OTHER,
@ -386,8 +480,9 @@ const struct rot_caps easycomm3_rot_caps = {
.park = easycomm_rot_park,
.reset = easycomm_rot_reset,
.move = easycomm_rot_move_velocity,
.get_info = NULL,
.set_conf = easycomm_rot_set_conf,
.get_conf = easycomm_rot_get_conf,
.get_info = easycomm_rot_get_info,
};
/* ************************************************************************* */

Wyświetl plik

@ -2,6 +2,7 @@
* Hamlib Rotator backend - Easycomm interface protocol
* Copyright (c) 2001-2003 by Stephane Fillod
* Contributed by Francois Retief <fgretief@sun.ac.za>
* Copyright (c) 2014 by Alexander Schultze <alexschultze@gmail.com>
*
*
* This library is free software; you can redistribute it and/or
@ -23,8 +24,25 @@
#ifndef _ROT_EASYCOMM_H
#define _ROT_EASYCOMM_H 1
#include "token.h"
extern const struct rot_caps easycomm1_rot_caps;
extern const struct rot_caps easycomm2_rot_caps;
extern const struct rot_caps easycomm3_rot_caps;
/*
* Tokens used by rotorez_rot_set_conf and get_conf and the 'C' command in rotctl
* and rotctld.
*/
#define TOK_GET_CONFIG TOKEN_BACKEND(1)
#define TOK_SET_CONFIG TOKEN_BACKEND(2)
#define TOK_GET_STATUS TOKEN_BACKEND(3)
#define TOK_GET_ERRORS TOKEN_BACKEND(4)
#define TOK_GET_VERSION TOKEN_BACKEND(5)
#define TOK_GET_INPUT TOKEN_BACKEND(6)
#define TOK_SET_OUTPUT TOKEN_BACKEND(7)
#define TOK_GET_ANALOG_INPUT TOKEN_BACKEND(8)
#endif /* _ROT_EASYCOMM_H */

Wyświetl plik

@ -1,6 +1,5 @@
The following are the specifications for the EasyComm interfaces which
are available with the WiSP programs. Both EasyComm 1 and EasyComm2 are
available in WiSP32. Only EasyComm1 is available with WiSP31. The EasyComm
are available with the WiSP programs. The EasyComm
interfaces are for use by those who wish to design their own radio and rotor
controllers.
@ -89,11 +88,47 @@ EASYCOMM III Standard
The EasyComm 3 standard is an extension of the version 2 with the additional features:
Command Meaning Perameters
------- ------- ----------
IN Get Status string
Command Meaning Perameters Hamlib Config Token
------- ------- ---------- -------------------
VL Velocity Left number [mdeg/s]
VR Velocity Right number [mdeg/s]
VU Velocity Up number [mdeg/s]
VD Velocity Down number [mdeg/s]
CR Read config register [0-x] 1
CW Write config register [0-x] 2
GS Get status register 3
GE Get error register 4
VE Request Version 5
IP Read an input number 6
OP Set output number 7
AN Read analogue input number 8
>Several status and error bits can combined. Proposed mapping:
Status Meaning
------- -------
1 Idle
2 Moving
4 Pointing
8 Error
Error Meaning
------- -------
1 Sensor Error
2 Jam
4 Homing Error
>Proposed mapping of configuration registers:
Register Meaning Value
------- ------- ----------
0 MaxSpeed number
a Overshoot 0/1/-
b Jamming 0/1/-
c Endpoints 0/1/-
d Unstick 0/1/-
73, Alexander Schultze