Skip to content

Commit

Permalink
fix new ethminer output
Browse files Browse the repository at this point in the history
  • Loading branch information
orkblutt committed Aug 20, 2017
1 parent 70c21d0 commit d43275e
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 27 deletions.
2 changes: 1 addition & 1 deletion MiningLigth.pro
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = MinerLamp
TEMPLATE = app
VERSION = 0.1.0.550
VERSION = 0.1.0.620

# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
Expand Down
2 changes: 1 addition & 1 deletion mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ MainWindow::MainWindow(QWidget *parent) :
int pos = ui->lineEditArgs->text().indexOf("-O ");
if(pos > 0)
ui->lineEditAccount->setText(ui->lineEditArgs->text().mid(pos + 3
, ui->lineEditArgs->text().indexOf(" 0x") > 0 ? 43 : 41));
, ui->lineEditArgs->text().indexOf(" 0x") > 0 ? 42 : 40));
}

MainWindow::~MainWindow()
Expand Down
68 changes: 43 additions & 25 deletions minerprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ MinerProcess::MinerProcess():
, _ledActivated(false)
, _ledHash(50)
, _ledShare(100)
, _acceptedShare(0)
, _staleShare(0)
, _shareNumber("")
#ifdef DONATE
, _donate(Q_NULLPTR)
#endif
Expand Down Expand Up @@ -121,9 +124,47 @@ void MinerProcess::onReadyToReadStdout()
void MinerProcess::onReadyToReadStderr()
{
QString line(_miner.readAllStandardError());

if(line.length() > 1)
{
int mhsPos = line.indexOf(QRegExp("[0-9]{1,5}.[0-9]{1,2}MH/s"));
if(mhsPos != -1)
{
int endPos = line.indexOf(" (", mhsPos);
QString hashRate = line.mid(mhsPos, endPos - mhsPos);

qDebug() << hashRate;


if(_readyToMonitor)
{
if(hashRate == "0.00MH/s")
_0mhs++;
else
_0mhs = 0;

if(_0mhs > _max0mhs)
{
restart();
}
}

hashRate += " ";
hashRate += _shareNumber;

emit emitHashRate(hashRate);

_hashrateCount++;
}

int miningOnPos = line.indexOf("Mining on #");
if(miningOnPos != -1)
{
miningOnPos = line.indexOf("[", miningOnPos);
int endPos = line.indexOf("]", miningOnPos) + 1;
_shareNumber = line.mid(miningOnPos, endPos - miningOnPos);
}


QStringList list = line.split(QRegExp("\r\n"), QString::SkipEmptyParts);
qDebug() << list;
for(int i = 0; i < list.size(); i++)
Expand All @@ -135,7 +176,6 @@ void MinerProcess::onReadyToReadStderr()
|| list.at(i).indexOf("Submitted") != -1)
{
_log->append(list.at(i).simplified());

}
}
else
Expand All @@ -151,29 +191,6 @@ void MinerProcess::onReadyToReadStderr()
return;
}

if(line.indexOf("MH/s") != -1)
{
QRegExp regex("[, ]");
QStringList list = line.split(regex, QString::SkipEmptyParts);
QString hasrate(list.at(6) + " " + list.at(7));

emit emitHashRate(hasrate);

if(_readyToMonitor)
{
if(list.at(7) == "0.00MH/s")
_0mhs++;
else
_0mhs = 0;

if(_0mhs > _max0mhs)
{
restart();
}
}
_hashrateCount++;
}

if(_ledActivated)
{
if(line.indexOf("B-) Submitted and accepted.") != -1)
Expand Down Expand Up @@ -207,6 +224,7 @@ void MinerProcess::onStarted()
_log->append("ethminer start");
_isRunning = true;
_0mhs = 0;
_shareNumber = "";
emit emitStarted();
}

Expand Down
5 changes: 5 additions & 0 deletions minerprocess.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ class MinerProcess : public QObject

unsigned int _hashrateCount;

unsigned int _acceptedShare;
unsigned int _staleShare;

QString _shareNumber;

unsigned short _ledHash;
unsigned short _ledShare;

Expand Down
2 changes: 2 additions & 0 deletions nanopoolapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ void nanopoolAPI::replyFinished(QNetworkReply *reply)
_userBalance = jsonData.value("balance").toString().toDouble();
_currentCalcultatedHashRate = jsonData.value("hashrate").toString().toDouble();



QJsonObject jsonHR = jsonData.value("avgHashrate").toObject();

_averageHashRate1H = jsonHR["h1"].toString().toDouble();
Expand Down

0 comments on commit d43275e

Please sign in to comment.