Browse Source

API allow full debug settings control

nfactor-troky
Kano 12 years ago
parent
commit
568b0fed89
  1. 28
      API-README
  2. 78
      api.c
  3. 4
      cgminer.c
  4. 2
      logging.h

28
API-README

@ -287,6 +287,20 @@ The list of requests - a (*) means it requires privileged access - and replies a
Current Block Hash=XXXX..., <- blank if none Current Block Hash=XXXX..., <- blank if none
LP=true/false| <- LP is in use on at least 1 pool LP=true/false| <- LP is in use on at least 1 pool
debug|setting (*)
DEBUG Debug settings
The optional commands for 'setting' are the same as
the screen curses debug settings.
Only the first character is checked (case insensitive):
Silent, Quiet, Verbose, Debug, RPCProto, PerDevice, Normal
The output fields are (as above):
Silent=true/false,
Quiet=true/false,
Verbose=true/false,
Debug=true/false,
RPCProto=true/false,
PerDevice=true/false|
When you enable, disable or restart a GPU or PGA, you will also get Thread messages When you enable, disable or restart a GPU or PGA, you will also get Thread messages
in the cgminer status window in the cgminer status window
@ -306,8 +320,9 @@ windows
Obviously, the JSON format is simply just the names as given before the '=' Obviously, the JSON format is simply just the names as given before the '='
with the values after the '=' with the values after the '='
If you enable cgminer debug (-D or --debug) you will also get messages showing If you enable cgminer debug (-D or --debug) or, when cgminer debug is off,
details of the requests received and the replies turn on debug with the API command 'debug|debug' you will also get messages
showing some details of the requests received and the replies
There are included 4 program examples for accessing the API: There are included 4 program examples for accessing the API:
@ -339,13 +354,18 @@ miner.php - an example web page to access the API
Feature Changelog for external applications using the API: Feature Changelog for external applications using the API:
API V1.19
Added API commands:
'debug'
----------
API V1.18 API V1.18
Modified API commands: Modified API commands:
'stats' - add 'Work Had Roll Time', 'Work Can Roll', 'Work Had Expire', 'stats' - add 'Work Had Roll Time', 'Work Can Roll', 'Work Had Expire',
'Work Roll Time' to the pool stats 'Work Roll Time' to the pool stats
Modified API commands:
'config' - include 'ScanTime' 'config' - include 'ScanTime'
---------- ----------

78
api.c

@ -166,7 +166,7 @@ static const char SEPARATOR = '|';
#define SEPSTR "|" #define SEPSTR "|"
static const char GPUSEP = ','; static const char GPUSEP = ',';
static const char *APIVERSION = "1.18"; static const char *APIVERSION = "1.19";
static const char *DEAD = "Dead"; static const char *DEAD = "Dead";
static const char *SICK = "Sick"; static const char *SICK = "Sick";
static const char *NOSTART = "NoStart"; static const char *NOSTART = "NoStart";
@ -258,6 +258,7 @@ static const char *OSINFO =
#define _MINESTATS "STATS" #define _MINESTATS "STATS"
#define _CHECK "CHECK" #define _CHECK "CHECK"
#define _MINECOIN "COIN" #define _MINECOIN "COIN"
#define _DEBUGSET "DEBUG"
static const char ISJSON = '{'; static const char ISJSON = '{';
#define JSON0 "{" #define JSON0 "{"
@ -295,6 +296,7 @@ static const char ISJSON = '{';
#define JSON_MINESTATS JSON1 _MINESTATS JSON2 #define JSON_MINESTATS JSON1 _MINESTATS JSON2
#define JSON_CHECK JSON1 _CHECK JSON2 #define JSON_CHECK JSON1 _CHECK JSON2
#define JSON_MINECOIN JSON1 _MINECOIN JSON2 #define JSON_MINECOIN JSON1 _MINECOIN JSON2
#define JSON_DEBUGSET JSON1 _DEBUGSET JSON2
#define JSON_END JSON4 JSON5 #define JSON_END JSON4 JSON5
static const char *JSON_COMMAND = "command"; static const char *JSON_COMMAND = "command";
@ -390,6 +392,7 @@ static const char *JSON_PARAMETER = "parameter";
#define MSG_INVBOOL 76 #define MSG_INVBOOL 76
#define MSG_FOO 77 #define MSG_FOO 77
#define MSG_MINECOIN 78 #define MSG_MINECOIN 78
#define MSG_DEBUGSET 79
enum code_severity { enum code_severity {
SEVERITY_ERR, SEVERITY_ERR,
@ -543,6 +546,7 @@ struct CODES {
{ SEVERITY_ERR, MSG_INVBOOL, PARAM_NONE, "Invalid parameter should be true or 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_SUCC, MSG_FOO, PARAM_BOOL, "Failover-Only set to %s" },
{ SEVERITY_SUCC, MSG_MINECOIN,PARAM_NONE, "CGMiner coin" }, { SEVERITY_SUCC, MSG_MINECOIN,PARAM_NONE, "CGMiner coin" },
{ SEVERITY_SUCC, MSG_DEBUGSET,PARAM_STR, "Debug settings" },
{ SEVERITY_FAIL, 0, 0, NULL } { SEVERITY_FAIL, 0, 0, NULL }
}; };
@ -2772,7 +2776,7 @@ static void minecoin(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bo
#endif #endif
root = api_add_const(root, "Hash Method", SHA256STR, false); root = api_add_const(root, "Hash Method", SHA256STR, false);
mutex_lock(&ch_lock); mutex_lock(&ch_lock);
if (current_fullhash && *current_fullhash) { if (current_fullhash && *current_fullhash) {
root = api_add_timeval(root, "Current Block Time", &block_timeval, true); root = api_add_timeval(root, "Current Block Time", &block_timeval, true);
root = api_add_string(root, "Current Block Hash", current_fullhash, true); root = api_add_string(root, "Current Block Hash", current_fullhash, true);
@ -2781,7 +2785,7 @@ static void minecoin(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bo
root = api_add_timeval(root, "Current Block Time", &t, true); root = api_add_timeval(root, "Current Block Time", &t, true);
root = api_add_const(root, "Current Block Hash", BLANK, false); root = api_add_const(root, "Current Block Hash", BLANK, false);
} }
mutex_unlock(&ch_lock); mutex_unlock(&ch_lock);
root = api_add_bool(root, "LP", &have_longpoll, false); root = api_add_bool(root, "LP", &have_longpoll, false);
@ -2791,6 +2795,73 @@ static void minecoin(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bo
strcat(io_buffer, buf); strcat(io_buffer, buf);
} }
static void debugstate(__maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
{
struct api_data *root = NULL;
char buf[TMPBUFSIZ];
if (param == NULL)
param = (char *)BLANK;
else
*param = tolower(*param);
switch(*param) {
case 's':
opt_realquiet = true;
break;
case 'q':
opt_quiet ^= true;
break;
case 'v':
opt_log_output ^= true;
if (opt_log_output)
opt_quiet = false;
break;
case 'd':
opt_debug ^= true;
opt_log_output = opt_debug;
if (opt_debug)
opt_quiet = false;
break;
case 'r':
opt_protocol ^= true;
if (opt_protocol)
opt_quiet = false;
break;
case 'p':
want_per_device_stats ^= true;
opt_log_output = want_per_device_stats;
break;
case 'n':
opt_log_output = false;
opt_debug = false;
opt_quiet = false;
opt_protocol = false;
want_per_device_stats = false;
break;
default:
// anything else just reports the settings
break;
}
sprintf(io_buffer, isjson
? "%s," JSON_DEBUGSET
: "%s" _DEBUGSET ",",
message(MSG_DEBUGSET, 0, NULL, isjson));
root = api_add_bool(root, "Silent", &opt_realquiet, false);
root = api_add_bool(root, "Quiet", &opt_quiet, false);
root = api_add_bool(root, "Verbose", &opt_log_output, false);
root = api_add_bool(root, "Debug", &opt_debug, false);
root = api_add_bool(root, "RPCProto", &opt_protocol, false);
root = api_add_bool(root, "PerDevice", &want_per_device_stats, false);
root = print_data(root, buf, isjson);
if (isjson)
strcat(buf, JSON_CLOSE);
strcat(io_buffer, buf);
}
static void checkcommand(__maybe_unused SOCKETTYPE c, char *param, bool isjson, char group); static void checkcommand(__maybe_unused SOCKETTYPE c, char *param, bool isjson, char group);
struct CMDS { struct CMDS {
@ -2843,6 +2914,7 @@ struct CMDS {
{ "check", checkcommand, false }, { "check", checkcommand, false },
{ "failover-only", failoveronly, true }, { "failover-only", failoveronly, true },
{ "coin", minecoin, false }, { "coin", minecoin, false },
{ "debug", debugstate, true },
{ NULL, NULL, false } { NULL, NULL, false }
}; };

4
cgminer.c

@ -86,10 +86,10 @@ static char packagename[255];
bool opt_protocol; bool opt_protocol;
static bool opt_benchmark; static bool opt_benchmark;
bool have_longpoll; bool have_longpoll;
static bool want_per_device_stats; bool want_per_device_stats;
bool use_syslog; bool use_syslog;
bool opt_quiet; bool opt_quiet;
static bool opt_realquiet; bool opt_realquiet;
bool opt_loginput; bool opt_loginput;
const int opt_cutofftemp = 95; const int opt_cutofftemp = 95;
int opt_log_interval = 5; int opt_log_interval = 5;

2
logging.h

@ -20,6 +20,8 @@ enum {
/* original / legacy debug flags */ /* original / legacy debug flags */
extern bool opt_debug; extern bool opt_debug;
extern bool opt_log_output; extern bool opt_log_output;
extern bool opt_realquiet;
extern bool want_per_device_stats;
/* global log_level, messages with lower or equal prio are logged */ /* global log_level, messages with lower or equal prio are logged */
extern int opt_log_level; extern int opt_log_level;

Loading…
Cancel
Save