kopia lustrzana https://github.com/Hamlib/Hamlib
new netrigctl/netrotctl protocol with return value
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2428 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.2.8
rodzic
638628e18d
commit
f541b221fe
1115
dummy/netrigctl.c
1115
dummy/netrigctl.c
Plik diff jest za duży
Load Diff
|
@ -2,7 +2,7 @@
|
||||||
* Hamlib Netrotctl backend - main file
|
* Hamlib Netrotctl backend - main file
|
||||||
* Copyright (c) 2001-2008 by Stephane Fillod
|
* Copyright (c) 2001-2008 by Stephane Fillod
|
||||||
*
|
*
|
||||||
* $Id: netrotctl.c,v 1.1 2008-09-21 19:34:15 fillods Exp $
|
* $Id: netrotctl.c,v 1.2 2008-10-27 22:23:36 fillods Exp $
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or modify
|
* This library is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Library General Public License as
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
@ -38,7 +38,27 @@
|
||||||
|
|
||||||
#define CMD_MAX 32
|
#define CMD_MAX 32
|
||||||
#define BUF_MAX 64
|
#define BUF_MAX 64
|
||||||
#define ROTCTL_ERROR "ERROR "
|
|
||||||
|
/*
|
||||||
|
* Helper function with protocol return code parsing
|
||||||
|
*/
|
||||||
|
static int netrotctl_transaction(ROT *rot, char *cmd, int len, char *buf)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = write_block(&rot->state.rotport, cmd, len);
|
||||||
|
if (ret != RIG_OK)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"));
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
if (!memcmp(buf, NETROTCTL_RET, strlen(NETROTCTL_RET)))
|
||||||
|
return atoi(buf+strlen(NETROTCTL_RET));
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static int netrotctl_open(ROT *rot)
|
static int netrotctl_open(ROT *rot)
|
||||||
{
|
{
|
||||||
|
@ -54,52 +74,43 @@ static int netrotctl_open(ROT *rot)
|
||||||
|
|
||||||
len = sprintf(cmd, "\\dump_state\n");
|
len = sprintf(cmd, "\\dump_state\n");
|
||||||
|
|
||||||
ret = write(rot->state.rotport.fd, cmd, len);
|
ret = netrotctl_transaction(rot, cmd, len, buf);
|
||||||
if (ret != len) {
|
if (ret <= 0)
|
||||||
rig_debug(RIG_DEBUG_ERR,"%s: write failed: %s\n", __FUNCTION__,
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
||||||
strerror(errno));
|
|
||||||
return -RIG_EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"));
|
|
||||||
if (ret <= 0) {
|
|
||||||
return -RIG_EIO;
|
|
||||||
}
|
|
||||||
if (!memcmp(buf, ROTCTL_ERROR, strlen(ROTCTL_ERROR)))
|
|
||||||
return atoi(buf+strlen(ROTCTL_ERROR));
|
|
||||||
prot_ver = atoi(buf);
|
prot_ver = atoi(buf);
|
||||||
#define ROTCTLD_PROT_VER 0
|
#define ROTCTLD_PROT_VER 0
|
||||||
if (prot_ver < ROTCTLD_PROT_VER)
|
if (prot_ver < ROTCTLD_PROT_VER)
|
||||||
return -RIG_EPROTO;
|
return -RIG_EPROTO;
|
||||||
|
|
||||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"));
|
ret = netrotctl_transaction(rot, cmd, len, buf);
|
||||||
if (ret <= 0) {
|
if (ret <= 0)
|
||||||
return -RIG_EIO;
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
||||||
}
|
|
||||||
model = atoi(buf);
|
model = atoi(buf);
|
||||||
|
|
||||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"));
|
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"));
|
||||||
if (ret <= 0) {
|
if (ret <= 0)
|
||||||
return -RIG_EIO;
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
||||||
}
|
|
||||||
rs->min_az = atof(buf);
|
rs->min_az = atof(buf);
|
||||||
|
|
||||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"));
|
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"));
|
||||||
if (ret <= 0) {
|
if (ret <= 0)
|
||||||
return -RIG_EIO;
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
||||||
}
|
|
||||||
rs->max_az = atof(buf);
|
rs->max_az = atof(buf);
|
||||||
|
|
||||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"));
|
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"));
|
||||||
if (ret <= 0) {
|
if (ret <= 0)
|
||||||
return -RIG_EIO;
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
||||||
}
|
|
||||||
rs->min_el = atof(buf);
|
rs->min_el = atof(buf);
|
||||||
|
|
||||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"));
|
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"));
|
||||||
if (ret <= 0) {
|
if (ret <= 0)
|
||||||
return -RIG_EIO;
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
||||||
}
|
|
||||||
rs->max_el = atof(buf);
|
rs->max_el = atof(buf);
|
||||||
|
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
|
@ -116,20 +127,18 @@ static int netrotctl_set_position(ROT *rot, azimuth_t az, elevation_t el)
|
||||||
{
|
{
|
||||||
int ret, len;
|
int ret, len;
|
||||||
char cmd[CMD_MAX];
|
char cmd[CMD_MAX];
|
||||||
|
char buf[BUF_MAX];
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE,"%s called: %f %f\n", __FUNCTION__,
|
rig_debug(RIG_DEBUG_VERBOSE,"%s called: %f %f\n", __FUNCTION__,
|
||||||
az, el);
|
az, el);
|
||||||
|
|
||||||
len = sprintf(cmd, "P %f %f\n", az, el);
|
len = sprintf(cmd, "P %f %f\n", az, el);
|
||||||
|
|
||||||
ret = write(rot->state.rotport.fd, cmd, len);
|
ret = netrotctl_transaction(rot, cmd, len, buf);
|
||||||
if (ret != len) {
|
if (ret > 0)
|
||||||
rig_debug(RIG_DEBUG_ERR,"%s: write failed: %s\n", __FUNCTION__,
|
return -RIG_EPROTO;
|
||||||
strerror(errno));
|
else
|
||||||
return -RIG_EIO;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
return RIG_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int netrotctl_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
|
static int netrotctl_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
|
||||||
|
@ -142,33 +151,17 @@ static int netrotctl_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
|
||||||
|
|
||||||
len = sprintf(cmd, "p\n");
|
len = sprintf(cmd, "p\n");
|
||||||
|
|
||||||
ret = write(rot->state.rotport.fd, cmd, len);
|
ret = netrotctl_transaction(rot, cmd, len, buf);
|
||||||
if (ret != len) {
|
if (ret <= 0)
|
||||||
rig_debug(RIG_DEBUG_ERR,"%s: write failed: %s\n", __FUNCTION__,
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
||||||
strerror(errno));
|
|
||||||
return -RIG_EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"));
|
|
||||||
if (ret <= 0) {
|
|
||||||
return -RIG_EIO;
|
|
||||||
}
|
|
||||||
if (!memcmp(buf, ROTCTL_ERROR, strlen(ROTCTL_ERROR)))
|
|
||||||
return atoi(buf+strlen(ROTCTL_ERROR));
|
|
||||||
|
|
||||||
*az = atof(buf);
|
*az = atof(buf);
|
||||||
|
|
||||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"));
|
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"));
|
||||||
if (ret <= 0) {
|
if (ret <= 0)
|
||||||
return -RIG_EIO;
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
||||||
}
|
|
||||||
*el = atof(buf);
|
|
||||||
|
|
||||||
/* read dummy END */
|
*el = atof(buf);
|
||||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"));
|
|
||||||
if (ret <= 0) {
|
|
||||||
return -RIG_EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
@ -178,19 +171,17 @@ static int netrotctl_stop(ROT *rot)
|
||||||
{
|
{
|
||||||
int ret, len;
|
int ret, len;
|
||||||
char cmd[CMD_MAX];
|
char cmd[CMD_MAX];
|
||||||
|
char buf[BUF_MAX];
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __FUNCTION__);
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __FUNCTION__);
|
||||||
|
|
||||||
len = sprintf(cmd, "S\n");
|
len = sprintf(cmd, "S\n");
|
||||||
|
|
||||||
ret = write(rot->state.rotport.fd, cmd, len);
|
ret = netrotctl_transaction(rot, cmd, len, buf);
|
||||||
if (ret != len) {
|
if (ret > 0)
|
||||||
rig_debug(RIG_DEBUG_ERR,"%s: write failed: %s\n", __FUNCTION__,
|
return -RIG_EPROTO;
|
||||||
strerror(errno));
|
else
|
||||||
return -RIG_EIO;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
return RIG_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -198,57 +189,51 @@ static int netrotctl_park(ROT *rot)
|
||||||
{
|
{
|
||||||
int ret, len;
|
int ret, len;
|
||||||
char cmd[CMD_MAX];
|
char cmd[CMD_MAX];
|
||||||
|
char buf[BUF_MAX];
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __FUNCTION__);
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __FUNCTION__);
|
||||||
|
|
||||||
len = sprintf(cmd, "K\n");
|
len = sprintf(cmd, "K\n");
|
||||||
|
|
||||||
ret = write(rot->state.rotport.fd, cmd, len);
|
ret = netrotctl_transaction(rot, cmd, len, buf);
|
||||||
if (ret != len) {
|
if (ret > 0)
|
||||||
rig_debug(RIG_DEBUG_ERR,"%s: write failed: %s\n", __FUNCTION__,
|
return -RIG_EPROTO;
|
||||||
strerror(errno));
|
else
|
||||||
return -RIG_EIO;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
return RIG_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int netrotctl_reset(ROT *rot, rot_reset_t reset)
|
static int netrotctl_reset(ROT *rot, rot_reset_t reset)
|
||||||
{
|
{
|
||||||
int ret, len;
|
int ret, len;
|
||||||
char cmd[CMD_MAX];
|
char cmd[CMD_MAX];
|
||||||
|
char buf[BUF_MAX];
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __FUNCTION__);
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __FUNCTION__);
|
||||||
|
|
||||||
len = sprintf(cmd, "R %d\n", reset);
|
len = sprintf(cmd, "R %d\n", reset);
|
||||||
|
|
||||||
ret = write(rot->state.rotport.fd, cmd, len);
|
ret = netrotctl_transaction(rot, cmd, len, buf);
|
||||||
if (ret != len) {
|
if (ret > 0)
|
||||||
rig_debug(RIG_DEBUG_ERR,"%s: write failed: %s\n", __FUNCTION__,
|
return -RIG_EPROTO;
|
||||||
strerror(errno));
|
else
|
||||||
return -RIG_EIO;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
return RIG_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int netrotctl_move(ROT *rot, int direction, int speed)
|
static int netrotctl_move(ROT *rot, int direction, int speed)
|
||||||
{
|
{
|
||||||
int ret, len;
|
int ret, len;
|
||||||
char cmd[CMD_MAX];
|
char cmd[CMD_MAX];
|
||||||
|
char buf[BUF_MAX];
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __FUNCTION__);
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __FUNCTION__);
|
||||||
|
|
||||||
len = sprintf(cmd, "M %d %d\n", direction, speed);
|
len = sprintf(cmd, "M %d %d\n", direction, speed);
|
||||||
|
|
||||||
ret = write(rot->state.rotport.fd, cmd, len);
|
ret = netrotctl_transaction(rot, cmd, len, buf);
|
||||||
if (ret != len) {
|
if (ret > 0)
|
||||||
rig_debug(RIG_DEBUG_ERR,"%s: write failed: %s\n", __FUNCTION__,
|
return -RIG_EPROTO;
|
||||||
strerror(errno));
|
else
|
||||||
return -RIG_EIO;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
return RIG_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *netrotctl_get_info(ROT *rot)
|
static const char *netrotctl_get_info(ROT *rot)
|
||||||
|
@ -261,27 +246,12 @@ static const char *netrotctl_get_info(ROT *rot)
|
||||||
|
|
||||||
len = sprintf(cmd, "_\n");
|
len = sprintf(cmd, "_\n");
|
||||||
|
|
||||||
ret = write(rot->state.rotport.fd, cmd, len);
|
ret = netrotctl_transaction(rot, cmd, len, buf);
|
||||||
if (ret != len) {
|
if (ret < 0)
|
||||||
rig_debug(RIG_DEBUG_ERR,"%s: write failed: %s\n", __FUNCTION__,
|
|
||||||
strerror(errno));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"));
|
|
||||||
if (ret < 0) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (!memcmp(buf, ROTCTL_ERROR, strlen(ROTCTL_ERROR)))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
buf [ret] = '\0';
|
buf [ret] = '\0';
|
||||||
|
|
||||||
/* read dummy END */
|
|
||||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"));
|
|
||||||
if (ret <= 0) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,9 +265,9 @@ const struct rot_caps netrotctl_caps = {
|
||||||
.rot_model = ROT_MODEL_NETROTCTL,
|
.rot_model = ROT_MODEL_NETROTCTL,
|
||||||
.model_name = "NET rotctl",
|
.model_name = "NET rotctl",
|
||||||
.mfg_name = "Hamlib",
|
.mfg_name = "Hamlib",
|
||||||
.version = "0.1",
|
.version = "0.2",
|
||||||
.copyright = "LGPL",
|
.copyright = "LGPL",
|
||||||
.status = RIG_STATUS_ALPHA,
|
.status = RIG_STATUS_BETA,
|
||||||
.rot_type = ROT_TYPE_OTHER,
|
.rot_type = ROT_TYPE_OTHER,
|
||||||
.port_type = RIG_PORT_NETWORK,
|
.port_type = RIG_PORT_NETWORK,
|
||||||
.timeout = 2000,
|
.timeout = 2000,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Hamlib Interface - API header
|
* Hamlib Interface - API header
|
||||||
* Copyright (c) 2000-2008 by Stephane Fillod and Frank Singleton
|
* Copyright (c) 2000-2008 by Stephane Fillod and Frank Singleton
|
||||||
*
|
*
|
||||||
* $Id: rig.h,v 1.128 2008-10-25 11:36:02 y32kn Exp $
|
* $Id: rig.h,v 1.129 2008-10-27 22:23:36 fillods Exp $
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or modify
|
* This library is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Library General Public License as
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
@ -100,6 +100,9 @@ enum rig_errcode_e {
|
||||||
RIG_EDOM /*!< Argument out of domain of func */
|
RIG_EDOM /*!< Argument out of domain of func */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** \brief Token in the netrigctl protocol for returning error code */
|
||||||
|
#define NETRIGCTL_RET "RPRT "
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*\brief Hamlib debug levels
|
*\brief Hamlib debug levels
|
||||||
*
|
*
|
||||||
|
@ -240,9 +243,7 @@ enum rig_status_e {
|
||||||
* !! Use of RIG_STATUS_NEW is deprecated. Do not use it anymore */
|
* !! Use of RIG_STATUS_NEW is deprecated. Do not use it anymore */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/** \brief Map all deprecated RIG_STATUS_NEW references to RIG_STATUS_UNTESTED for backward compatibility */
|
||||||
* Map all RIG_STATUS_NEW references to RIG_STATUS_UNTESTED for backward compatibility
|
|
||||||
*/
|
|
||||||
#define RIG_STATUS_NEW RIG_STATUS_UNTESTED
|
#define RIG_STATUS_NEW RIG_STATUS_UNTESTED
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Hamlib Interface - Rotator API header
|
* Hamlib Interface - Rotator API header
|
||||||
* Copyright (c) 2000-2005 by Stephane Fillod
|
* Copyright (c) 2000-2005 by Stephane Fillod
|
||||||
*
|
*
|
||||||
* $Id: rotator.h,v 1.15 2008-05-01 12:19:57 fillods Exp $
|
* $Id: rotator.h,v 1.16 2008-10-27 22:23:36 fillods Exp $
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or modify
|
* This library is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Library General Public License as
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
@ -72,6 +72,9 @@ typedef struct rot ROT;
|
||||||
typedef float elevation_t;
|
typedef float elevation_t;
|
||||||
typedef float azimuth_t;
|
typedef float azimuth_t;
|
||||||
|
|
||||||
|
/** \brief Token in the netrotctl protocol for returning error code */
|
||||||
|
#define NETROTCTL_RET "RPRT "
|
||||||
|
|
||||||
/*! \def ROT_RESET_ALL
|
/*! \def ROT_RESET_ALL
|
||||||
* \brief A macro that returns the flag for the \b reset operation.
|
* \brief A macro that returns the flag for the \b reset operation.
|
||||||
* \sa rot_reset(), rot_reset_t
|
* \sa rot_reset(), rot_reset_t
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* It takes commands in interactive mode as well as
|
* It takes commands in interactive mode as well as
|
||||||
* from command line options.
|
* from command line options.
|
||||||
*
|
*
|
||||||
* $Id: rigctl.c,v 1.67 2008-05-23 14:26:09 fillods Exp $
|
* $Id: rigctl.c,v 1.68 2008-10-27 22:23:36 fillods Exp $
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
|
@ -84,6 +84,7 @@ static struct option long_options[] =
|
||||||
|
|
||||||
int interactive = 1; /* if no cmd on command line, switch to interactive */
|
int interactive = 1; /* if no cmd on command line, switch to interactive */
|
||||||
int prompt = 1; /* Print prompt in rigctl */
|
int prompt = 1; /* Print prompt in rigctl */
|
||||||
|
int opt_end= 0; /* only used by rigctld */
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
int main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* It takes commands in interactive mode as well as
|
* It takes commands in interactive mode as well as
|
||||||
* from command line options.
|
* from command line options.
|
||||||
*
|
*
|
||||||
* $Id: rigctl_parse.c,v 1.8 2008-09-21 19:24:47 fillods Exp $
|
* $Id: rigctl_parse.c,v 1.9 2008-10-27 22:23:36 fillods Exp $
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
|
@ -274,6 +274,7 @@ static int scanfc(FILE *fin, const char *format, void *p)
|
||||||
|
|
||||||
extern int interactive;
|
extern int interactive;
|
||||||
extern int prompt;
|
extern int prompt;
|
||||||
|
extern int opt_end;
|
||||||
|
|
||||||
|
|
||||||
int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc)
|
int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc)
|
||||||
|
@ -467,14 +468,18 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
if ((cmd_entry->flags & ARG_OUT) && interactive && !prompt)
|
if (interactive && !prompt)
|
||||||
fprintf(fout, "ERROR %d\n", retcode); /* only for rigctld */
|
fprintf(fout, NETRIGCTL_RET "%d\n", retcode); /* only for rigctld */
|
||||||
else
|
else
|
||||||
fprintf(fout, "%s: error = %s\n", cmd_entry->name, rigerror(retcode));
|
fprintf(fout, "%s: error = %s\n", cmd_entry->name, rigerror(retcode));
|
||||||
} else {
|
} else {
|
||||||
if ((cmd_entry->flags & ARG_OUT) && interactive && !prompt) /* only for rigctld */
|
if (interactive && !prompt) { /* only for rigctld */
|
||||||
|
if (!(cmd_entry->flags & ARG_OUT) && !opt_end) /* netrigctl RIG_OK */
|
||||||
|
fprintf(fout, NETRIGCTL_RET "0\n");
|
||||||
|
else if ((cmd_entry->flags & ARG_OUT) && opt_end) /* Nate's protocol */
|
||||||
fprintf(fout, "END\n");
|
fprintf(fout, "END\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fflush(fout);
|
fflush(fout);
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* This program test/control a radio using Hamlib.
|
* This program test/control a radio using Hamlib.
|
||||||
* It takes commands from network connection.
|
* It takes commands from network connection.
|
||||||
*
|
*
|
||||||
* $Id: rigctld.c,v 1.8 2008-09-21 20:32:07 fillods Exp $
|
* $Id: rigctld.c,v 1.9 2008-10-27 22:23:36 fillods Exp $
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
|
@ -68,7 +68,7 @@
|
||||||
* NB: do NOT use -W since it's reserved by POSIX.
|
* NB: do NOT use -W since it's reserved by POSIX.
|
||||||
* TODO: add an option to read from a file
|
* TODO: add an option to read from a file
|
||||||
*/
|
*/
|
||||||
#define SHORT_OPTIONS "m:r:p:d:P:D:s:c:lC:t:T:LuovhV"
|
#define SHORT_OPTIONS "m:r:p:d:P:D:s:c:lC:t:T:LeuovhV"
|
||||||
static struct option long_options[] =
|
static struct option long_options[] =
|
||||||
{
|
{
|
||||||
{"model", 1, 0, 'm'},
|
{"model", 1, 0, 'm'},
|
||||||
|
@ -86,6 +86,7 @@ static struct option long_options[] =
|
||||||
{"show-conf",0, 0, 'L'},
|
{"show-conf",0, 0, 'L'},
|
||||||
{"dump-caps", 0, 0, 'u'},
|
{"dump-caps", 0, 0, 'u'},
|
||||||
{"vfo", 0, 0, 'o'},
|
{"vfo", 0, 0, 'o'},
|
||||||
|
{"end-marker", 0, 0, 'e'},
|
||||||
{"verbose", 0, 0, 'v'},
|
{"verbose", 0, 0, 'v'},
|
||||||
{"help", 0, 0, 'h'},
|
{"help", 0, 0, 'h'},
|
||||||
{"version", 0, 0, 'V'},
|
{"version", 0, 0, 'V'},
|
||||||
|
@ -104,6 +105,7 @@ void usage(void);
|
||||||
|
|
||||||
int interactive = 1; /* no cmd because of daemon */
|
int interactive = 1; /* no cmd because of daemon */
|
||||||
int prompt= 0 ; /* Daemon mode for rigparse return string */
|
int prompt= 0 ; /* Daemon mode for rigparse return string */
|
||||||
|
int opt_end= 0 ; /* END marker for rigctld */
|
||||||
|
|
||||||
int portno = 4532;
|
int portno = 4532;
|
||||||
uint32_t src_addr = INADDR_ANY;
|
uint32_t src_addr = INADDR_ANY;
|
||||||
|
@ -271,6 +273,9 @@ int main (int argc, char *argv[])
|
||||||
case 'u':
|
case 'u':
|
||||||
dump_caps_opt++;
|
dump_caps_opt++;
|
||||||
break;
|
break;
|
||||||
|
case 'e':
|
||||||
|
opt_end = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage(); /* unknown option? */
|
usage(); /* unknown option? */
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -351,8 +356,10 @@ int main (int argc, char *argv[])
|
||||||
* Prepare listening socket
|
* Prepare listening socket
|
||||||
*/
|
*/
|
||||||
sock_listen = socket(AF_INET, SOCK_STREAM, 0);
|
sock_listen = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if (sock_listen < 0)
|
if (sock_listen < 0) {
|
||||||
perror("ERROR opening socket");
|
perror("ERROR opening socket");
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
memset((char *) &serv_addr, 0, sizeof(serv_addr));
|
memset((char *) &serv_addr, 0, sizeof(serv_addr));
|
||||||
|
|
||||||
serv_addr.sin_family = AF_INET;
|
serv_addr.sin_family = AF_INET;
|
||||||
|
@ -502,6 +509,7 @@ void usage(void)
|
||||||
" -l, --list list all model numbers and exit\n"
|
" -l, --list list all model numbers and exit\n"
|
||||||
" -u, --dump-caps dump capabilities and exit\n"
|
" -u, --dump-caps dump capabilities and exit\n"
|
||||||
" -o, --vfo do not default to VFO_CURR, require extra vfo arg\n"
|
" -o, --vfo do not default to VFO_CURR, require extra vfo arg\n"
|
||||||
|
" -e, --end-marker use END marker in rigctld protocol\n"
|
||||||
" -v, --verbose set verbose mode, cumulative\n"
|
" -v, --verbose set verbose mode, cumulative\n"
|
||||||
" -h, --help display this help and exit\n"
|
" -h, --help display this help and exit\n"
|
||||||
" -V, --version output version information and exit\n\n",
|
" -V, --version output version information and exit\n\n",
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* It takes commands in interactive mode as well as
|
* It takes commands in interactive mode as well as
|
||||||
* from command line options.
|
* from command line options.
|
||||||
*
|
*
|
||||||
* $Id: rotctl.c,v 1.11 2008-09-12 22:55:09 fillods Exp $
|
* $Id: rotctl.c,v 1.12 2008-10-27 22:23:36 fillods Exp $
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
|
@ -71,6 +71,7 @@ static struct option long_options[] =
|
||||||
|
|
||||||
int interactive = 1; /* if no cmd on command line, switch to interactive */
|
int interactive = 1; /* if no cmd on command line, switch to interactive */
|
||||||
int prompt = 1; /* Print prompt in rotctl */
|
int prompt = 1; /* Print prompt in rotctl */
|
||||||
|
int opt_end= 0 ; /* only used by rotctld */
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
int main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* It takes commands in interactive mode as well as
|
* It takes commands in interactive mode as well as
|
||||||
* from command line options.
|
* from command line options.
|
||||||
*
|
*
|
||||||
* $Id: rotctl_parse.c,v 1.2 2008-09-21 19:27:54 fillods Exp $
|
* $Id: rotctl_parse.c,v 1.3 2008-10-27 22:23:36 fillods Exp $
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
|
@ -159,6 +159,7 @@ static int scanfc(FILE *fin, const char *format, void *p)
|
||||||
|
|
||||||
extern int interactive;
|
extern int interactive;
|
||||||
extern int prompt;
|
extern int prompt;
|
||||||
|
extern int opt_end;
|
||||||
|
|
||||||
int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, char *argv[], int argc)
|
int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, char *argv[], int argc)
|
||||||
{
|
{
|
||||||
|
@ -332,14 +333,18 @@ int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, char *argv[], int argc)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (retcode != RIG_OK) {
|
if (retcode != RIG_OK) {
|
||||||
if ((cmd_entry->flags & ARG_OUT) && interactive && !prompt)
|
if (interactive && !prompt)
|
||||||
fprintf(fout, "ERROR %d\n", retcode); /* only for rotctld */
|
fprintf(fout, NETROTCTL_RET "%d\n", retcode); /* only for rotctld */
|
||||||
else
|
else
|
||||||
fprintf(fout, "%s: error = %s\n", cmd_entry->name, rigerror(retcode));
|
fprintf(fout, "%s: error = %s\n", cmd_entry->name, rigerror(retcode));
|
||||||
} else {
|
} else {
|
||||||
if ((cmd_entry->flags & ARG_OUT) && interactive && !prompt) /* only for rotctld */
|
if (interactive && !prompt) { /* only for rotctld */
|
||||||
|
if (!(cmd_entry->flags & ARG_OUT) && !opt_end) /* netrotctl RIG_OK */
|
||||||
|
fprintf(fout, NETROTCTL_RET "0\n");
|
||||||
|
else if ((cmd_entry->flags & ARG_OUT) && opt_end) /* Nate's protocol */
|
||||||
fprintf(fout, "END\n");
|
fprintf(fout, "END\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fflush(fout);
|
fflush(fout);
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* This program test/control a rotator using Hamlib.
|
* This program test/control a rotator using Hamlib.
|
||||||
* It takes commands from network connection.
|
* It takes commands from network connection.
|
||||||
*
|
*
|
||||||
* $Id: rotctld.c,v 1.4 2008-09-21 20:32:08 fillods Exp $
|
* $Id: rotctld.c,v 1.5 2008-10-27 22:23:36 fillods Exp $
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
|
@ -76,7 +76,7 @@ void usage();
|
||||||
* NB: do NOT use -W since it's reserved by POSIX.
|
* NB: do NOT use -W since it's reserved by POSIX.
|
||||||
* TODO: add an option to read from a file
|
* TODO: add an option to read from a file
|
||||||
*/
|
*/
|
||||||
#define SHORT_OPTIONS "m:r:s:C:t:T:LvhVl"
|
#define SHORT_OPTIONS "m:r:s:C:t:T:LevhVl"
|
||||||
static struct option long_options[] =
|
static struct option long_options[] =
|
||||||
{
|
{
|
||||||
{"model", 1, 0, 'm'},
|
{"model", 1, 0, 'm'},
|
||||||
|
@ -87,6 +87,7 @@ static struct option long_options[] =
|
||||||
{"list", 0, 0, 'l'},
|
{"list", 0, 0, 'l'},
|
||||||
{"set-conf", 1, 0, 'C'},
|
{"set-conf", 1, 0, 'C'},
|
||||||
{"show-conf",0, 0, 'L'},
|
{"show-conf",0, 0, 'L'},
|
||||||
|
{"end-marker", 0, 0, 'e'},
|
||||||
{"verbose", 0, 0, 'v'},
|
{"verbose", 0, 0, 'v'},
|
||||||
{"help", 0, 0, 'h'},
|
{"help", 0, 0, 'h'},
|
||||||
{"version", 0, 0, 'V'},
|
{"version", 0, 0, 'V'},
|
||||||
|
@ -95,6 +96,7 @@ static struct option long_options[] =
|
||||||
|
|
||||||
int interactive = 1; /* no cmd because of daemon */
|
int interactive = 1; /* no cmd because of daemon */
|
||||||
int prompt= 0 ; /* Daemon mode for rigparse return string */
|
int prompt= 0 ; /* Daemon mode for rigparse return string */
|
||||||
|
int opt_end= 0 ; /* END marker for rotctld */
|
||||||
|
|
||||||
int portno = 4533;
|
int portno = 4533;
|
||||||
uint32_t src_addr = INADDR_ANY;
|
uint32_t src_addr = INADDR_ANY;
|
||||||
|
@ -193,6 +195,9 @@ int main (int argc, char *argv[])
|
||||||
case 'l':
|
case 'l':
|
||||||
list_models();
|
list_models();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
case 'e':
|
||||||
|
opt_end = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage(); /* unknown option? */
|
usage(); /* unknown option? */
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -394,6 +399,7 @@ void usage()
|
||||||
" -C, --set-conf=PARM=VAL set config parameters\n"
|
" -C, --set-conf=PARM=VAL set config parameters\n"
|
||||||
" -L, --show-conf list all config parameters\n"
|
" -L, --show-conf list all config parameters\n"
|
||||||
" -l, --list list all model numbers and exit\n"
|
" -l, --list list all model numbers and exit\n"
|
||||||
|
" -e, --end-marker use END marker in rotctld protocol\n"
|
||||||
" -v, --verbose set verbose mode, cumulative\n"
|
" -v, --verbose set verbose mode, cumulative\n"
|
||||||
" -h, --help display this help and exit\n"
|
" -h, --help display this help and exit\n"
|
||||||
" -V, --version output version information and exit\n\n",
|
" -V, --version output version information and exit\n\n",
|
||||||
|
|
Ładowanie…
Reference in New Issue