Browse Source

API allow display/change failover-only setting

nfactor-troky
Kano 12 years ago
parent
commit
95dff7363e
  1. 18
      API-README
  2. 43
      api.c
  3. 2
      cgminer.c
  4. 1
      miner.h

18
API-README

@ -122,7 +122,9 @@ The list of requests - a (*) means it requires privileged access - and replies a @@ -122,7 +122,9 @@ The list of requests - a (*) means it requires privileged access - and replies a
ADL in use=X, <- Y or N if any GPU has ADL
Strategy=Name, <- the current pool strategy
Log Interval=N, <- log interval (--log N)
Device Code=GPU ICA | <- spaced list of compiled devices
Device Code=GPU ICA , <- spaced list of compiled devices
OS=Linux/Apple/..., <- operating System
Failover-Only=true/false | <- failover-only setting
summary SUMMARY The status summary of the miner
e.g. Elapsed=NNN,Found Blocks=N,Getworks=N,...|
@ -275,6 +277,10 @@ The list of requests - a (*) means it requires privileged access - and replies a @@ -275,6 +277,10 @@ The list of requests - a (*) means it requires privileged access - and replies a
check|cmd COMMAND Exists=Y/N, <- 'cmd' exists in this version
Access=Y/N| <- you have access to use 'cmd'
failover-only|true/false (*)
none There is no reply section just the STATUS section
stating what failover-only was set to
When you enable, disable or restart a GPU or PGA, you will also get Thread messages
in the cgminer status window
@ -327,6 +333,16 @@ miner.php - an example web page to access the API @@ -327,6 +333,16 @@ miner.php - an example web page to access the API
Feature Changelog for external applications using the API:
API V1.16
Added API commands:
'failover-only'
Modified API commands:
'config' - include failover-only state
----------
API V1.15 (cgminer v2.6.1)
Added API commands:

43
api.c

@ -166,7 +166,7 @@ static const char SEPARATOR = '|'; @@ -166,7 +166,7 @@ static const char SEPARATOR = '|';
#define SEPSTR "|"
static const char GPUSEP = ',';
static const char *APIVERSION = "1.15";
static const char *APIVERSION = "1.16";
static const char *DEAD = "Dead";
static const char *SICK = "Sick";
static const char *NOSTART = "NoStart";
@ -184,6 +184,9 @@ static const char *YES = "Y"; @@ -184,6 +184,9 @@ static const char *YES = "Y";
static const char *NO = "N";
static const char *NULLSTR = "(null)";
static const char *TRUESTR = "true";
static const char *FALSESTR = "false";
static const char *DEVICECODE = ""
#ifdef HAVE_OPENCL
"GPU "
@ -376,6 +379,9 @@ static const char *JSON_PARAMETER = "parameter"; @@ -376,6 +379,9 @@ static const char *JSON_PARAMETER = "parameter";
#define MSG_CHECK 72
#define MSG_POOLPRIO 73
#define MSG_DUPPID 74
#define MSG_MISBOOL 75
#define MSG_INVBOOL 76
#define MSG_FOO 77
enum code_severity {
SEVERITY_ERR,
@ -403,6 +409,7 @@ enum code_parameters { @@ -403,6 +409,7 @@ enum code_parameters {
PARAM_POOL,
PARAM_STR,
PARAM_BOTH,
PARAM_BOOL,
PARAM_NONE
};
@ -524,6 +531,9 @@ struct CODES { @@ -524,6 +531,9 @@ struct CODES {
{ SEVERITY_SUCC, MSG_MINESTATS,PARAM_NONE, "CGMiner stats" },
{ SEVERITY_ERR, MSG_MISCHK, PARAM_NONE, "Missing check cmd" },
{ SEVERITY_SUCC, MSG_CHECK, PARAM_NONE, "Check command" },
{ SEVERITY_ERR, MSG_MISBOOL, PARAM_NONE, "Missing parameter: true/false" },
{ SEVERITY_ERR, MSG_INVBOOL, PARAM_NONE, "Invalid parameter should be true or false" },
{ SEVERITY_SUCC, MSG_FOO, PARAM_BOOL, "Failover-Only set to %s" },
{ SEVERITY_FAIL, 0, 0, NULL }
};
@ -928,7 +938,7 @@ static struct api_data *print_data(struct api_data *root, char *buf, bool isjson @@ -928,7 +938,7 @@ static struct api_data *print_data(struct api_data *root, char *buf, bool isjson
sprintf(buf, "%.15f", *((double *)(root->data)));
break;
case API_BOOL:
sprintf(buf, "%s", *((bool *)(root->data)) ? "true" : "false");
sprintf(buf, "%s", *((bool *)(root->data)) ? TRUESTR : FALSESTR);
break;
case API_TIMEVAL:
sprintf(buf, "%ld.%06ld",
@ -1133,6 +1143,9 @@ static char *message(int messageid, int paramid, char *param2, bool isjson) @@ -1133,6 +1143,9 @@ static char *message(int messageid, int paramid, char *param2, bool isjson)
case PARAM_BOTH:
sprintf(buf, codes[i].description, paramid, param2);
break;
case PARAM_BOOL:
sprintf(buf, codes[i].description, paramid ? TRUESTR : FALSESTR);
break;
case PARAM_NONE:
default:
strcpy(buf, codes[i].description);
@ -1233,6 +1246,7 @@ static void minerconfig(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, @@ -1233,6 +1246,7 @@ static void minerconfig(__maybe_unused SOCKETTYPE c, __maybe_unused char *param,
root = api_add_int(root, "Log Interval", &opt_log_interval, false);
root = api_add_const(root, "Device Code", DEVICECODE, false);
root = api_add_const(root, "OS", OSINFO, false);
root = api_add_bool(root, "Failover-Only", &opt_fail_only, false);
root = print_data(root, buf, isjson);
if (isjson)
@ -1240,8 +1254,7 @@ static void minerconfig(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, @@ -1240,8 +1254,7 @@ static void minerconfig(__maybe_unused SOCKETTYPE c, __maybe_unused char *param,
strcat(io_buffer, buf);
}
static const char*
status2str(enum alive status)
static const char *status2str(enum alive status)
{
switch (status) {
case LIFE_WELL:
@ -2704,6 +2717,27 @@ static void minerstats(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, @@ -2704,6 +2717,27 @@ static void minerstats(__maybe_unused SOCKETTYPE c, __maybe_unused char *param,
strcat(io_buffer, JSON_CLOSE);
}
static void failoveronly(__maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
{
if (param == NULL || *param == '\0') {
strcpy(io_buffer, message(MSG_MISBOOL, 0, NULL, isjson));
return;
}
*param = tolower(*param);
if (*param != 't' && *param != 'f') {
strcpy(io_buffer, message(MSG_INVBOOL, 0, NULL, isjson));
return;
}
bool tf = (*param == 't');
opt_fail_only = tf;;
strcpy(io_buffer, message(MSG_FOO, tf, NULL, isjson));
}
static void checkcommand(__maybe_unused SOCKETTYPE c, char *param, bool isjson, char group);
struct CMDS {
@ -2754,6 +2788,7 @@ struct CMDS { @@ -2754,6 +2788,7 @@ struct CMDS {
{ "restart", dorestart, true },
{ "stats", minerstats, false },
{ "check", checkcommand, false },
{ "failover-only", failoveronly, true },
{ NULL, NULL, false }
};

2
cgminer.c

@ -130,7 +130,7 @@ bool use_curses; @@ -130,7 +130,7 @@ bool use_curses;
#endif
static bool opt_submit_stale = true;
static int opt_shares;
static bool opt_fail_only;
bool opt_fail_only;
bool opt_autofan;
bool opt_autoengine;
bool opt_noadl;

1
miner.h

@ -551,6 +551,7 @@ extern bool opt_protocol; @@ -551,6 +551,7 @@ extern bool opt_protocol;
extern char *opt_kernel_path;
extern char *opt_socks_proxy;
extern char *cgminer_path;
extern bool opt_fail_only;
extern bool opt_autofan;
extern bool opt_autoengine;
extern bool use_curses;

Loading…
Cancel
Save