API add display of and setting queue,scantime,expiry
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
diff --git a/API-README b/API-README
index 2d72d81..4ac86b9 100644
--- a/API-README
+++ b/API-README
@@ -124,7 +124,10 @@ The list of requests - a (*) means it requires privileged access - and replies a
Log Interval=N, <- log interval (--log N)
Device Code=GPU ICA , <- spaced list of compiled devices
OS=Linux/Apple/..., <- operating System
- Failover-Only=true/false | <- failover-only setting
+ Failover-Only=true/false, <- failover-only setting
+ ScanTime=N, <- --scan-time setting
+ Queue=N, <- --queue setting
+ Expiry=N| <- --expiry setting
summary SUMMARY The status summary of the miner
e.g. Elapsed=NNN,Found Blocks=N,Getworks=N,...|
@@ -318,6 +321,13 @@ The list of requests - a (*) means it requires privileged access - and replies a
RPCProto=true/false,
PerDevice=true/false|
+ setconfig|name,N (*)
+ none There is no reply section just the STATUS section
+ stating the results of setting 'name' to N
+ The valid values for name are currently:
+ queue, scantime, expiry
+ N is an integer in the range 0 to 9999
+
When you enable, disable or restart a GPU or PGA, you will also get Thread messages
in the cgminer status window
@@ -376,6 +386,7 @@ API V1.19
Added API commands:
'debug'
'pgaidentify|N'
+ 'setconfig|name,N'
Modified API commands:
Change pool field name 'Diff1 Shares' to 'Diff1 Work'
@@ -384,6 +395,7 @@ Modified API commands:
'pga|N' - add 'Diff1 Work'
'notify' - add '*Dev Throttle' (for BFL Singles)
'pools' - add 'Proxy Type', 'Proxy'
+ 'config' - add 'Queue', 'Expiry'
----------
diff --git a/api.c b/api.c
index e318518..2e61aba 100644
--- a/api.c
+++ b/api.c
@@ -259,6 +259,7 @@ static const char *OSINFO =
#define _CHECK "CHECK"
#define _MINECOIN "COIN"
#define _DEBUGSET "DEBUG"
+#define _SETCONFIG "SETCONFIG"
static const char ISJSON = '{';
#define JSON0 "{"
@@ -297,6 +298,7 @@ static const char ISJSON = '{';
#define JSON_CHECK JSON1 _CHECK JSON2
#define JSON_MINECOIN JSON1 _MINECOIN JSON2
#define JSON_DEBUGSET JSON1 _DEBUGSET JSON2
+#define JSON_SETCONFIG JSON1 _SETCONFIG JSON2
#define JSON_END JSON4 JSON5
static const char *JSON_COMMAND = "command";
@@ -395,6 +397,11 @@ static const char *JSON_PARAMETER = "parameter";
#define MSG_DEBUGSET 79
#define MSG_PGAIDENT 80
#define MSG_PGANOID 81
+#define MSG_SETCONFIG 82
+#define MSG_UNKCON 83
+#define MSG_INVNUM 84
+#define MSG_CONPAR 85
+#define MSG_CONVAL 86
enum code_severity {
SEVERITY_ERR,
@@ -423,6 +430,7 @@ enum code_parameters {
PARAM_STR,
PARAM_BOTH,
PARAM_BOOL,
+ PARAM_SET,
PARAM_NONE
};
@@ -553,6 +561,11 @@ struct CODES {
{ SEVERITY_SUCC, MSG_PGAIDENT,PARAM_PGA, "Identify command sent to PGA%d" },
{ SEVERITY_WARN, MSG_PGANOID, PARAM_PGA, "PGA%d does not support identify" },
#endif
+ { SEVERITY_SUCC, MSG_SETCONFIG,PARAM_SET, "Set config '%s' to %d" },
+ { SEVERITY_ERR, MSG_UNKCON, PARAM_STR, "Unknown config '%s'" },
+ { SEVERITY_ERR, MSG_INVNUM, PARAM_BOTH, "Invalid number (%d) for '%s' range is 0-9999" },
+ { SEVERITY_ERR, MSG_CONPAR, PARAM_NONE, "Missing config parameters 'name\\,N'" },
+ { SEVERITY_ERR, MSG_CONVAL, PARAM_STR, "Missing config value N for '%s\\,N'" },
{ SEVERITY_FAIL, 0, 0, NULL }
};
@@ -1165,6 +1178,9 @@ static char *message(int messageid, int paramid, char *param2, bool isjson)
case PARAM_BOOL:
sprintf(buf, codes[i].description, paramid ? TRUESTR : FALSESTR);
break;
+ case PARAM_SET:
+ sprintf(buf, codes[i].description, param2, paramid);
+ break;
case PARAM_NONE:
default:
strcpy(buf, codes[i].description);
@@ -1267,6 +1283,8 @@ static void minerconfig(__maybe_unused SOCKETTYPE c, __maybe_unused char *param,
root = api_add_const(root, "OS", OSINFO, false);
root = api_add_bool(root, "Failover-Only", &opt_fail_only, false);
root = api_add_int(root, "ScanTime", &opt_scantime, false);
+ root = api_add_int(root, "Queue", &opt_queue, false);
+ root = api_add_int(root, "Expiry", &opt_expiry, false);
root = print_data(root, buf, isjson);
if (isjson)
@@ -2917,6 +2935,43 @@ static void debugstate(__maybe_unused SOCKETTYPE c, char *param, bool isjson, __
strcat(io_buffer, buf);
}
+static void setconfig(__maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
+{
+ char *comma;
+ int value;
+
+ if (param == NULL || *param == '\0') {
+ strcpy(io_buffer, message(MSG_CONPAR, 0, NULL, isjson));
+ return;
+ }
+
+ comma = strchr(param, ',');
+ if (!comma) {
+ strcpy(io_buffer, message(MSG_CONVAL, 0, param, isjson));
+ return;
+ }
+
+ *(comma++) = '\0';
+ value = atoi(comma);
+ if (value < 0 || value > 9999) {
+ strcpy(io_buffer, message(MSG_INVNUM, value, param, isjson));
+ return;
+ }
+
+ if (strcasecmp(param, "queue") == 0)
+ opt_queue = value;
+ else if (strcasecmp(param, "scantime") == 0)
+ opt_scantime = value;
+ else if (strcasecmp(param, "expiry") == 0)
+ opt_expiry = value;
+ else {
+ strcpy(io_buffer, message(MSG_UNKCON, 0, param, isjson));
+ return;
+ }
+
+ strcpy(io_buffer, message(MSG_SETCONFIG, value, param, isjson));
+}
+
static void checkcommand(__maybe_unused SOCKETTYPE c, char *param, bool isjson, char group);
struct CMDS {
@@ -2971,6 +3026,7 @@ struct CMDS {
{ "failover-only", failoveronly, true },
{ "coin", minecoin, false },
{ "debug", debugstate, true },
+ { "setconfig", setconfig, true },
{ NULL, NULL, false }
};
diff --git a/cgminer.c b/cgminer.c
index f42e0e0..9e9ef64 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -93,7 +93,7 @@ bool opt_realquiet;
bool opt_loginput;
const int opt_cutofftemp = 95;
int opt_log_interval = 5;
-static int opt_queue = 1;
+int opt_queue = 1;
int opt_scantime = 60;
int opt_expiry = 120;
int opt_bench_algo = -1;
diff --git a/miner.h b/miner.h
index 3167fab..924bc85 100644
--- a/miner.h
+++ b/miner.h
@@ -607,7 +607,9 @@ typedef bool (*sha256_func)(struct thr_info*, const unsigned char *pmidstate,
extern bool fulltest(const unsigned char *hash, const unsigned char *target);
+extern int opt_queue;
extern int opt_scantime;
+extern int opt_expiry;
extern pthread_mutex_t console_lock;
extern pthread_mutex_t ch_lock;