-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 89650ac
Showing
8 changed files
with
437 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
node-cgminer | ||
============ | ||
|
||
Usage | ||
----- | ||
|
||
CGMiner command return a Promises/A compatible promise (specifically a [Q](https://github.com/kriskowal/q) promise): | ||
|
||
var client = new CGMinerClient(HOST, PORT); | ||
client.COMMAND(ARG1, ARG2).then(function(results) { | ||
console.log(results); | ||
}, function(err) { | ||
// error handler | ||
}); | ||
|
||
COMMAND corresponds to one of the commands detailed in [CGMiner's API documentation](https://github.com/ckolivas/cgminer/blob/master/API-README). | ||
|
||
TODO | ||
---- | ||
|
||
* Some commands return the raw JSON response object while other return a customized object (`devs`, etc). | ||
* Documentation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env coffee | ||
|
||
CGMinerClient = require "../index" | ||
|
||
client = new CGMinerClient | ||
host: process.env.CGMINER_HOST or "localhost" | ||
port: process.env.CGMINER_PORT or 4028 | ||
|
||
command = process.argv[2].toLowerCase() | ||
|
||
if command is "help" | ||
if process.argv.length > 3 | ||
command = process.argv[3].toLowerCase() | ||
info = CGMinerClient.commands[command] | ||
console.log "Command:", info.name, if info.privledged then "(privledged)" else "" | ||
console.log "Arguments:", info.args if info.args? | ||
console.log "Reply:", info.reply if info.reply? | ||
console.log "Details:\n" | ||
console.log info.details.split("\n").map((l) -> " " + l).join("\n") | ||
console.log "" | ||
else | ||
for name, command of CGMinerClient.commands | ||
console.log name + " " + | ||
(if command.args? then "#{command.args} " else "") + | ||
(if command.reply? then "-> " + command.reply else "") | ||
else | ||
client[command].apply(client, process.argv[3..]).then (result) -> | ||
console.log result | ||
.done() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
# <name--> <args-> <priv---> <rep><details--> | ||
REGEX = /^([\w-]+)(?:\|([^ ]+))?( \(\*\))?[\n\s]+(\w+)((?:.|\n)*)$/ | ||
|
||
exports.getCommands = -> | ||
docs = require("fs").readFileSync("#{__dirname}/commands.txt", "utf-8") | ||
parsed = docs.split(/\n\n /g).map (command) -> command.match REGEX | ||
commands = {} | ||
for command in parsed when command? | ||
commands[command[1]] = | ||
name: command[1] | ||
args: command[2] | ||
privileged: !!command[3] | ||
reply: if command[4] isnt "none" then command[4] else null | ||
details: command[5].split("\n").map((l) -> l.replace(/^\s+/, "")).join("\n") | ||
commands |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,284 @@ | ||
|
||
|
||
version VERSION CGMiner=cgminer, version | ||
API=API| version | ||
|
||
config CONFIG Some miner configuration information: | ||
GPU Count=N, <- the number of GPUs | ||
ASC Count=N, <- the number of ASCs | ||
PGA Count=N, <- the number of PGAs | ||
Pool Count=N, <- the number of Pools | ||
ADL=X, <- Y or N if ADL is compiled in the code | ||
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 | ||
OS=Linux/Apple/..., <- operating System | ||
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,...| | ||
|
||
pools POOLS The status of each pool | ||
e.g. Pool=0,URL=http://pool.com:6311,Status=Alive,...| | ||
|
||
devs DEVS Each available GPU, PGA and ASC with their details | ||
e.g. GPU=0,Accepted=NN,MHS av=NNN,...,Intensity=D| | ||
Last Share Time=NNN, <- standand long time in seconds | ||
(or 0 if none) of last accepted share | ||
Last Share Pool=N, <- pool number (or -1 if none) | ||
Last Valid Work=NNN, <- standand long time in seconds | ||
of last work returned that wasn't an HW: | ||
Will not report PGAs if PGA mining is disabled | ||
Will not report ASCs if ASC mining is disabled | ||
|
||
gpu|N GPU The details of a single GPU number N in the same | ||
format and details as for DEVS | ||
|
||
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 | ||
Use 'pgacount' or 'config' first to see if there are any | ||
|
||
gpucount GPUS Count=N| <- the number of GPUs | ||
|
||
pgacount PGAS Count=N| <- the number of PGAs | ||
Always returns 0 if PGA mining is disabled | ||
|
||
switchpool|N (*) | ||
none There is no reply section just the STATUS section | ||
stating the results of switching pool N to the | ||
highest priority (the pool is also enabled) | ||
The Msg includes the pool URL | ||
|
||
enablepool|N (*) | ||
none There is no reply section just the STATUS section | ||
stating the results of enabling pool N | ||
The Msg includes the pool URL | ||
|
||
addpool|URL,USR,PASS (*) | ||
none There is no reply section just the STATUS section | ||
stating the results of attempting to add pool N | ||
The Msg includes the pool URL | ||
Use '\\' to get a '\' and '\,' to include a comma | ||
inside URL, USR or PASS | ||
|
||
poolpriority|N,... (*) | ||
none There is no reply section just the STATUS section | ||
stating the results of changing pool priorities | ||
See usage below | ||
|
||
disablepool|N (*) | ||
none There is no reply section just the STATUS section | ||
stating the results of disabling pool N | ||
The Msg includes the pool URL | ||
|
||
removepool|N (*) | ||
none There is no reply section just the STATUS section | ||
stating the results of removing pool N | ||
The Msg includes the pool URL | ||
N.B. all details for the pool will be lost | ||
|
||
gpuenable|N (*) | ||
none There is no reply section just the STATUS section | ||
stating the results of the enable request | ||
|
||
gpudisable|N (*) | ||
none There is no reply section just the STATUS section | ||
stating the results of the disable request | ||
|
||
gpurestart|N (*) | ||
none There is no reply section just the STATUS section | ||
stating the results of the restart request | ||
|
||
gpuintensity|N,I (*) | ||
none There is no reply section just the STATUS section | ||
stating the results of setting GPU N intensity to I | ||
|
||
gpumem|N,V (*) | ||
none There is no reply section just the STATUS section | ||
stating the results of setting GPU N memoryclock to V MHz | ||
|
||
gpuengine|N,V (*) | ||
none There is no reply section just the STATUS section | ||
stating the results of setting GPU N clock to V MHz | ||
|
||
gpufan|N,V (*) | ||
none There is no reply section just the STATUS section | ||
stating the results of setting GPU N fan speed to V% | ||
|
||
gpuvddc|N,V (*) | ||
none There is no reply section just the STATUS section | ||
stating the results of setting GPU N vddc to V | ||
|
||
save|filename (*) | ||
none There is no reply section just the STATUS section | ||
stating success or failure saving the cgminer config | ||
to filename | ||
The filename is optional and will use the cgminer | ||
default if not specified | ||
|
||
quit (*) none There is no status section but just a single "BYE" | ||
reply before cgminer quits | ||
|
||
notify NOTIFY The last status and history count of each devices problem | ||
This lists all devices including those not supported | ||
by the 'devs' command | ||
e.g. NOTIFY=0,Name=GPU,ID=0,Last Well=1332432290,...| | ||
|
||
privileged (*) | ||
none There is no reply section just the STATUS section | ||
stating an error if you do not have privileged access | ||
to the API and success if you do have privilege | ||
The command doesn't change anything in cgminer | ||
|
||
pgaenable|N (*) | ||
none There is no reply section just the STATUS section | ||
stating the results of the enable request | ||
You cannot enable a PGA if it's status is not WELL | ||
This is only available if PGA mining is enabled | ||
|
||
pgadisable|N (*) | ||
none There is no reply section just the STATUS section | ||
stating the results of the disable request | ||
This is only available if PGA mining is enabled | ||
|
||
pgaidentify|N (*) | ||
none There is no reply section just the STATUS section | ||
stating the results of the identify request | ||
This is only available if PGA mining is enabled | ||
and currently only BFL singles support this command | ||
On a BFL single it will flash the led on the front | ||
of the device for appoximately 4s | ||
All other non BFL PGA devices will return a warning | ||
status message stating that they dont support it | ||
This adds a 4s delay to the BFL share being processed | ||
so you may get a message stating that procssing took | ||
longer than 7000ms if the request was sent towards | ||
the end of the timing of any work being worked on | ||
e.g.: BFL0: took 8438ms - longer than 7000ms | ||
You should ignore this | ||
|
||
devdetails DEVDETAILS Each device with a list of their static details | ||
This lists all devices including those not supported | ||
by the 'devs' command | ||
e.g. DEVDETAILS=0,Name=GPU,ID=0,Driver=opencl,...| | ||
|
||
restart (*) none There is no status section but just a single "RESTART" | ||
reply before cgminer restarts | ||
|
||
stats STATS Each device or pool that has 1 or more getworks | ||
with a list of stats regarding getwork times | ||
The values returned by stats may change in future | ||
versions thus would not normally be displayed | ||
Device drivers are also able to add stats to the | ||
end of the details returned | ||
|
||
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 | ||
|
||
coin COIN Coin mining information: | ||
Hash Method=sha256/scrypt, | ||
Current Block Time=N.N, <- 0 means none | ||
Current Block Hash=XXXX..., <- blank if none | ||
LP=true/false, <- LP is in use on at least 1 pool | ||
Network Difficulty=NN.NN| | ||
|
||
debug|setting (*) | ||
DEBUG Debug settings | ||
The optional commands for 'setting' are the same as | ||
the screen curses debug settings | ||
You can only specify one setting | ||
Only the first character is checked (case insensitive): | ||
Silent, Quiet, Verbose, Debug, RPCProto, PerDevice, | ||
WorkTime, 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, | ||
WorkTime=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 | ||
|
||
usbstats USBSTATS Stats of all LIBUSB mining devices except ztex | ||
e.g. Name=MMQ,ID=0,Stat=SendWork,Count=99,...| | ||
|
||
pgaset|N,opt[,val] (*) | ||
none There is no reply section just the STATUS section | ||
stating the results of setting PGA N with opt[,val] | ||
This is only available if PGA mining is enabled | ||
|
||
If the PGA does not support any set options, it will | ||
always return a WARN stating pgaset isn't supported | ||
|
||
If opt=help it will return an INFO status with a | ||
help message about the options available | ||
|
||
The current options are: | ||
MMQ opt=clock val=160 to 230 (and a multiple of 2) | ||
|
||
zero|Which,true/false (*) | ||
none There is no reply section just the STATUS section | ||
stating that the zero, and optional summary, was done | ||
If Which='all', all normal cgminer and API statistics | ||
will be zeroed other than the numbers displayed by the | ||
usbstats and stats commands | ||
If Which='bestshare', only the 'Best Share' values | ||
are zeroed for each pool and the global 'Best Share' | ||
The true/false option determines if a full summary is | ||
shown on the cgminer display like is normally displayed | ||
on exit. | ||
|
||
hotplug|N (*) none There is no reply section just the STATUS section | ||
stating that the hotplug setting succeeded | ||
If the code is not compiled with hotplug in it, the | ||
the warning reply will be 'Hotplug is not available' | ||
If N=0 then hotplug will be disabled | ||
If N>0 && <=9999, then hotplug will check for new | ||
devices every N seconds | ||
|
||
asc|N ASC The details of a single ASC number N in the same | ||
format and details as for DEVS | ||
This is only available if ASC mining is enabled | ||
Use 'asccount' or 'config' first to see if there | ||
are any | ||
|
||
ascenable|N (*) | ||
none There is no reply section just the STATUS section | ||
stating the results of the enable request | ||
You cannot enable a ASC if it's status is not WELL | ||
This is only available if ASC mining is enabled | ||
|
||
ascdisable|N (*) | ||
none There is no reply section just the STATUS section | ||
stating the results of the disable request | ||
This is only available if ASC mining is enabled | ||
|
||
ascidentify|N (*) | ||
none There is no reply section just the STATUS section | ||
stating the results of the identify request | ||
This is only available if ASC mining is enabled | ||
and currently only BFL ASICs support this command | ||
On a BFL single it will flash the led on the front | ||
of the device for appoximately 4s | ||
All other non BFL ASIC devices will return a | ||
warning status message stating that they dont | ||
support it | ||
|
||
asccount ASCS Count=N| <- the number of ASCs | ||
Always returns 0 if ASC mining is disabled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CGMinerClient = require "./index" | ||
|
||
client = new CGMinerClient() | ||
|
||
client.version().then (result) -> | ||
console.log result | ||
client.summary().then (result) -> | ||
console.log result | ||
.done() |
Oops, something went wrong.