Merge branch 'master' of github.com:ckolivas/cgminer
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 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490
diff --git a/API-README b/API-README
index c60f2c9..5643e80 100644
--- a/API-README
+++ b/API-README
@@ -178,6 +178,16 @@ The list of requests - a (*) means it requires privileged access - and replies:
Will not report PGAs if PGA mining is disabled
Will not report ASCs if ASC mining is disabled
+ edevs[|old] DEVS The same as devs, except it ignores blacklisted
+ devices and zombie devices
+ If you specify the optional 'old' parameter, then
+ the output will include zombie devices that became
+ zombies less than 'old' seconds ago
+ A value of zero for 'old', which is the default,
+ means ignore all zombies
+ It will return an empty list of devices if all
+ devices are blacklisted or zombies
+
pga|N PGA The details of a single PGA number N in the same
format and details as for DEVS
This is only available if PGA mining is enabled
@@ -293,6 +303,16 @@ The list of requests - a (*) means it requires privileged access - and replies:
Device drivers are also able to add stats to the
end of the details returned
+ estats[|old] STATS The same as stats, except it ignores blacklisted
+ devices, zombie devices and pools
+ If you specify the optional 'old' parameter, then
+ the output will include zombie devices that became
+ zombies less than 'old' seconds ago
+ A value of zero for 'old', which is the default,
+ means ignore all zombies
+ It will return an empty list of devices if all
+ devices are blacklisted or zombies
+
check|cmd COMMAND Exists=Y/N, <- 'cmd' exists in this version
Access=Y/N| <- you have access to use 'cmd'
@@ -483,6 +503,14 @@ miner.php - an example web page to access the API
Feature Changelog for external applications using the API:
+API V3.3 (cgminer v4.1.1)
+
+Added API commands:
+ 'edevs' - Only enabled devices, for 'devs'
+ 'estats' - Only enabled devices, for 'stats'
+
+---------
+
API V3.2 (cgminer v4.1.0)
Fix for:
diff --git a/api.c b/api.c
index 3a9891b..6a1d09c 100644
--- a/api.c
+++ b/api.c
@@ -132,7 +132,7 @@ static const char SEPARATOR = '|';
#define JOIN_CMD "CMD="
#define BETWEEN_JOIN SEPSTR
-static const char *APIVERSION = "3.2";
+static const char *APIVERSION = "3.3";
static const char *DEAD = "Dead";
static const char *SICK = "Sick";
static const char *NOSTART = "NoStart";
@@ -2168,6 +2168,95 @@ static void devstatus(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __ma
io_close(io_data);
}
+static void edevstatus(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
+{
+ bool io_open = false;
+ int devcount = 0;
+ int numasc = 0;
+ int numpga = 0;
+ int i;
+ time_t howoldsec = 0;
+
+#ifdef HAVE_AN_ASIC
+ numasc = numascs();
+#endif
+
+#ifdef HAVE_AN_FPGA
+ numpga = numpgas();
+#endif
+
+ if (numpga == 0 && numasc == 0) {
+ message(io_data, MSG_NODEVS, 0, NULL, isjson);
+ return;
+ }
+
+ if (param && *param)
+ howoldsec = (time_t)atoi(param);
+
+ message(io_data, MSG_DEVS, 0, NULL, isjson);
+ if (isjson)
+ io_open = io_add(io_data, COMSTR JSON_DEVS);
+
+#ifdef HAVE_AN_ASIC
+ if (numasc > 0) {
+ for (i = 0; i < numasc; i++) {
+#ifdef USE_USBUTILS
+ int dev = ascdevice(i);
+ if (dev < 0) // Should never happen
+ continue;
+
+ struct cgpu_info *cgpu = get_devices(dev);
+ if (!cgpu)
+ continue;
+ if (cgpu->blacklisted)
+ continue;
+ if (cgpu->usbinfo.nodev) {
+ if (howoldsec <= 0)
+ continue;
+ if ((when - cgpu->usbinfo.last_nodev.tv_sec) >= howoldsec)
+ continue;
+ }
+#endif
+
+ ascstatus(io_data, i, isjson, isjson && devcount > 0);
+
+ devcount++;
+ }
+ }
+#endif
+
+#ifdef HAVE_AN_FPGA
+ if (numpga > 0) {
+ for (i = 0; i < numpga; i++) {
+#ifdef USE_USBUTILS
+ int dev = pgadevice(i);
+ if (dev < 0) // Should never happen
+ continue;
+
+ struct cgpu_info *cgpu = get_devices(dev);
+ if (!cgpu)
+ continue;
+ if (cgpu->blacklisted)
+ continue;
+ if (cgpu->usbinfo.nodev) {
+ if (howoldsec <= 0)
+ continue;
+ if ((when - cgpu->usbinfo.last_nodev.tv_sec) >= howoldsec)
+ continue;
+ }
+#endif
+
+ pgastatus(io_data, i, isjson, isjson && devcount > 0);
+
+ devcount++;
+ }
+ }
+#endif
+
+ if (isjson && io_open)
+ io_close(io_data);
+}
+
#ifdef HAVE_AN_FPGA
static void pgadev(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
{
@@ -3201,6 +3290,52 @@ static void minerstats(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __m
io_close(io_data);
}
+static void minerestats(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
+{
+ struct cgpu_info *cgpu;
+ bool io_open = false;
+ struct api_data *extra;
+ char id[20];
+ int i, j;
+ time_t howoldsec = 0;
+
+ if (param && *param)
+ howoldsec = (time_t)atoi(param);
+
+ message(io_data, MSG_MINESTATS, 0, NULL, isjson);
+ if (isjson)
+ io_open = io_add(io_data, COMSTR JSON_MINESTATS);
+
+ i = 0;
+ for (j = 0; j < total_devices; j++) {
+ cgpu = get_devices(j);
+ if (!cgpu)
+ continue;
+#ifdef USE_USBUTILS
+ if (cgpu->blacklisted)
+ continue;
+ if (cgpu->usbinfo.nodev) {
+ if (howoldsec <= 0)
+ continue;
+ if ((when - cgpu->usbinfo.last_nodev.tv_sec) >= howoldsec)
+ continue;
+ }
+#endif
+ if (cgpu->drv) {
+ if (cgpu->drv->get_api_stats)
+ extra = cgpu->drv->get_api_stats(cgpu);
+ else
+ extra = NULL;
+
+ sprintf(id, "%s%d", cgpu->drv->name, cgpu->device_id);
+ i = itemstats(io_data, i, id, &(cgpu->cgminer_stats), NULL, extra, cgpu, isjson);
+ }
+ }
+
+ if (isjson && io_open)
+ io_close(io_data);
+}
+
static void failoveronly(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
{
if (param == NULL || *param == '\0') {
@@ -3809,6 +3944,7 @@ struct CMDS {
{ "version", apiversion, false, true },
{ "config", minerconfig, false, true },
{ "devs", devstatus, false, true },
+ { "edevs", edevstatus, false, true },
{ "pools", poolstatus, false, true },
{ "summary", summary, false, true },
#ifdef HAVE_AN_FPGA
@@ -3832,6 +3968,7 @@ struct CMDS {
{ "devdetails", devdetails, false, true },
{ "restart", dorestart, true, false },
{ "stats", minerstats, false, true },
+ { "estats", minerestats, false, true },
{ "check", checkcommand, false, false },
{ "failover-only", failoveronly, true, false },
{ "coin", minecoin, false, true },
diff --git a/driver-hashfast.c b/driver-hashfast.c
index 45f53c0..efbf754 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -1880,7 +1880,8 @@ static void hfa_statline_before(char *buf, size_t bufsiz, struct cgpu_info *hash
* again. */
static void hfa_reinit(struct cgpu_info *hashfast)
{
- hfa_running_shutdown(hashfast, hashfast->device_data);
+ if (hashfast && hashfast->device_data)
+ hfa_running_shutdown(hashfast, hashfast->device_data);
}
static void hfa_free_all_work(struct hashfast_info *info)
diff --git a/miner.php b/miner.php
index 6fd0658..3d9fe78 100644
--- a/miner.php
+++ b/miner.php
@@ -828,6 +828,7 @@ function fmt($section, $name, $value, $when, $alldata)
case 'PGA.Last Share Time':
case 'ASC.Last Share Time':
case 'DEVS.Last Share Time':
+ case 'EDEVS.Last Share Time':
if ($value == 0
|| (isset($alldata['Last Share Pool']) && $alldata['Last Share Pool'] == -1))
{
@@ -844,6 +845,7 @@ function fmt($section, $name, $value, $when, $alldata)
case 'PGA.Last Valid Work':
case 'ASC.Last Valid Work':
case 'DEVS.Last Valid Work':
+ case 'EDEVS.Last Valid Work':
if ($value == 0)
$ret = 'Never';
else
@@ -859,6 +861,7 @@ function fmt($section, $name, $value, $when, $alldata)
case 'PGA.Last Share Pool':
case 'ASC.Last Share Pool':
case 'DEVS.Last Share Pool':
+ case 'EDEVS.Last Share Pool':
if ($value == -1)
{
$ret = 'None';
@@ -867,6 +870,11 @@ function fmt($section, $name, $value, $when, $alldata)
break;
case 'SUMMARY.Elapsed':
case 'STATS.Elapsed':
+ case 'ESTATS.Elapsed':
+ case 'PGA.Device Elapsed':
+ case 'ASC.Device Elapsed':
+ case 'DEVS.Device Elapsed':
+ case 'EDEVS.Device Elapsed':
$s = $value % 60;
$value -= $s;
$value /= 60;
@@ -924,6 +932,7 @@ function fmt($section, $name, $value, $when, $alldata)
case 'PGA.Utility':
case 'ASC.Utility':
case 'DEVS.Utility':
+ case 'EDEVS.Utility':
case 'SUMMARY.Utility':
case 'total.Utility':
$ret = $value.'/m';
@@ -960,6 +969,7 @@ function fmt($section, $name, $value, $when, $alldata)
case 'PGA.Temperature':
case 'ASC.Temperature':
case 'DEVS.Temperature':
+ case 'EDEVS.Temperature':
$ret = $value.'°C';
if (!isset($alldata['GPU']))
{
@@ -969,17 +979,22 @@ function fmt($section, $name, $value, $when, $alldata)
}
case 'GPU.GPU Clock':
case 'DEVS.GPU Clock':
+ case 'EDEVS.GPU Clock':
case 'GPU.Memory Clock':
case 'DEVS.Memory Clock':
+ case 'EDEVS.Memory Clock':
case 'GPU.GPU Voltage':
case 'DEVS.GPU Voltage':
+ case 'EDEVS.GPU Voltage':
case 'GPU.GPU Activity':
case 'DEVS.GPU Activity':
+ case 'EDEVS.GPU Activity':
if ($value == 0)
$class = $warnclass;
break;
case 'GPU.Fan Percent':
case 'DEVS.Fan Percent':
+ case 'EDEVS.Fan Percent':
if ($value == 0)
$class = $warnclass;
else
@@ -993,6 +1008,7 @@ function fmt($section, $name, $value, $when, $alldata)
break;
case 'GPU.Fan Speed':
case 'DEVS.Fan Speed':
+ case 'EDEVS.Fan Speed':
if ($value == 0)
$class = $warnclass;
else
@@ -1010,6 +1026,7 @@ function fmt($section, $name, $value, $when, $alldata)
case 'PGA.MHS av':
case 'ASC.MHS av':
case 'DEVS.MHS av':
+ case 'EDEVS.MHS av':
case 'SUMMARY.MHS av':
case 'total.MHS av':
$parts = explode('.', $value, 2);
@@ -1048,6 +1065,7 @@ function fmt($section, $name, $value, $when, $alldata)
case 'PGA.Total MH':
case 'ASC.Total MH':
case 'DEVS.Total MH':
+ case 'EDEVS.Total MH':
case 'SUMMARY.Total MH':
case 'total.Total MH':
case 'SUMMARY.Getworks':
@@ -1057,6 +1075,7 @@ function fmt($section, $name, $value, $when, $alldata)
case 'PGA.Accepted':
case 'ASC.Accepted':
case 'DEVS.Accepted':
+ case 'EDEVS.Accepted':
case 'SUMMARY.Accepted':
case 'POOL.Accepted':
case 'total.Accepted':
@@ -1064,6 +1083,7 @@ function fmt($section, $name, $value, $when, $alldata)
case 'PGA.Rejected':
case 'ASC.Rejected':
case 'DEVS.Rejected':
+ case 'EDEVS.Rejected':
case 'SUMMARY.Rejected':
case 'POOL.Rejected':
case 'total.Rejected':
@@ -1084,6 +1104,12 @@ function fmt($section, $name, $value, $when, $alldata)
case 'STATS.Times Recv':
case 'STATS.Bytes Recv':
case 'STATS.Net Bytes Recv':
+ case 'ESTATS.Times Sent':
+ case 'ESTATS.Bytes Sent':
+ case 'ESTATS.Net Bytes Sent':
+ case 'ESTATS.Times Recv':
+ case 'ESTATS.Bytes Recv':
+ case 'ESTATS.Net Bytes Recv':
case 'total.Times Sent':
case 'total.Bytes Sent':
case 'total.Net Bytes Sent':
@@ -1107,6 +1133,16 @@ function fmt($section, $name, $value, $when, $alldata)
case 'STATS.Min Diff':
case 'STATS.Max Diff':
case 'STATS.Work Diff':
+ case 'ESTATS.Hs':
+ case 'ESTATS.W':
+ case 'ESTATS.history_time':
+ case 'ESTATS.Pool Wait':
+ case 'ESTATS.Pool Max':
+ case 'ESTATS.Pool Min':
+ case 'ESTATS.Pool Av':
+ case 'ESTATS.Min Diff':
+ case 'ESTATS.Max Diff':
+ case 'ESTATS.Work Diff':
$parts = explode('.', $value, 2);
if (count($parts) == 1)
$dec = '';
@@ -1118,6 +1154,7 @@ function fmt($section, $name, $value, $when, $alldata)
case 'PGA.Status':
case 'ASC.Status':
case 'DEVS.Status':
+ case 'EDEVS.Status':
case 'POOL.Status':
if ($value != 'Alive')
$class = $errorclass;
@@ -1127,6 +1164,7 @@ function fmt($section, $name, $value, $when, $alldata)
case 'ASC.Enabled':
case 'ASC.Enabled':
case 'DEVS.Enabled':
+ case 'EDEVS.Enabled':
if ($value != 'Y')
$class = $warnclass;
break;
@@ -1144,6 +1182,7 @@ function fmt($section, $name, $value, $when, $alldata)
case 'PGA.Difficulty Accepted':
case 'ASC.Difficulty Accepted':
case 'DEVS.Difficulty Accepted':
+ case 'EDEVS.Difficulty Accepted':
case 'POOL.Difficulty Accepted':
case 'total.Difficulty Accepted':
case 'SUMMARY.Difficulty Rejected':
@@ -1151,6 +1190,7 @@ function fmt($section, $name, $value, $when, $alldata)
case 'PGA.Difficulty Rejected':
case 'ASC.Difficulty Rejected':
case 'DEVS.Difficulty Rejected':
+ case 'EDEVS.Difficulty Rejected':
case 'POOL.Difficulty Rejected':
case 'total.Difficulty Rejected':
case 'SUMMARY.Difficulty Stale':
@@ -1160,12 +1200,15 @@ function fmt($section, $name, $value, $when, $alldata)
case 'PGA.Last Share Difficulty':
case 'ASC.Last Share Difficulty':
case 'DEVS.Last Share Difficulty':
+ case 'EDEVS.Last Share Difficulty':
case 'POOL.Last Share Difficulty':
if ($value != '')
$ret = number_format((float)$value, 2);
break;
case 'DEVS.Device Hardware%':
case 'DEVS.Device Rejected%':
+ case 'EDEVS.Device Hardware%':
+ case 'EDEVS.Device Rejected%':
case 'ASC.Device Hardware%':
case 'ASC.Device Rejected%':
case 'PGA.Device Hardware%':
@@ -1963,12 +2006,14 @@ $sectionmap = array(
'SUMMARY' => 'summary',
'POOL' => 'pools',
'DEVS' => 'devs',
+ 'EDEVS' => 'edevs',
'GPU' => 'devs', // You would normally use DEVS
'PGA' => 'devs', // You would normally use DEVS
'ASC' => 'devs', // You would normally use DEVS
'NOTIFY' => 'notify',
'DEVDETAILS' => 'devdetails',
'STATS' => 'stats',
+ 'ESTATS' => 'estats',
'CONFIG' => 'config',
'COIN' => 'coin',
'USBSTATS' => 'usbstats');
@@ -2176,6 +2221,7 @@ function joinsections($sections, $results, $errors)
{
case 'POOL':
case 'DEVS':
+ case 'EDEVS':
case 'CONFIG':
case 'COIN':
$sectionmap[$section] = $section;
@@ -2187,6 +2233,7 @@ function joinsections($sections, $results, $errors)
}
break;
case 'DEVS':
+ case 'EDEVS':
switch($both[1])
{
case 'NOTIFY':
@@ -2197,6 +2244,7 @@ function joinsections($sections, $results, $errors)
$results[$section] = joinfields($both[0], $both[1], $join, $results);
break;
case 'STATS':
+ case 'ESTATS':
$join = array('L' => array('Name','ID'), 'R' => array('ID'));
$sectionmap[$section] = $section;
$results[$section] = joinlr($both[0], $both[1], $join, $results);
@@ -2236,7 +2284,7 @@ function secmatch($section, $field)
if ($section == $field)
return true;
- if ($section == 'DEVS'
+ if (($section == 'DEVS' || $section == 'EDEVS')
&& ($field == 'GPU' || $field == 'PGA' || $field == 'ASC'))
return true;