i asked in the sidehack support thread but nobody was able to help.. so ill try here
i need an expert to help me.. i got cgminer-gekko working on the r1 and i modified the lua to work with the new cgminer-api.. but i have one problem i cant fix..
if you notice, #2 is twice.. always twice.. i dont know why.. here is my code.
function stats_u3()
local api = {}
local data = {}
local summary = luci.util.execi("/usr/bin/cgminer-api -o edevs 127.0.0.1 4029 | sed \"s/|/\\n/g\" ")
if not summary then
return
end
for line in summary do
for nam, val in string.gfind(line .. ',', "([^=,]+)=*([^,]*),") do
api[nam] = val
end
if api['Device Elapsed'] then
local elapsed = api['Device Elapsed']
local str
local days
local h
local m
local s = elapsed % 60;
elapsed = elapsed - s
elapsed = elapsed / 60
if elapsed == 0 then
str = string.format("%ds", s)
else
m = elapsed % 60;
elapsed = elapsed - m
elapsed = elapsed / 60
if elapsed == 0 then
str = string.format("%dm %ds", m, s);
else
h = elapsed % 24;
elapsed = elapsed - h
elapsed = elapsed / 24
if elapsed == 0 then
str = string.format("%dh %dm %ds", h, m, s)
else
str = string.format("%dd %dh %dm %ds", elapsed, h, m, s);
end
end
end
data[#data+1] = {
['stats'] = api['ASC'],
['elapsed'] = str,
['ghs5s'] = tostring(math.floor(api['MHS 5s']+0.5) / 1000),
['ghsav'] = tostring(math.floor(api['MHS av']+0.5) / 1000),
['hw'] = num_commas(api['Hardware Errors'])
}
end
end
return data
end
i cant find anything in the code that would make #2 come up twice
What's the return from this command when you run from the terminal?
/usr/bin/cgminer-api -o edevs 127.0.0.1 4029 | sed \"s/|/\\n/g\"
Also try just the first part before the pipe.
/usr/bin/cgminer-api -o edevs 127.0.0.1 4029
If they return data from 4 devices, then the issue is in cgminer-api. Not much you can do about that, besides truncating it with the lua functions.
If it returns 3, then the lua logic is messed up.
this is the output including the sed part.. sed takes the pipes and makes it a new line. i can try to do it without sed but i dont think the for line part will work without 3 lines?
STATUS=S,When=1448523822,Code=9,Msg=3 ASC(s),Description=cgminer 4.9.2
ASC=0,Name=COMPAC,ID=0,Enabled=Y,Status=Alive,Temperature=0.00,MHS av=10998.14,MHS 5s=10163.85,MHS 1m=10296.59,MHS 5m=10447.74,MHS 15m=10697.75,Accepted=14287,Rejected=7,Hardware Errors=0,Utility=7.00,Last Share Pool=0,Last Share Time=1448523820,Total MH=1347699314.0000,Diff1 Work=313847,Difficulty Accepted=310210.00000000,Difficulty Rejected=157.00000000,Last Share Difficulty=19.00000000,No Device=false,Last Valid Work=1448523821,Device Hardware%=0.0000,Device Rejected%=0.0500,Device Elapsed=122539
ASC=1,Name=COMPAC,ID=1,Enabled=Y,Status=Alive,Temperature=0.00,MHS av=10985.84,MHS 5s=13295.93,MHS 1m=12017.06,MHS 5m=11367.00,MHS 15m=11222.00,Accepted=14237,Rejected=7,Hardware Errors=0,Utility=6.97,Last Share Pool=0,Last Share Time=1448523822,Total MH=1346191968.0000,Diff1 Work=313496,Difficulty Accepted=309033.00000000,Difficulty Rejected=153.00000000,Last Share Difficulty=19.00000000,No Device=false,Last Valid Work=1448523822,Device Hardware%=0.0000,Device Rejected%=0.0488,Device Elapsed=122539
ASC=2,Name=COMPAC,ID=2,Enabled=Y,Status=Alive,Temperature=0.00,MHS av=10990.72,MHS 5s=13810.23,MHS 1m=11543.57,MHS 5m=11031.56,MHS 15m=10958.14,Accepted=14608,Rejected=6,Hardware Errors=2,Utility=7.15,Last Share Pool=0,Last Share Time=1448523817,Total MH=1346788945.0000,Diff1 Work=313634,Difficulty Accepted=317376.00000000,Difficulty Rejected=126.00000000,Last Share Difficulty=19.00000000,No Device=false,Last Valid Work=1448523822,Device Hardware%=0.0006,Device Rejected%=0.0402,Device Elapsed=122539