Author

Topic: bmminer api json (Read 245 times)

member
Activity: 159
Merit: 12
October 30, 2018, 12:02:10 PM
#6
you are right, strange, something wrong with curl library or im using incorrect opts.

any way i got it working using fsockopen function:

Code:
$socket = fsockopen($ip, 4028, $err_code, $err_str);
$data = '{"id":1,"jsonrpc":"2.0","command": "summary"}' . "\r\n\r\n";
fputs($socket, $data);
$buffer = null;
while (!feof($socket)) { $buffer .= fgets($socket, 4028); }
if ($socket) {  fclose($socket); }
print $buffer;
full member
Activity: 294
Merit: 129
October 29, 2018, 11:35:45 AM
#5
curl doesnt work properly but as Tim says netcat will work
full member
Activity: 538
Merit: 175
October 27, 2018, 10:57:14 AM
#4
it looks like, i incorrectly pass $data using curl, as it cannot recognize the command. i cannot find working example using curl function..

I don't think this is a RESTful API, so you probably can't use curl. You should be able to use netcat or a similar program though. And if you are looking for stats I would use "command":"stats" instead of summary.

Now, if you look for the }{ right near the start of the second line, you will find the missing comma that I was referring to:

Code:
{"STATUS":[{"STATUS":"S","When":1540655486,"Code":70,"Msg":"BMMiner stats","Description":"bmminer 1.0.0"}],"STATS":[{"BMMiner":"2.0.0","Miner":"16.8.1.3","CompileTime":"Fri Jul 13 10:46:43 CST 2018","Type":"Antminer S9j
S9j_V2.12"}{"STATS":0,"ID":"BC50","Elapsed":676738,"Calls":0,"Wait":0.000000,"Max":0.000000,"Min":99999999.000000,"GHS 5s":"16545.91","GHS av":16656.74,"miner_count":3,"frequency":"850","fan_num":2,"fan1":0,"fan2":0,"fan3":4560,"fan4":0,"fan5":0,"fan6":4440,"fan7":0,"fan8":0,"temp_num":3,"temp1":0,"temp2":0,"temp3":0,"temp4":0,"temp5":0,"temp6":59,"temp7":54,"temp8":57,"temp9":0,"temp10":0,"temp11":0,"temp12":0,"temp13":0,"temp14":0,"temp15":0,"temp16":0,"temp2_1":0,"temp2_2":0,"temp2_3":0,"temp2_4":0,"temp2_5":0,"temp2_6":81,"temp2_7":72,"temp2_8":74,"temp2_9":0,"temp2_10":0,"temp2_11":0,"temp2_12":0,"temp2_13":0,"temp2_14":0,"temp2_15":0,"temp2_16":0,"temp3_1":0,"temp3_2":0,"temp3_3":0,"temp3_4":0,"temp3_5":0,"temp3_6":0,"temp3_7":0,"temp3_8":0,"temp3_9":0,"temp3_10":0,"temp3_11":0,"temp3_12":0,"temp3_13":0,"temp3_14":0,"temp3_15":0,"temp3_16":0,"freq_avg1":0.00,"freq_avg2":0.00,"freq_avg3":0.00,"freq_avg4":0.00,"freq_avg5":0.00,"freq_avg6":850.00,"freq_avg7":850.00,"freq_avg8":850.00,"freq_avg9":0.00,"freq_avg10":0.00,"freq_avg11":0.00,"freq_avg12":0.00,"freq_avg13":0.00,"freq_avg14":0.00,"freq_avg15":0.00,"freq_avg16":0.00,"total_rateideal":18314.09,"total_freqavg":850.00,"total_acn":189,"total_rate":16545.90,"chain_rateideal1":0.00,"chain_rateideal2":0.00,"chain_rateideal3":0.00,"chain_rateideal4":0.00,"chain_rateideal5":0.00,"chain_rateideal6":6104.70,"chain_rateideal7":6104.70,"chain_rateideal8":6104.70,"chain_rateideal9":0.00,"chain_rateideal10":0.00,"chain_rateideal11":0.00,"chain_rateideal12":0.00,"chain_rateideal13":0.00,"chain_rateideal14":0.00,"chain_rateideal15":0.00,"chain_rateideal16":0.00,"temp_max":59,"Device Hardware%":0.0004,"no_matching_work":10764,"chain_acn1":0,"chain_acn2":0,"chain_acn3":0,"chain_acn4":0,"chain_acn5":0,"chain_acn6":63,"chain_acn7":63,"chain_acn8":63,"chain_acn9":0,"chain_acn10":0,"chain_acn11":0,"chain_acn12":0,"chain_acn13":0,"chain_acn14":0,"chain_acn15":0,"chain_acn16":0,"chain_acs1":"","chain_acs2":"","chain_acs3":"","chain_acs4":"","chain_acs5":"","chain_acs6":" oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo ooooooo","chain_acs7":" oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo ooooooo","chain_acs8":" oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo ooooooo","chain_acs9":"","chain_acs10":"","chain_acs11":"","chain_acs12":"","chain_acs13":"","chain_acs14":"","chain_acs15":"","chain_acs16":"","chain_hw1":0,"chain_hw2":0,"chain_hw3":0,"chain_hw4":0,"chain_hw5":0,"chain_hw6":10581,"chain_hw7":78,"chain_hw8":105,"chain_hw9":0,"chain_hw10":0,"chain_hw11":0,"chain_hw12":0,"chain_hw13":0,"chain_hw14":0,"chain_hw15":0,"chain_hw16":0,"chain_rate1":"","chain_rate2":"","chain_rate3":"","chain_rate4":"","chain_rate5":"","chain_rate6":"5773.27","chain_rate7":"4768.92","chain_rate8":"6003.71","chain_rate9":"","chain_rate10":"","chain_rate11":"","chain_rate12":"","chain_rate13":"","chain_rate14":"","chain_rate15":"","chain_rate16":"","chain_xtime6":"{X0=2,X1=2,X2=2,X3=2,X4=2,X5=2,X6=2,X7=2,X8=2,X9=2,X10=2,X11=2,X12=2,X13=2,X14=3,X15=2,X16=2,X17=2,X18=2,X19=2,X20=2,X21=2,X22=2,X23=2,X24=2,X25=2,X26=2,X27=10,X28=2,X29=2,X30=2,X31=2,X32=2,X33=2,X34=2,X35=2,X36=2,X37=2,X38=2,X39=2,X40=2,X41=2,X42=2,X43=2,X44=2,X45=2,X46=2,X47=2,X48=2,X49=2,X50=2,X51=2,X52=2,X53=2,X54=2,X55=2,X56=5,X57=2,X58=2,X59=2,X60=2,X61=2,X62=2}","chain_xtime7":"{X0=2,X1=11,X2=2,X3=2,X4=2,X5=2,X6=2,X7=2,X8=2,X9=2,X10=3557,X11=2,X12=2,X13=2,X14=2,X15=2,X16=5,X17=2,X18=2,X19=2,X20=4,X21=2,X22=4,X23=2,X24=2,X25=2,X26=4812,X27=2,X28=2,X29=2,X30=2,X31=2,X32=3,X33=2,X34=2,X35=2,X36=2,X37=2,X38=3,X39=5,X40=2,X41=2,X42=2,X43=2,X44=3,X45=2,X46=3,X47=2,X48=5,X49=2,X50=2,X51=2,X52=2,X53=2,X54=19,X55=2,X56=3,X57=2,X58=2,X59=4,X60=4,X61=2,X62=40}","chain_xtime8":"{X0=2,X1=2,X2=2,X3=2,X4=2,X5=2,X6=2,X7=2,X8=2,X9=2,X10=2,X11=2,X12=2,X13=2,X14=2,X15=2,X16=2,X17=2,X18=2,X19=2,X20=2,X21=2,X22=2,X23=2,X24=2,X25=2,X26=2,X27=2,X28=2,X29=2,X30=2,X31=2,X32=2,X33=2,X34=2,X35=2,X36=2,X37=2,X38=2,X39=2,X40=2,X41=2,X42=2,X43=2,X44=2,X45=2,X46=2,X47=2,X48=2,X49=2,X50=2,X51=2,X52=2,X53=2,X54=2,X55=2,X56=2,X57=2,X58=2,X59=2,X60=2,X61=2,X62=2}","chain_offside_6":"0","chain_offside_7":"0","chain_offside_8":"0","chain_opencore_6":"0","chain_opencore_7":"0","chain_opencore_8":"0","miner_version":"16.8.1.3"}],"id":1}
member
Activity: 159
Merit: 12
October 26, 2018, 04:31:31 PM
#3
The API does not return perfect JSON. I don't remember exactly where the issue is but I know there's a missing comma or bracket or something.

it looks like, i incorrectly pass $data using curl, as it cannot recognize the command. i cannot find working example using curl function..
full member
Activity: 538
Merit: 175
October 25, 2018, 10:34:10 PM
#2
The API does not return perfect JSON. I don't remember exactly where the issue is but I know there's a missing comma or bracket or something.
member
Activity: 159
Merit: 12
October 25, 2018, 10:39:36 AM
#1
Hi, im trying to get stats from s9 using php script, but cannot get it, i'm using following code:

Code:
$data = '{"id":1,"jsonrpc":"2.0","command":"summary"}';

$ch = curl_init('10.10.10.12:4028');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data))
);
print curl_exec($ch);

as result  i'm getting:

Code:
STATUS=E,When=1540481771,Code=14,Msg=Invalid command,Description=bmminer 1.0.0|

please help to get it worked.
Jump to: