mirror of
https://github.com/eliboa/TegraRcmGUI.git
synced 2024-12-29 11:36:02 +00:00
driver install
settings tab autoRCM tool
This commit is contained in:
parent
bef72f5cd0
commit
44c4a7fb0d
30 changed files with 681 additions and 82 deletions
|
@ -5,6 +5,7 @@ CONFIG += c++11
|
|||
|
||||
RC_ICONS = res/TegraRcmGUI.ico
|
||||
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any Qt feature that has been marked deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
|
@ -22,6 +23,7 @@ SOURCES += \
|
|||
main.cpp \
|
||||
qkourou.cpp \
|
||||
qpayload.cpp \
|
||||
qsettings.cpp \
|
||||
qtools.cpp \
|
||||
qutils.cpp \
|
||||
tegrarcmgui.cpp
|
||||
|
@ -33,6 +35,7 @@ HEADERS += \
|
|||
kourou/usb_command.h \
|
||||
qkourou.h \
|
||||
qpayload.h \
|
||||
qsettings.h \
|
||||
qtools.h \
|
||||
qutils.h \
|
||||
rcm_device.h \
|
||||
|
@ -41,15 +44,28 @@ HEADERS += \
|
|||
|
||||
FORMS += \
|
||||
qpayload.ui \
|
||||
qsettings.ui \
|
||||
qtools.ui \
|
||||
tegrarcmgui.ui
|
||||
|
||||
TRANSLATIONS = languages/tegrarcmgui_fr.ts
|
||||
|
||||
LIBS += -L$$PWD/../../../../../../../libusbK-dev-kit/bin/lib/amd64/ -llibusbK
|
||||
ARCH = 32
|
||||
#ARCH = 64
|
||||
|
||||
contains( ARCH, 64 ) {
|
||||
LIBS += -L$$PWD/../../../../../../../libusbK-dev-kit/bin/lib/amd64/ -llibusbK
|
||||
}
|
||||
contains( ARCH, 32 ) {
|
||||
LIBS += -L$$PWD/../../../../../../../libusbK-dev-kit/bin/lib/x86/ -llibusbK
|
||||
}
|
||||
INCLUDEPATH += $$PWD/../../../../../../../libusbK-dev-kit/includes
|
||||
DEPENDPATH += $$PWD/../../../../../../../libusbK-dev-kit/includes
|
||||
|
||||
|
||||
|
||||
LIBS += -lsetupapi
|
||||
|
||||
RESOURCES += \
|
||||
qresources.qrc
|
||||
|
||||
|
|
Binary file not shown.
|
@ -527,6 +527,8 @@ void on_RebootRCMCommand()
|
|||
clock_halt_bpmp();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool get_autoRCM_state(bool *state)
|
||||
{
|
||||
if(!initialize_mount(NULL, 1))
|
||||
|
@ -600,6 +602,12 @@ bool set_autoRCM_state(bool autoRCM)
|
|||
return true;
|
||||
}
|
||||
|
||||
void on_setAutoRcmCommand(bool state)
|
||||
{
|
||||
bool res = set_autoRCM_state(state);
|
||||
send_response((const void*)&res, sizeof(bool)); // Notify caller
|
||||
}
|
||||
|
||||
void on_getDeviceInfoCommand(FATFS *fs)
|
||||
{
|
||||
// Init a device info struct
|
||||
|
@ -636,10 +644,8 @@ void on_getDeviceInfoCommand(FATFS *fs)
|
|||
di.emmc_fs_type = fs->fs_type;
|
||||
di.emmc_fs_cl_size = fs->csize;
|
||||
di.emmc_fs_last_cl = fs->n_fatent - 2;
|
||||
printk("di.emmc_fs_last_cl = %lu\n", emmc_fs_last_cl);
|
||||
FATFS *ffs;
|
||||
f_getfree("", &di.emmc_fs_free_cl, &ffs);
|
||||
printk("di.emmc_fs_free_cl = %lu\n", di.emmc_fs_free_cl);
|
||||
FILINFO fno;
|
||||
di.cfw_sxos = (f_stat("boot.dat", &fno) == FR_OK);
|
||||
di.cbl_hekate = (f_stat("bootloader/hekate_ipl.ini", &fno) == FR_OK);
|
||||
|
@ -753,19 +759,22 @@ int main(void)
|
|||
break;
|
||||
case WRITE_SD_FILE :
|
||||
on_WriteSDFileCommand();
|
||||
break;
|
||||
|
||||
break;
|
||||
case PUSH_PAYLOAD :
|
||||
on_PushPayloadCommand();
|
||||
break;
|
||||
|
||||
break;
|
||||
case REBOOT_RCM :
|
||||
on_RebootRCMCommand();
|
||||
break;
|
||||
|
||||
case GET_DEVICE_INFO:
|
||||
on_getDeviceInfoCommand(&fs);
|
||||
break;
|
||||
case SET_AUTORCM_ON:
|
||||
on_setAutoRcmCommand(true);
|
||||
break;
|
||||
case SET_AUTORCM_OFF:
|
||||
on_setAutoRcmCommand(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,9 @@ typedef enum _UC_CommandType
|
|||
PUSH_PAYLOAD,
|
||||
REBOOT_RCM,
|
||||
GET_DEVICE_INFO,
|
||||
GET_STATUS
|
||||
GET_STATUS,
|
||||
SET_AUTORCM_ON,
|
||||
SET_AUTORCM_OFF
|
||||
|
||||
} UC_CommandType;
|
||||
|
||||
|
|
|
@ -199,3 +199,22 @@ bool Kourou::rebootToRcm()
|
|||
|
||||
return response;
|
||||
}
|
||||
|
||||
bool Kourou::setAutoRcmEnabled(bool state)
|
||||
{
|
||||
if (!arianeIsReady_sync())
|
||||
return false;
|
||||
|
||||
UC_Header uc;
|
||||
uc.command = state ? SET_AUTORCM_ON : SET_AUTORCM_OFF;
|
||||
// Send command
|
||||
write((const u8*)&uc, sizeof(uc));
|
||||
|
||||
// Get response
|
||||
bool response = false;
|
||||
if (!readResponse(&response, sizeof(bool)))
|
||||
return false;
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ typedef enum _KRESULT : DWORD
|
|||
{
|
||||
RCM_REBOOT_FAILED = 0x00F,
|
||||
ARIANE_NOT_READY = 0x010,
|
||||
WRONG_PARAM_GENERIC = 0x011
|
||||
WRONG_PARAM_GENERIC = 0x011,
|
||||
FAILED_TO_SET_AUTORCM = 0x012
|
||||
|
||||
} KRESULT;
|
||||
|
||||
|
@ -48,6 +49,7 @@ public:
|
|||
bool arianeIsReady_sync();
|
||||
void setArianeReady(bool b) { m_ariane_ready = b; }
|
||||
bool rebootToRcm();
|
||||
bool setAutoRcmEnabled(bool state);
|
||||
|
||||
private:
|
||||
int sendBinPackets(char* buffer, u32 len);
|
||||
|
|
|
@ -46,12 +46,19 @@ bool RcmDevice::initDevice(KLST_DEVINFO_HANDLE deviceInfo)
|
|||
return false;
|
||||
};
|
||||
|
||||
// Load driver API
|
||||
if (!m_usbAPI_loaded)
|
||||
{
|
||||
LibK_LoadDriverAPI(&m_usbApi, KUSB_DRVID_LIBUSBK);
|
||||
m_usbAPI_loaded = true;
|
||||
}
|
||||
|
||||
if (deviceInfo != nullptr && (deviceInfo->Common.Vid != RCM_VID && deviceInfo->Common.Pid != RCM_PID))
|
||||
return error(WRONG_DEVICE_VID_PID);
|
||||
|
||||
KLST_DEVINFO_HANDLE tmp_devInfo = deviceInfo != nullptr ? deviceInfo : m_devInfo;
|
||||
if(tmp_devInfo == nullptr && !getPluggedDevice(&tmp_devInfo))
|
||||
return error(DEVICE_NOT_FOUND);
|
||||
return error(DEVICE_NOT_FOUND);
|
||||
|
||||
// New device already initialized & connected, return ready state (no need to load anything else)
|
||||
if (m_devInfo != nullptr && m_devStatus == CONNECTED && m_devInfo->DeviceID == tmp_devInfo->DeviceID)
|
||||
|
@ -62,14 +69,7 @@ bool RcmDevice::initDevice(KLST_DEVINFO_HANDLE deviceInfo)
|
|||
m_devIsInitialized = false;
|
||||
|
||||
if (m_devInfo->DriverID != KUSB_DRVID_LIBUSBK)
|
||||
return error(MISSING_LIBUSBK_DRIVER);
|
||||
|
||||
// Load driver API
|
||||
if (!m_usbAPI_loaded)
|
||||
{
|
||||
LibK_LoadDriverAPI(&m_usbApi, KUSB_DRVID_LIBUSBK);
|
||||
m_usbAPI_loaded = true;
|
||||
}
|
||||
return error(MISSING_LIBUSBK_DRIVER);
|
||||
|
||||
// Init USB handle
|
||||
m_usbApi.Free(m_usbHandle); // Free previous usb handle
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
#define RCMDEVICE_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <setupapi.h>
|
||||
#include <stdio.h>
|
||||
#include <tchar.h>
|
||||
#include "libusbk_int.h"
|
||||
#include <string>
|
||||
#include "../../types.h"
|
||||
|
@ -147,7 +150,7 @@ private:
|
|||
bool m_usbAPI_loaded = false;
|
||||
DEVICE_STATUS m_devStatus;
|
||||
|
||||
private:
|
||||
private:
|
||||
bool getPluggedDevice(KLST_DEVINFO_HANDLE *devinfo);
|
||||
int switchToHighBuffer();
|
||||
u32 getCurrentBufferAddress() const { return m_currentBuffer == 0 ? 0x40005000u : 0x40009000u; }
|
||||
|
|
|
@ -29,7 +29,9 @@ typedef enum _UC_CommandType : u8
|
|||
PUSH_PAYLOAD,
|
||||
REBOOT_RCM,
|
||||
GET_DEVICE_INFO,
|
||||
GET_STATUS
|
||||
GET_STATUS,
|
||||
SET_AUTORCM_ON,
|
||||
SET_AUTORCM_OFF
|
||||
|
||||
} UC_CommandType;
|
||||
|
||||
|
|
1
main.cpp
1
main.cpp
|
@ -3,7 +3,6 @@
|
|||
#include <QApplication>
|
||||
#include <QTranslator>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
|
|
78
qkourou.cpp
78
qkourou.cpp
|
@ -11,10 +11,11 @@ QKourou::QKourou(QWidget *parent, Kourou* device, TegraRcmGUI* gui) : QWidget(pa
|
|||
connect(this, SIGNAL(clb_error(int)), parent, SLOT(error(int)));
|
||||
connect(this, SIGNAL(clb_deviceStateChange()), parent, SLOT(on_deviceStateChange()));
|
||||
connect(this, SIGNAL(clb_finished(int)), parent, SLOT(on_Kourou_finished(int)));
|
||||
connect(this, SIGNAL(pushMessage(QString)), parent, SLOT(pushMessage(QString)));
|
||||
}
|
||||
|
||||
void QKourou::initDevice(bool silent, KLST_DEVINFO_HANDLE deviceInfo)
|
||||
{
|
||||
{
|
||||
if (!waitUntilUnlock())
|
||||
return;
|
||||
|
||||
|
@ -99,7 +100,7 @@ DWORD QKourou::autoInject()
|
|||
|
||||
void QKourou::getDeviceInfo()
|
||||
{
|
||||
qDebug() << "QKourou::getDeviceInfo() execute in " << QThread::currentThreadId();
|
||||
//qDebug() << "QKourou::getDeviceInfo() execute in " << QThread::currentThreadId();
|
||||
|
||||
if (!waitUntilUnlock())
|
||||
return;
|
||||
|
@ -117,6 +118,19 @@ void QKourou::getDeviceInfo()
|
|||
|
||||
}
|
||||
|
||||
void QKourou::setAutoRcmEnabled(bool state)
|
||||
{
|
||||
if (!waitUntilUnlock())
|
||||
return;
|
||||
|
||||
setLockEnabled(true);
|
||||
bool res = m_device->setAutoRcmEnabled(state);
|
||||
setLockEnabled(false);
|
||||
|
||||
if (!res)
|
||||
emit clb_error(FAILED_TO_SET_AUTORCM);
|
||||
}
|
||||
|
||||
void QKourou::hack(const char* payload_path, u8 *payload_buff, u32 buff_size)
|
||||
{
|
||||
if (!waitUntilUnlock())
|
||||
|
@ -193,7 +207,6 @@ bool QKourou::waitUntilRcmReady(uint timeout_s)
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool QKourou::waitUntilInit(uint timeout_s)
|
||||
{
|
||||
qint64 begin_timestamp = QDateTime::currentSecsSinceEpoch();
|
||||
|
@ -204,3 +217,62 @@ bool QKourou::waitUntilInit(uint timeout_s)
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void QKourou::initNoDriverDeviceLookUpLoop()
|
||||
{
|
||||
connect(this, SIGNAL(clb_driverMissing()), m_gui->settingsTab, SLOT(on_driverMissing()));
|
||||
QTimer *lookup = new QTimer(this);
|
||||
connect(lookup, SIGNAL(timeout()), this, SLOT(noDriverDeviceLookUp()));
|
||||
lookup->start(1000); // Every second
|
||||
m_askForDriverInstall = true;
|
||||
m_APX_device_reconnect = true;
|
||||
}
|
||||
|
||||
void QKourou::noDriverDeviceLookUp()
|
||||
{
|
||||
if (m_device->getStatus() == CONNECTED)
|
||||
return;
|
||||
|
||||
unsigned index;
|
||||
HDEVINFO hDevInfo;
|
||||
SP_DEVINFO_DATA DeviceInfoData;
|
||||
TCHAR HardwareID[1024];
|
||||
bool found = false;
|
||||
// List all connected USB devices
|
||||
hDevInfo = SetupDiGetClassDevs(nullptr, TEXT("USB"), nullptr, DIGCF_PRESENT | DIGCF_ALLCLASSES);
|
||||
for (index = 0; ; index++)
|
||||
{
|
||||
DeviceInfoData.cbSize = sizeof(DeviceInfoData);
|
||||
if (!SetupDiEnumDeviceInfo(hDevInfo, index, &DeviceInfoData))
|
||||
break;
|
||||
|
||||
SetupDiGetDeviceRegistryProperty(hDevInfo, &DeviceInfoData, SPDRP_HARDWAREID, nullptr, (BYTE*)HardwareID, sizeof(HardwareID), nullptr);
|
||||
if (_tcsstr(HardwareID, _T("VID_0955&PID_7321")))
|
||||
{
|
||||
// device found, check driver
|
||||
BYTE driverPath[256], zeroBuffer[256];
|
||||
memset(driverPath, 0, 256);
|
||||
memset(zeroBuffer, 0, 256);
|
||||
SetupDiGetDeviceRegistryProperty(hDevInfo, &DeviceInfoData, SPDRP_DRIVER, nullptr, driverPath, 256, nullptr);
|
||||
if (!memcmp(driverPath, zeroBuffer, 256))
|
||||
{
|
||||
found = true;
|
||||
// Driver not found
|
||||
if (!m_askForDriverInstall)
|
||||
{
|
||||
if (m_APX_device_reconnect)
|
||||
emit pushMessage(tr("Device detected but driver is missing\nInstall driver from SETTINGS tab"));
|
||||
}
|
||||
else
|
||||
{
|
||||
emit clb_driverMissing();
|
||||
m_askForDriverInstall = false;
|
||||
}
|
||||
m_APX_device_reconnect = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
m_APX_device_reconnect = true;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,8 @@ private:
|
|||
TegraRcmGUI *m_gui;
|
||||
bool m_locked = false;
|
||||
bool m_force_lock = false;
|
||||
bool m_askForDriverInstall = true;
|
||||
bool m_APX_device_reconnect = true;
|
||||
QWidget *parent;
|
||||
std::string tmp_string;
|
||||
void hack(const char* payload_path, u8 *payload_buff, u32 buff_size);
|
||||
|
@ -54,14 +56,17 @@ public slots:
|
|||
void getDeviceInfo();
|
||||
void hack(const char* payload_path);
|
||||
void hack(u8 *payload_buff, u32 buff_size);
|
||||
|
||||
void initNoDriverDeviceLookUpLoop();
|
||||
void noDriverDeviceLookUp();
|
||||
void setAutoRcmEnabled(bool state);
|
||||
|
||||
signals:
|
||||
void clb_deviceInfo(UC_DeviceInfo di);
|
||||
void clb_error(int error);
|
||||
void clb_deviceStateChange();
|
||||
void clb_finished(int res);
|
||||
|
||||
void clb_driverMissing();
|
||||
void pushMessage(QString);
|
||||
};
|
||||
|
||||
#endif // QKOUROU_H
|
||||
|
|
|
@ -56,11 +56,12 @@ QPayloadWidget::QPayloadWidget(TegraRcmGUI *parent) : QWidget(parent)
|
|||
buttons.at(i)->setCursor(Qt::PointingHandCursor);
|
||||
|
||||
}
|
||||
this->setStyleSheet(GetStyleSheetFromResFile(":/res/QMainWindow.qss"));
|
||||
ui->payload_tableView->setStyleSheet(GetStyleSheetFromResFile(":/res/QTableView.qss"));
|
||||
ui->payloadFrame->setStyleSheet(GetStyleSheetFromResFile(":/res/QFrame_box02.qss"));
|
||||
|
||||
// Buttons
|
||||
Switch *_switch = new Switch(parent->m_kourou->autoInjectPayload ? true : false, 70);
|
||||
Switch *_switch = new Switch(parent->userSettings->value("autoInject").toBool() ? true : false, 50);
|
||||
ui->horizontalLayout->addWidget(_switch);
|
||||
connect(_switch, SIGNAL(clicked()), this, SLOT(on_autoInject_toggled()));
|
||||
//ui->injectPayloadBtn->setCursor(Qt::PointingHandCursor);
|
||||
|
|
|
@ -108,8 +108,8 @@ color: rgb(255, 255, 255);</string>
|
|||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>250</x>
|
||||
<y>50</y>
|
||||
<x>270</x>
|
||||
<y>46</y>
|
||||
<width>81</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
|
@ -128,9 +128,9 @@ color: rgb(255, 255, 255);</string>
|
|||
<widget class="QWidget" name="horizontalLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>340</x>
|
||||
<x>360</x>
|
||||
<y>40</y>
|
||||
<width>71</width>
|
||||
<width>51</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
|
|
@ -13,5 +13,7 @@
|
|||
<file>res/QFrame_box02.qss</file>
|
||||
<file>res/delete.ico</file>
|
||||
<file>res/add.ico</file>
|
||||
<file>res/QLabel_warning.qss</file>
|
||||
<file>res/QLabel_title02.qss</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
62
qsettings.cpp
Normal file
62
qsettings.cpp
Normal file
|
@ -0,0 +1,62 @@
|
|||
#include "qsettings.h"
|
||||
#include "ui_qsettings.h"
|
||||
#include "qutils.h"
|
||||
#include <QProcess>
|
||||
|
||||
qSettings::qSettings(TegraRcmGUI *parent) : QWidget(parent),
|
||||
ui(new Ui::qSettings), parent(parent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
m_kourou = parent->m_kourou;
|
||||
m_device = &parent->m_device;
|
||||
|
||||
/// Stylesheets
|
||||
// Apply stylesheet to all buttons
|
||||
QString btnSs = GetStyleSheetFromResFile(":/res/QPushButton.qss");
|
||||
auto buttons = this->findChildren<QPushButton*>();
|
||||
for (int i = 0; i < buttons.count(); i++)
|
||||
{
|
||||
buttons.at(i)->setStyleSheet(btnSs);
|
||||
buttons.at(i)->setCursor(Qt::PointingHandCursor);
|
||||
}
|
||||
}
|
||||
|
||||
qSettings::~qSettings()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void qSettings::on_driverMissing()
|
||||
{
|
||||
QString message(tr("The required APX device driver is missing.\nDo you wan to install it now ?"));
|
||||
if(QMessageBox::question(this, "Warning", message, QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
|
||||
{
|
||||
on_installDriverButton_clicked();
|
||||
}
|
||||
}
|
||||
|
||||
void qSettings::on_installDriverButton_clicked()
|
||||
{
|
||||
QString q_path = QDir(".").absolutePath() + "/apx_driver/InstallDriver.exe";
|
||||
|
||||
QFile file(q_path);
|
||||
if (!file.exists())
|
||||
return;
|
||||
|
||||
std::wstring w_path = q_path.toStdWString();
|
||||
LPCWSTR path = (const wchar_t*) w_path.c_str();
|
||||
SHELLEXECUTEINFO shExInfo = { 0 };
|
||||
shExInfo.cbSize = sizeof(shExInfo);
|
||||
shExInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
|
||||
shExInfo.hwnd = nullptr;
|
||||
shExInfo.lpVerb = _T("runas");
|
||||
shExInfo.lpFile = path;
|
||||
shExInfo.lpDirectory = nullptr;
|
||||
shExInfo.nShow = SW_SHOW;
|
||||
shExInfo.hInstApp = nullptr;
|
||||
|
||||
if (ShellExecuteEx(&shExInfo))
|
||||
{
|
||||
CloseHandle(shExInfo.hProcess);
|
||||
}
|
||||
}
|
38
qsettings.h
Normal file
38
qsettings.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
#ifndef QSETTINGSU_H
|
||||
#define QSETTINGSU_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "tegrarcmgui.h"
|
||||
|
||||
class TegraRcmGUI;
|
||||
class Kourou;
|
||||
class QKourou;
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui {
|
||||
class qSettings;
|
||||
}
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class qSettings : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit qSettings(TegraRcmGUI *parent = nullptr);
|
||||
~qSettings();
|
||||
|
||||
public slots:
|
||||
void on_driverMissing();
|
||||
private slots:
|
||||
void on_installDriverButton_clicked();
|
||||
|
||||
private:
|
||||
Ui::qSettings *ui;
|
||||
TegraRcmGUI *parent;
|
||||
QKourou *m_kourou;
|
||||
Kourou *m_device;
|
||||
|
||||
};
|
||||
|
||||
#endif // QSETTINGSU_H
|
32
qsettings.ui
Normal file
32
qsettings.ui
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>qSettings</class>
|
||||
<widget class="QWidget" name="qSettings">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="installDriverButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>80</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Install driver</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
68
qtools.cpp
68
qtools.cpp
|
@ -1,14 +1,76 @@
|
|||
#include "qtools.h"
|
||||
#include "ui_qtools.h"
|
||||
|
||||
qTools::qTools(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::qTools)
|
||||
qTools::qTools(TegraRcmGUI *parent) : QWidget(parent),
|
||||
ui(new Ui::qTools), parent(parent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
m_kourou = parent->m_kourou;
|
||||
m_device = &parent->m_device;
|
||||
connect(this, SIGNAL(error(int)), parent, SLOT(error(int)));
|
||||
|
||||
/// Stylesheets
|
||||
// Apply stylesheet to all buttons
|
||||
QString btnSs = GetStyleSheetFromResFile(":/res/QPushButton.qss");
|
||||
auto buttons = this->findChildren<QPushButton*>();
|
||||
for (int i = 0; i < buttons.count(); i++)
|
||||
{
|
||||
buttons.at(i)->setStyleSheet(btnSs);
|
||||
buttons.at(i)->setCursor(Qt::PointingHandCursor);
|
||||
}
|
||||
|
||||
ui->autoRcmFrame->setStyleSheet(GetStyleSheetFromResFile(":/res/QFrame_box02.qss"));
|
||||
ui->genricToolFrame->setStyleSheet(GetStyleSheetFromResFile(":/res/QFrame_box02.qss"));
|
||||
ui->autoRcm_warningFrame->setStyleSheet(GetStyleSheetFromResFile(":/res/QLabel_warning.qss"));
|
||||
ui->autoRcmTitleLbl->setStyleSheet(GetStyleSheetFromResFile(":/res/QLabel_title02.qss"));
|
||||
|
||||
// Buttons
|
||||
autoRCM_switch = new Switch(false, 50);
|
||||
ui->autoRcmLayout->addWidget(autoRCM_switch);
|
||||
connect(autoRCM_switch, SIGNAL(clicked()), this, SLOT(on_autoRcmSwitchToggled()));
|
||||
|
||||
Switch *_switch2 = new Switch(false, 50);
|
||||
ui->genricToolLayout->addWidget(_switch2);
|
||||
//connect(_switch, SIGNAL(clicked()), this, SLOT(on_autoInject_toggled()));
|
||||
}
|
||||
|
||||
qTools::~qTools()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void qTools::on_deviceStateChange()
|
||||
{
|
||||
//autoRcm_arianeLbl
|
||||
|
||||
if (!m_device->arianeIsReady() || !parent->isDeviceInfoAvailable())
|
||||
{
|
||||
QString label;
|
||||
if (m_device->arianeIsReady())
|
||||
label.append(tr("Waiting for Ariane response"));
|
||||
else
|
||||
{
|
||||
label.append(tr("Ariane needs to be loaded!\n"));
|
||||
label.append(m_kourou->autoLaunchAriane ? tr("Boot device to RCM") : tr("Enable Ariane autoboot first"));
|
||||
}
|
||||
ui->autoRcm_warningLbl->setText(label);
|
||||
ui->autoRcm_warningFrame->show();
|
||||
autoRCM_switch->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->autoRcm_warningFrame->hide();
|
||||
autoRCM_switch->show();
|
||||
}
|
||||
}
|
||||
|
||||
void qTools::on_autoRcmSwitchToggled()
|
||||
{
|
||||
if (!m_device->arianeIsReady())
|
||||
{
|
||||
emit error(ARIANE_NOT_READY);
|
||||
return;
|
||||
}
|
||||
|
||||
QtConcurrent::run(m_kourou, &QKourou::setAutoRcmEnabled, autoRCM_switch->getState());
|
||||
}
|
||||
|
|
30
qtools.h
30
qtools.h
|
@ -2,21 +2,41 @@
|
|||
#define QTOOLS_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QObject>
|
||||
#include "tegrarcmgui.h"
|
||||
#include "qutils.h"
|
||||
|
||||
namespace Ui {
|
||||
class qTools;
|
||||
}
|
||||
class TegraRcmGUI;
|
||||
class Kourou;
|
||||
class QKourou;
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class qTools; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class qTools : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit qTools(QWidget *parent = nullptr);
|
||||
explicit qTools(TegraRcmGUI *parent = nullptr);
|
||||
~qTools();
|
||||
Switch *autoRCM_switch;
|
||||
|
||||
private:
|
||||
Ui::qTools *ui;
|
||||
TegraRcmGUI *parent;
|
||||
QKourou *m_kourou;
|
||||
Kourou *m_device;
|
||||
|
||||
public slots:
|
||||
void on_deviceStateChange();
|
||||
|
||||
private slots:
|
||||
void on_autoRcmSwitchToggled();
|
||||
|
||||
signals:
|
||||
void error(int);
|
||||
|
||||
};
|
||||
|
||||
#endif // QTOOLS_H
|
||||
|
|
185
qtools.ui
185
qtools.ui
|
@ -6,25 +6,192 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>496</width>
|
||||
<height>404</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QFrame" name="autoRcmFrame">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>30</y>
|
||||
<width>47</width>
|
||||
<height>14</height>
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
<width>211</width>
|
||||
<height>121</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="verticalLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<y>80</y>
|
||||
<width>51</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="autoRcmLayout"/>
|
||||
</widget>
|
||||
<widget class="QLabel" name="autoRcmTitleLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>191</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Toggle autoRCM</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="autoRcmDescLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>30</y>
|
||||
<width>201</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">font: italic 9pt "Calibri";</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>autoRCM is a controlled brick of BOOT0
|
||||
partition. Enabling autoRCM will force
|
||||
your Switch to boot straight to RCM</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignJustify|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QFrame" name="autoRcm_warningFrame">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>79</y>
|
||||
<width>191</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<widget class="QLabel" name="autoRcm_warningLbl">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>191</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QFrame" name="genricToolFrame">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>20</y>
|
||||
<width>211</width>
|
||||
<height>121</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="verticalLayoutWidget_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<y>80</y>
|
||||
<width>51</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="genricToolLayout"/>
|
||||
</widget>
|
||||
<widget class="QLabel" name="genricToolTitleLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>241</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">font: 75 11pt "Calibri";</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Another Tool:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="genricToolDescLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>30</y>
|
||||
<width>201</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">font: italic 9pt "Calibri";</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>blabababla</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="genricToolStateLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>6</x>
|
||||
<y>79</y>
|
||||
<width>141</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Tool state:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
|
@ -85,7 +85,7 @@ void Switch::paintEvent(QPaintEvent *e) {
|
|||
}
|
||||
}
|
||||
|
||||
void Switch::toggle(bool state)
|
||||
void Switch::toggle()
|
||||
{
|
||||
int toffset = offset();
|
||||
_switch = _switch ? false : true;
|
||||
|
@ -105,7 +105,7 @@ void Switch::toggle(bool state)
|
|||
|
||||
void Switch::mouseReleaseEvent(QMouseEvent *e) {
|
||||
if (e->button() & Qt::LeftButton) {
|
||||
toggle(_switch);
|
||||
toggle();
|
||||
}
|
||||
QAbstractButton::mouseReleaseEvent(e);
|
||||
}
|
||||
|
|
3
qutils.h
3
qutils.h
|
@ -42,8 +42,9 @@ public:
|
|||
}
|
||||
|
||||
bool isActive() { return _switch; }
|
||||
bool getState() { return _switch; }
|
||||
void setState(bool value) { _switch = value; }
|
||||
void toggle(bool state);
|
||||
void toggle();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent*) override;
|
||||
|
|
5
res/QLabel_title02.qss
Normal file
5
res/QLabel_title02.qss
Normal file
|
@ -0,0 +1,5 @@
|
|||
QLabel
|
||||
{
|
||||
font: 75 10pt "Rubik";
|
||||
color: rgb(0, 150, 136);
|
||||
}
|
11
res/QLabel_warning.qss
Normal file
11
res/QLabel_warning.qss
Normal file
|
@ -0,0 +1,11 @@
|
|||
QFrame
|
||||
{
|
||||
border-radius: 5px;
|
||||
border:1px solid rgb(150, 35, 0);
|
||||
}
|
||||
|
||||
QLabel
|
||||
{
|
||||
font: 75 9pt "Calibri";
|
||||
color: rgb(150, 35, 0);
|
||||
}
|
|
@ -13,6 +13,11 @@ QToolTip
|
|||
background-color: rgb(30, 30, 30);
|
||||
color: rgb(255, 255, 255);
|
||||
}
|
||||
QMessageBox QLabel {
|
||||
QMessageBox QLabel
|
||||
{
|
||||
color: rgb(0, 0, 0);
|
||||
}
|
||||
QLabel
|
||||
{
|
||||
color: rgb(255, 255, 255);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
QTabWidget::pane
|
||||
{
|
||||
border-radius:10px;
|
||||
background-color: rgb(60, 60, 60);
|
||||
color: rgb(255, 255, 255);
|
||||
background-color: rgb(60, 60, 60);
|
||||
}
|
||||
QTabWidget::tab-bar
|
||||
{
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
QTableView
|
||||
{
|
||||
border-radius: 10px;
|
||||
alternate-background-color: rgb(188, 188, 188);
|
||||
background: rgb(240, 240, 240);
|
||||
selection-background-color: rgb(150, 0, 83);
|
||||
color: rgb(255, 255, 255);
|
||||
alternate-background-color: rgb(80, 80, 80);
|
||||
background: rgb(41, 41, 41);
|
||||
selection-background-color: rgb(30, 105, 98);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "ui_tegrarcmgui.h"
|
||||
#include "qutils.h"
|
||||
#include <QPoint>
|
||||
#include <Windows.h>
|
||||
|
||||
QMouseEvent MouseLeftButtonEvent(QEvent::MouseButtonPress, QPoint(0,0), Qt::LeftButton, nullptr, nullptr);
|
||||
|
||||
|
@ -32,6 +33,9 @@ TegraRcmGUI::TegraRcmGUI(QWidget *parent)
|
|||
// Init acces to builtin resources
|
||||
Q_INIT_RESOURCE(qresources);
|
||||
|
||||
// Load settings
|
||||
userSettings = new QSettings("nx", "TegraRcmGUI");
|
||||
|
||||
// Tray icon init
|
||||
trayIcon = new QSystemTrayIcon;
|
||||
trayIcon->setIcon(switchOffIcon);
|
||||
|
@ -39,22 +43,30 @@ TegraRcmGUI::TegraRcmGUI(QWidget *parent)
|
|||
connect(trayIcon, &QSystemTrayIcon::activated, this, &TegraRcmGUI::trayIconActivated);
|
||||
trayIconMenu = trayIcon->contextMenu();
|
||||
|
||||
// Load settings
|
||||
userSettings = new QSettings("nx", "TegraRcmGUI");
|
||||
|
||||
// Create a qKourou instance to invoke Kourou methods (asynchronously) using signals and slots
|
||||
m_kourou = new QKourou(this, &m_device, this);
|
||||
|
||||
m_kourou->autoLaunchAriane = userSettings->value("autoAriane").toBool();
|
||||
m_kourou->autoInjectPayload = userSettings->value("autoInject").toBool();
|
||||
|
||||
// Init tabs
|
||||
ui->tabWidget->tabBar()->setCursor(Qt::PointingHandCursor);
|
||||
ui->push_layout->setAlignment(Qt::AlignTop);
|
||||
ui->pushLayoutWidget->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
payloadTab = new QPayloadWidget(this);
|
||||
ui->tabWidget->addTab(payloadTab, tr("PAYLOAD"));
|
||||
toolsTab = new qTools(this);
|
||||
ui->tabWidget->addTab(toolsTab, tr("TOOLS"));
|
||||
settingsTab = new qSettings(this);
|
||||
ui->tabWidget->addTab(settingsTab, tr("SETTINGS"));
|
||||
|
||||
// Load builtin Ariane payload
|
||||
QFile file(":/ariane_bin");
|
||||
if (file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
m_kourou->ariane_bin = file.readAll();
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
// Init device at startup (in a concurrent thread)
|
||||
QtConcurrent::run(m_kourou, &QKourou::initDevice, true, nullptr);
|
||||
|
@ -74,7 +86,8 @@ TegraRcmGUI::TegraRcmGUI(QWidget *parent)
|
|||
devInfoTimer->start(60000*5); // Every 5 minutes
|
||||
QTimer *pushTimer = new QTimer(this);
|
||||
connect(pushTimer, SIGNAL(timeout()), this, SLOT(pushTimer()));
|
||||
pushTimer->start(1000); // Every minute
|
||||
pushTimer->start(1000); // Every second
|
||||
m_kourou->initNoDriverDeviceLookUpLoop();
|
||||
|
||||
|
||||
/// GUI inits
|
||||
|
@ -86,16 +99,6 @@ TegraRcmGUI::TegraRcmGUI(QWidget *parent)
|
|||
ui->statusBoxFrame->setStyleSheet(GetStyleSheetFromResFile(":/res/QFrame_box01.qss"));
|
||||
ui->deviceInfoBoxFrame->setStyleSheet(GetStyleSheetFromResFile(":/res/QFrame_box01.qss"));
|
||||
|
||||
// Init tabs
|
||||
ui->tabWidget->tabBar()->setCursor(Qt::PointingHandCursor);
|
||||
ui->push_layout->setAlignment(Qt::AlignTop);
|
||||
ui->pushLayoutWidget->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
|
||||
payloadTab = new QPayloadWidget(this);
|
||||
ui->tabWidget->addTab(payloadTab, tr("PAYLOAD"));
|
||||
toolsTab = new qTools(this);
|
||||
ui->tabWidget->addTab(toolsTab, tr("TOOLS"));
|
||||
|
||||
ui->closeAppBtn->setCursor(Qt::PointingHandCursor);
|
||||
connect(ui->closeAppBtn, SIGNAL(clicked()), this, SLOT(close()));
|
||||
|
||||
|
@ -136,19 +139,33 @@ void TegraRcmGUI::deviceInfoTimer()
|
|||
|
||||
void TegraRcmGUI::on_deviceStateChange()
|
||||
{
|
||||
ui->devStatusLbl_2->setText(m_device.getStatus() == CONNECTED ? tr("CONNECTED") : tr("DISCONNECTED"));
|
||||
ui->devStatusLbl_2->setText(tr("DEVICE STATUS"));
|
||||
ui->devStatusFrame->setStyleSheet(m_device.getStatus() == CONNECTED ? statusOnStyleSht : statusOffStyleSht);
|
||||
ui->rcmStatusLbl_2->setText(m_device.rcmIsReady() ? tr("READY") : tr("OFF"));
|
||||
QString arianeStatus;
|
||||
QString arianeStatus, arianeStyle;
|
||||
if (m_kourou->arianeIsLoading)
|
||||
{
|
||||
arianeStatus.append(tr("LOADING"));
|
||||
arianeStyle = statusOffStyleSht;
|
||||
}
|
||||
else if (m_device.arianeIsReady())
|
||||
{
|
||||
arianeStatus.append(tr("READY"));
|
||||
arianeStyle = statusOnStyleSht;
|
||||
}
|
||||
else
|
||||
{
|
||||
arianeStatus.append(tr("OFF"));
|
||||
arianeStyle = m_kourou->autoLaunchAriane ? statusOffRedStyleSht : statusOffStyleSht;
|
||||
}
|
||||
ui->arianeStatusLbl_2->setText(arianeStatus);
|
||||
ui->rcmStatusFrame->setStyleSheet(m_device.rcmIsReady() ? statusOnStyleSht : statusOffStyleSht);
|
||||
ui->arianeStatusFrame->setStyleSheet(m_device.arianeIsReady() ? statusOnStyleSht : statusOffStyleSht);
|
||||
QString style = statusOffRedStyleSht;
|
||||
if (m_device.arianeIsReady())
|
||||
style = statusOffStyleSht;
|
||||
else if (m_device.rcmIsReady())
|
||||
style = statusOnStyleSht;
|
||||
ui->rcmStatusFrame->setStyleSheet(style);
|
||||
ui->arianeStatusFrame->setStyleSheet(arianeStyle);
|
||||
if (!m_device.arianeIsReady())
|
||||
clearDeviceInfo();
|
||||
|
||||
|
@ -157,8 +174,11 @@ void TegraRcmGUI::on_deviceStateChange()
|
|||
else
|
||||
trayIcon->setIcon(switchOffIcon);
|
||||
|
||||
payloadTab->on_deviceStateChange();
|
||||
if (m_device.getStatus() != CONNECTED || !m_device.rcmIsReady())
|
||||
m_deviceInfoAvailable = false;
|
||||
|
||||
payloadTab->on_deviceStateChange();
|
||||
toolsTab->on_deviceStateChange();
|
||||
}
|
||||
|
||||
void TegraRcmGUI::on_autoLaunchAriane_toggled(bool value)
|
||||
|
@ -166,8 +186,15 @@ void TegraRcmGUI::on_autoLaunchAriane_toggled(bool value)
|
|||
m_kourou->autoLaunchAriane = !m_kourou->autoLaunchAriane;
|
||||
userSettings->setValue("autoAriane", m_kourou->autoLaunchAriane);
|
||||
|
||||
if (m_device.rcmIsReady() && m_kourou->autoLaunchAriane)
|
||||
on_deviceStateChange();
|
||||
|
||||
if (!m_kourou->autoLaunchAriane)
|
||||
return;
|
||||
|
||||
if (m_device.rcmIsReady())
|
||||
QtConcurrent::run(m_kourou, &QKourou::initDevice, true, nullptr);
|
||||
else if (!m_device.arianeIsReady())
|
||||
pushMessage((m_device.getStatus() == CONNECTED ? tr("Reboot") : tr("Boot")) + tr(" device to RCM to launch Ariane"));
|
||||
}
|
||||
|
||||
bool TegraRcmGUI::enableWidget(QWidget *widget, bool enable)
|
||||
|
@ -200,6 +227,12 @@ void TegraRcmGUI::clearDeviceInfo()
|
|||
|
||||
void TegraRcmGUI::on_deviceInfo_received(UC_DeviceInfo di)
|
||||
{
|
||||
if (!m_deviceInfoAvailable)
|
||||
{
|
||||
m_deviceInfoAvailable = true;
|
||||
toolsTab->on_deviceStateChange();
|
||||
}
|
||||
else m_deviceInfoAvailable = true;
|
||||
ui->batteryLbl->show();
|
||||
ui->burntFusesLbl1->show();
|
||||
ui->sdfsLbl1->show();
|
||||
|
@ -230,11 +263,27 @@ void TegraRcmGUI::on_deviceInfo_received(UC_DeviceInfo di)
|
|||
ui->fsTotSizeLbl2->setText("N/A");
|
||||
ui->fsFreeSpaceLbl2->setText("N/A");
|
||||
}
|
||||
|
||||
if (di.autoRCM != toolsTab->autoRCM_switch->isActive())
|
||||
toolsTab->autoRCM_switch->toggle();
|
||||
}
|
||||
|
||||
void TegraRcmGUI::error(int error)
|
||||
{
|
||||
QMessageBox::critical(this, "Error", QString().asprintf("Error %d", error));
|
||||
if (error == FAILED_TO_SET_AUTORCM)
|
||||
toolsTab->autoRCM_switch->toggle();
|
||||
|
||||
QString err_label;
|
||||
for (ErrorLabel item : ErrorLabelArr)
|
||||
{
|
||||
if (item.error == error)
|
||||
err_label = item.label;
|
||||
}
|
||||
|
||||
if (!err_label.size())
|
||||
err_label.append(QString().asprintf("Error %d", error));
|
||||
|
||||
QMessageBox::critical(this, "Error", err_label);
|
||||
}
|
||||
|
||||
void TegraRcmGUI::pushMessage(QString message)
|
||||
|
|
|
@ -6,11 +6,14 @@
|
|||
#include <QtConcurrent/QtConcurrent>
|
||||
#include "qpayload.h"
|
||||
#include "qtools.h"
|
||||
#include "qsettings.h"
|
||||
#include "kourou/kourou.h"
|
||||
#include "kourou/usb_command.h"
|
||||
#include "qkourou.h"
|
||||
|
||||
class QPayloadWidget;
|
||||
class qTools;
|
||||
class qSettings;
|
||||
class QKourou;
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
@ -36,7 +39,9 @@ public:
|
|||
QKourou *m_kourou;
|
||||
QPayloadWidget *payloadTab;
|
||||
qTools *toolsTab;
|
||||
qSettings *settingsTab;
|
||||
bool enableWidget(QWidget *widget, bool enable);
|
||||
bool isDeviceInfoAvailable() { return m_deviceInfoAvailable; }
|
||||
|
||||
private slots:
|
||||
void on_deviceInfo_received(UC_DeviceInfo di);
|
||||
|
@ -58,8 +63,7 @@ signals:
|
|||
private:
|
||||
Ui::TegraRcmGUI *ui;
|
||||
KHOT_HANDLE m_hotHandle = nullptr;
|
||||
|
||||
bool m_ready = false;
|
||||
bool m_deviceInfoAvailable = false;
|
||||
std::string tmp_string;
|
||||
QVector<qint64> push_ts;
|
||||
int tsToDeleteCount = 0;
|
||||
|
@ -81,4 +85,15 @@ const QString statusOffStyleSht("QFrame{border-radius: 10px; background-color: r
|
|||
const QString statusOffRedStyleSht("QFrame{border-radius: 10px; background-color: rgb(150, 35, 0); border-color: rgb(0, 0, 0);}"
|
||||
"QLabel{font: 75 9pt \"Calibri\"; color: rgb(255, 255, 255);}");
|
||||
|
||||
typedef struct ErrorLabel ErrorLabel;
|
||||
struct ErrorLabel {
|
||||
int error;
|
||||
QString label;
|
||||
};
|
||||
|
||||
static ErrorLabel ErrorLabelArr[] =
|
||||
{
|
||||
{ FAILED_TO_SET_AUTORCM, "Failed to set autoRCM" },
|
||||
};
|
||||
|
||||
#endif // TEGRARCMGUI_H
|
||||
|
|
Loading…
Reference in a new issue