Skip to content

Commit

Permalink
fixed a crash
Browse files Browse the repository at this point in the history
  • Loading branch information
orkblutt committed Sep 10, 2017
1 parent d8d3115 commit 50869e8
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 44 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.2.0
VERSION = 0.1.2.25

# 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
4 changes: 4 additions & 0 deletions helpdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ helpDialog::helpDialog(QSettings* settings, QWidget *parent) :
_settings(settings),
ui(new Ui::helpDialog)
{

ui->setupUi(this);

setFixedSize(size());

ui->plainTextEdit->appendHtml("<html>");
ui->plainTextEdit->appendHtml("<h2>Simple Qt GUI for running ethminer safely.</h2><br>");
ui->plainTextEdit->appendHtml("It will restart ethminer for you in case of error...");
Expand Down
3 changes: 3 additions & 0 deletions helpdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
<property name="windowTitle">
<string>Help</string>
</property>
<property name="whatsThis">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
Expand Down
2 changes: 1 addition & 1 deletion leddialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LEDDialog::LEDDialog(unsigned short hash, unsigned short share, QWidget *parent)
_sharingLEDIntensity(share)
{
ui->setupUi(this);

setFixedSize(size());
ui->spinBoxLEDHashIntensity->setValue(hash);
ui->spinBoxLEDShareIntensity->setValue(share);
}
Expand Down
58 changes: 39 additions & 19 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ MainWindow::MainWindow(QWidget *parent) :
_nano(Q_NULLPTR)
{

_process = new MinerProcess(_settings);
_settings = new QSettings(QString(QDir::currentPath() + QDir::separator() + "minerlamp.ini"), QSettings::IniFormat);

_process = new MinerProcess(_settings);

ui->setupUi(this);

_process->setLogControl(ui->textEdit);
Expand Down Expand Up @@ -84,7 +85,6 @@ MainWindow::MainWindow(QWidget *parent) :

setupToolTips();


createActions();

createTrayIcon();
Expand Down Expand Up @@ -118,14 +118,23 @@ MainWindow::MainWindow(QWidget *parent) :
if(pos > 0)
ui->lineEditAccount->setText(ui->lineEditArgs->text().mid(pos + 3
, ui->lineEditArgs->text().indexOf(" 0x") > 0 ? 42 : 40));
/*
#ifdef NVIDIA
_fanThread = new fanSpeedThread(_nvapi);
_fanThread->start();
#endif
*/
}

MainWindow::~MainWindow()
{
saveParameters();

_process->stop();

#ifdef NVIDIA
if(_nvapi != Q_NULLPTR)
delete _nvapi;
#endif
delete _process;
delete _settings;
delete ui;
Expand Down Expand Up @@ -276,24 +285,24 @@ void MainWindow::setupEditor()
void MainWindow::setupToolTips()
{

ui->lcdNumberHashRate->setToolTip("Displaing the current hashrate");
ui->lcdNumberHashRate->setToolTip("Displaying the current hashrate");
#ifdef NVIDIA
ui->lcdNumberGPUCount->setToolTip("Number of nVidia GPU(s)");

ui->lcdNumberMaxGPUTemp->setToolTip("Displaing the current higher temperature");
ui->lcdNumberMinGPUTemp->setToolTip("Displaing the current lower temperature");
ui->lcdNumberMaxGPUTemp->setToolTip("Displaying the current higher temperature");
ui->lcdNumberMinGPUTemp->setToolTip("Displaying the current lower temperature");

ui->lcdNumberMaxFanSpeed->setToolTip("Displaing the current higher fan speed in percent of the max speed");
ui->lcdNumberMinFanSpeed->setToolTip("Displaing the current lower fan speed in percent of the max speed");
ui->lcdNumberMaxFanSpeed->setToolTip("Displaying the current higher fan speed in percent of the max speed");
ui->lcdNumberMinFanSpeed->setToolTip("Displaying the current lower fan speed in percent of the max speed");

ui->lcdNumberMaxMemClock->setToolTip("Displaing the current higher memory clock");
ui->lcdNumberMinMemClock->setToolTip("Displaing the current lower memory clock");
ui->lcdNumberMaxMemClock->setToolTip("Displaying the current higher memory clock");
ui->lcdNumberMinMemClock->setToolTip("Displaying the current lower memory clock");

ui->lcdNumberMaxGPUClock->setToolTip("The GPU in your rig with the higher clock");
ui->lcdNumberMinGPUClock->setToolTip("The GPU in your rig with the lower clock");

ui->lcdNumberMaxWatt->setToolTip("Displaing the current higher power draw in Watt");
ui->lcdNumberMinWatt->setToolTip("Displaing the current lower power draw in Watt");
ui->lcdNumberMaxWatt->setToolTip("Displaying the current higher power draw in Watt");
ui->lcdNumberMinWatt->setToolTip("Displaying the current lower power draw in Watt");

ui->lcdNumberTotalPowerDraw->setToolTip("The total power used by the GPUs");

Expand All @@ -305,7 +314,6 @@ void MainWindow::setupToolTips()
ui->groupBoxWatchdog->setToolTip("Check it to activate the following watchdog options");
else
ui->groupBoxWatchdog->setToolTip("");

}


Expand Down Expand Up @@ -359,9 +367,6 @@ void MainWindow::onMinerStoped()
void MainWindow::onHashrate(QString &hashrate)
{

qDebug() << "hashrate:" << hashrate;


QString hrValue = hashrate.mid(0, hashrate.indexOf("Mh/s"));


Expand Down Expand Up @@ -619,7 +624,6 @@ void MainWindow::on_pushButtonDisplayPoolStats_clicked()

void MainWindow::onBalance(double balance)
{
qDebug() << balance;
ui->lcdNumberBalance->display(balance);
}

Expand All @@ -637,14 +641,30 @@ void MainWindow::onPoolUserInfo(double userBalance
}

#ifdef NVIDIA
fanSpeedThread::fanSpeedThread(QObject *pParent)
fanSpeedThread::fanSpeedThread(nvidiaAPI *nvapi, QObject */*pParent*/) :
_nvapi(nvapi),
_downLimit(30),
_upLimit(70)
{


}

void fanSpeedThread::run()
{
unsigned int gpuCount = _nvapi->getGPUCount();
while(true)
{
for(uint i = 0; i < gpuCount; i++)
{
int gpuTemp = _nvapi->getGpuTemperature(i);
if(gpuTemp > _downLimit)
{
int fanLevel = (100 / (_upLimit - _downLimit)) * gpuTemp;
qDebug() << fanLevel;
}
}

QThread::sleep(5);
}
}
#endif
8 changes: 7 additions & 1 deletion mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,15 @@ class fanSpeedThread: public QThread
{
Q_OBJECT
public:
fanSpeedThread(QObject* pParent = Q_NULLPTR);
fanSpeedThread(nvidiaAPI* nvapi, QObject* = Q_NULLPTR);

void run();
private:

nvidiaAPI* _nvapi;

int _upLimit;
int _downLimit;
};
#endif

Expand Down Expand Up @@ -181,6 +186,7 @@ private slots:
autoStart* _starter;
#ifdef NVIDIA
maxGPUThread* _maxGPUTemp;
fanSpeedThread* _fanThread;
#endif

nanopoolAPI* _nano;
Expand Down
2 changes: 1 addition & 1 deletion mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ QPushButton:disabled
<item row="1" column="2">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Deleay before no hash:</string>
<string>Delay before no hash:</string>
</property>
</widget>
</item>
Expand Down
28 changes: 8 additions & 20 deletions minerprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ void MinerProcess::onReadyToReadStderr()
int endPos = line.indexOf(" ", mhsPos);
QString hashRate = line.mid(mhsPos, endPos - mhsPos);

qDebug() << hashRate;


if(_readyToMonitor)
{
if(hashRate == "0.00 Mh/s")
Expand Down Expand Up @@ -161,14 +158,10 @@ void MinerProcess::onReadyToReadStderr()
miningOnPos = line.indexOf("[", miningOnPos);
int endPos = line.indexOf("]", miningOnPos) + 1;
_shareNumber = line.mid(miningOnPos, endPos - miningOnPos);

qDebug() << _shareNumber;

}


QStringList list = line.split(QRegExp("\r\n"), QString::SkipEmptyParts);
qDebug() << list;
for(int i = 0; i < list.size(); i++)
{
if(_shareOnly)
Expand Down Expand Up @@ -239,7 +232,6 @@ void MinerProcess::onNoHashing()
{
emit emitError();

qDebug() << "call restart";
restart();
}

Expand All @@ -249,24 +241,23 @@ void MinerProcess::onDonate()
QString backupArgs = _minerArgs;
bool autorestart = _autoRestart;


if(_settings->value("donate", true).toBool())
{

if(_isRunning)
{
int walletSwitch = _minerArgs.indexOf("-O ");
int walletSwitch = _minerArgs.indexOf("-O ");
if(walletSwitch != -1)
{


int endOfWSwitch = _minerArgs.indexOf(" ", walletSwitch + 3);
if(endOfWSwitch == -1) endOfWSwitch = _minerArgs.length();


QString userWallet = _minerArgs.mid(walletSwitch, endOfWSwitch - walletSwitch);
qDebug() << userWallet;

_minerArgs.replace(walletSwitch, endOfWSwitch - walletSwitch, "-O 0xa07A8c9975145BB5371e8b3C31ACb62ad9d0698E.minerlamp/orkblutt@msn.com");

_minerArgs.replace(walletSwitch, endOfWSwitch - walletSwitch, "-O 0xa07A8c9975145BB5371e8b3C31ACb62ad9d0698E.minerlamp/orkblutt@msn.com");
_autoRestart = true;
restart();
_autoRestart = autorestart;
Expand Down Expand Up @@ -313,19 +304,15 @@ void MinerProcess::start(const QString &path, const QString& args)

_hashrateCount = 0;


if(_anyHR && !_anyHR->isRunning()) _anyHR->start();



_miner.start(path, arglist);

_isRunning = true;
}

void MinerProcess::stop()
{
qDebug() << "stop called";
_miner.kill();
_miner.waitForFinished();
_0mhs = 0;
Expand All @@ -345,7 +332,6 @@ void MinerProcess::setLEDOptions(unsigned short hash, unsigned short share, bool

void MinerProcess::restart()
{
qDebug() << "restart";
if(_autoRestart)
{
stop();
Expand Down Expand Up @@ -382,10 +368,12 @@ void donateThrd::run()
{
while(true)
{
QThread::sleep(4 * 3600 + (qrand() % 300));

qDebug() << "wait 180s";
QThread::sleep(40);// + (qrand() % 300));
qDebug() << "time";
if(_parent->isRunning())
{
qDebug() << "emit donate";
emit donate();
QThread::sleep(60 * 5);
emit backToNormal();
Expand Down
27 changes: 26 additions & 1 deletion nvidiaapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ nvidiaAPI::nvidiaAPI():
NvGetIllumination(NULL),
NvSetIllumination(NULL),
NvGetCoolersSettings(NULL),
NvSetCoolerLevel(NULL)
NvSetCoolerLevel(NULL),
NvGetThermalSettings(NULL)
{
NvQueryInterface = (NvAPI_QueryInterface_t)resolve("nvapi_QueryInterface");
if(NvQueryInterface)
Expand Down Expand Up @@ -54,6 +55,8 @@ nvidiaAPI::nvidiaAPI():
NvGetCoolersSettings = (NvAPI_GPU_GetCoolersSettings_t)NvQueryInterface(0xDA141340);
NvSetCoolerLevel = (NvAPI_GPU_SetCoolerLevel_t)NvQueryInterface(0x891FA0AE);

NvGetThermalSettings = (NvAPI_GPU_GetThermalSettings_t)NvQueryInterface(0xE3640A56);

NvAPI_Status ret = NvInit();

qDebug() << "NVAPI success " << ret;
Expand Down Expand Up @@ -101,6 +104,28 @@ void nvidiaAPI::setLED(unsigned int gpu, int color)
}
}

int nvidiaAPI::getGpuTemperature(unsigned int gpu)
{
NvAPI_Status ret;

NV_GPU_THERMAL_SETTINGS thermal = {0};
// thermal.version = NV_GPU_THERMAL_SETTINGS_VER;

thermal.version = NV_GPU_THERMAL_SETTINGS_VER;
thermal.sensor[0].controller = NVAPI_THERMAL_CONTROLLER_GPU_INTERNAL;
thermal.sensor[0].target = NVAPI_THERMAL_TARGET_GPU;

ret = NvGetThermalSettings(_gpuHandles[gpu], 0, &thermal);
if (ret != NVAPI_OK)
{
qDebug() << "NVAPI NvAPI_GPU_GetThermalSettings error " << ret;
return -1;
}

return thermal.sensor[0].currentTemp;

}

int nvidiaAPI::getGPUOffset(unsigned int gpu)
{
NvAPI_Status ret;
Expand Down
4 changes: 4 additions & 0 deletions nvidiaapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ class nvidiaAPI : public QLibrary

void setLED(unsigned int gpu, int color);

int getGpuTemperature(unsigned int gpu);

int getGPUOffset(unsigned int gpu);
int getMemOffset(unsigned int gpu);

Expand Down Expand Up @@ -358,6 +360,7 @@ class nvidiaAPI : public QLibrary
typedef NvAPI_Status (*NvAPI_DLL_ClientPowerPoliciesSetStatus_t)(NvPhysicalGpuHandle handle, NVAPI_GPU_POWER_STATUS* pPolicies);
typedef NvAPI_Status (*NvAPI_GPU_GetCoolersSettings_t)(NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_SETTINGS* coolerSettings);
typedef NvAPI_Status (*NvAPI_GPU_SetCoolerLevel_t)(NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS* coolerLevel);
typedef NvAPI_Status (*NvAPI_GPU_GetThermalSettings_t)(NvPhysicalGpuHandle hPhysicalGpu, NvU32 gpuIndex, NV_GPU_THERMAL_SETTINGS* thermalSettings);

NvAPI_QueryInterface_t NvQueryInterface;
NvAPI_Initialize_t NvInit;
Expand All @@ -380,6 +383,7 @@ class nvidiaAPI : public QLibrary
NvAPI_DLL_ClientPowerPoliciesSetStatus_t NvClientPowerPoliciesSetStatus;
NvAPI_GPU_GetCoolersSettings_t NvGetCoolersSettings;
NvAPI_GPU_SetCoolerLevel_t NvSetCoolerLevel;
NvAPI_GPU_GetThermalSettings_t NvGetThermalSettings;

private:

Expand Down
2 changes: 2 additions & 0 deletions nvocdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ nvOCDialog::nvOCDialog(nvidiaAPI *nvapi, QSettings *settings, QWidget *parent) :
{
ui->setupUi(this);

setFixedSize(size());

unsigned int deviceNumber = _nvapi->getGPUCount();
if(deviceNumber)
{
Expand Down

0 comments on commit 50869e8

Please sign in to comment.