Début firmware uploader
This commit is contained in:
@@ -0,0 +1,258 @@
|
||||
#include "HexFile.h"
|
||||
#include <QTextStream>
|
||||
#include <QMessageBox>
|
||||
|
||||
#define USE_BIG_RECORDS
|
||||
#define MAX_RECORDS_IN_BIG_RECORDS 512 //16 bytes by record, 512 bytes by row --> 16 rows / big record
|
||||
|
||||
CHexFile::CHexFile(void)
|
||||
{
|
||||
mFileOpened = false;
|
||||
mFileParsed = false;
|
||||
mRecordsListValid = false;
|
||||
mHighAddress = 0;
|
||||
mDiscardedRecords = 0;
|
||||
mTotalParsedRecords = 0;
|
||||
|
||||
}
|
||||
|
||||
CHexFile::~CHexFile(void)
|
||||
{
|
||||
for(int i = 0; i < mRecordsList.size(); i++)
|
||||
delete mRecordsList.at(i);
|
||||
|
||||
}
|
||||
|
||||
int CHexFile::CloseOpenedHexFile()
|
||||
{
|
||||
for(int i = 0; i < mRecordsList.size(); i++)
|
||||
delete mRecordsList.at(i);
|
||||
|
||||
mFileOpened = false;
|
||||
mFileParsed = false;
|
||||
mHexfileHandle = 0;
|
||||
mRecordsListValid = false;
|
||||
mHighAddress = 0;
|
||||
mDiscardedRecords = 0;
|
||||
mTotalParsedRecords = 0;
|
||||
}
|
||||
|
||||
int CHexFile::OpenDataFile(QString FilePath, bool CloseIfAlreadyParsed)
|
||||
{
|
||||
|
||||
//Check if file exists
|
||||
if(QFile::exists(FilePath) == false)
|
||||
return 0;
|
||||
|
||||
if(mFileParsed == true)
|
||||
{
|
||||
if(CloseIfAlreadyParsed == false)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
CloseOpenedHexFile();
|
||||
}
|
||||
}
|
||||
|
||||
mHexfileHandle = new QFile(FilePath);
|
||||
|
||||
if(mHexfileHandle->open(QIODevice::ReadOnly|QIODevice::Text|QIODevice::Unbuffered) == false)
|
||||
{
|
||||
delete mHexfileHandle;
|
||||
mHexfileHandle = 0;
|
||||
qDebug("Cannot open specified HEX file...");
|
||||
return 0;
|
||||
}
|
||||
|
||||
mHexFileSize = mHexfileHandle->size();
|
||||
|
||||
mFileOpened = true;
|
||||
|
||||
mRecordsTableSize = 0;
|
||||
mFirmwareDataSize = 0;
|
||||
|
||||
return ParseData();
|
||||
|
||||
}
|
||||
|
||||
int CHexFile::ParseData(void)
|
||||
{
|
||||
if(!mFileOpened)
|
||||
return 0;
|
||||
|
||||
int Ret;
|
||||
bool Finished = false;
|
||||
unsigned int CurAddress;
|
||||
|
||||
// CArray<CHexRecord*,CHexRecord*> TempArray;
|
||||
QList<CHexRecord*> TempList;
|
||||
QString RecordString;
|
||||
QTextStream RecordFileStream(mHexfileHandle);
|
||||
// CArchive ar(&mHexfileHandle,CArchive::load);
|
||||
|
||||
while(!Finished)
|
||||
{
|
||||
CHexRecord *NewRecord = new CHexRecord;
|
||||
RecordString.clear();
|
||||
// ar.ReadString(mRecordString);
|
||||
RecordString = RecordFileStream.readLine();
|
||||
// Ret = NewRecord.DecodeRawRecord(&mRecordString,mHighAddress);
|
||||
Ret = NewRecord->DecodeRawRecord(&RecordString,mHighAddress);
|
||||
mTotalParsedRecords++;
|
||||
|
||||
switch(Ret)
|
||||
{
|
||||
case CHexRecord::RET_DATA_RECORD:
|
||||
{
|
||||
#ifdef USE_BIG_RECORDS
|
||||
TempList.append(NewRecord);
|
||||
// mRecordsTable[mRecordsTableSize] = NewRecord;
|
||||
// mRecordsTableSize++;
|
||||
#else
|
||||
mRecordsList.append(NewRecord);
|
||||
mRecordsTable[mRecordsTableSize] = NewRecord;
|
||||
mRecordsTableSize++;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case CHexRecord::RET_EOF_RECORD:
|
||||
{
|
||||
mHexfileHandle->close();
|
||||
mFileOpened = false;
|
||||
delete mHexfileHandle;
|
||||
mRecordsListValid = true;
|
||||
Finished = true;
|
||||
delete NewRecord;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CHexRecord::RET_EXTENDED_LINEAR_ADDRESS:
|
||||
{
|
||||
// mHighAddress = NewRecord.GetExtenedAddress();
|
||||
mHighAddress = NewRecord->GetExtenedAddress();
|
||||
CurAddress = mHighAddress;
|
||||
delete NewRecord;
|
||||
break;
|
||||
}
|
||||
case CHexRecord::RET_IGNORED_ALL_FF_RECORD:
|
||||
{
|
||||
delete NewRecord;
|
||||
mDiscardedRecords++;
|
||||
break;
|
||||
}
|
||||
case CHexRecord::RET_EXTENDED_ADDRESS:
|
||||
case CHexRecord::RET_START_SEGMENT_ADDRESS:
|
||||
case CHexRecord::RET_START_LINEAR_ADDRESS:
|
||||
case CHexRecord::RET_UNKNOWN_RECORD_TYPE:
|
||||
case CHexRecord::RET_INVALID_RECORD:
|
||||
case CHexRecord::RET_BAD_RECORD_CHECKSUM:
|
||||
case CHexRecord::RET_UNMANAGED_RECORD_TYPE:
|
||||
{
|
||||
mHexfileHandle->close();
|
||||
mFileOpened = false;
|
||||
delete mHexfileHandle;
|
||||
Finished = true;
|
||||
//MessageBox(NULL,"Parsing Error", "Cannot Parse Hex File",MB_OK);
|
||||
QMessageBox::warning(0,"Parsing Error","Cannot parse HEX file",QMessageBox::Ok);
|
||||
delete NewRecord;
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_BIG_RECORDS
|
||||
int i;
|
||||
int RecordCount;
|
||||
CHexRecord *TempRecordPtr;
|
||||
CHexRecord *BigRecord = new CHexRecord;
|
||||
|
||||
TempRecordPtr = TempList.at(0);
|
||||
CurAddress = TempRecordPtr->GetStartAddress();
|
||||
*BigRecord = *TempRecordPtr;
|
||||
RecordCount = 1;
|
||||
|
||||
for(i = 1; i < TempList.size(); i++)
|
||||
{
|
||||
// if(CurAddress == 0x1d0097F0)
|
||||
// {
|
||||
// CurAddress = CurAddress;
|
||||
// }
|
||||
CurAddress += (TempRecordPtr->GetRecordSizeInBytes());
|
||||
TempRecordPtr = TempList.at(i);
|
||||
if(CurAddress == TempRecordPtr->GetStartAddress() && RecordCount<MAX_RECORDS_IN_BIG_RECORDS && (i != (TempList.size()-1)))
|
||||
{
|
||||
BigRecord->AppendRecord(TempRecordPtr);
|
||||
RecordCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
RecordCount = 1; //Init to 1 because we load the record right below...
|
||||
mRecordsList.append(BigRecord);
|
||||
BigRecord = new CHexRecord;
|
||||
|
||||
if(i == TempList.size()-1) //Manage the last record.
|
||||
{
|
||||
*BigRecord = *TempRecordPtr;
|
||||
mRecordsList.append(BigRecord);
|
||||
BigRecord->mRecordSize += TempRecordPtr->mRecordSize;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
*BigRecord = *TempRecordPtr;
|
||||
CurAddress = TempRecordPtr->GetStartAddress();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for(i = 0; i < TempList.size(); i++)
|
||||
{
|
||||
delete TempList[i];
|
||||
}
|
||||
|
||||
for(i = 0; i < mRecordsList.size(); i++)
|
||||
{
|
||||
mFirmwareDataSize += mRecordsList.at(i)->GetRecordSizeInBytes();
|
||||
}
|
||||
|
||||
mFileParsed = true;
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned int CHexFile::GetNBRecords(void)
|
||||
{
|
||||
// return mRecordsTableSize;
|
||||
|
||||
return mRecordsList.size();
|
||||
|
||||
}
|
||||
|
||||
unsigned long CHexFile::GetFileSize(void)
|
||||
{
|
||||
return mHexFileSize;
|
||||
}
|
||||
|
||||
CHexRecord * CHexFile::GetRecord(int RecordIndex, int &Status)
|
||||
{
|
||||
|
||||
if(RecordIndex > mRecordsList.size())
|
||||
// if(RecordIndex > mRecordsTableSize)
|
||||
{
|
||||
Status = ERR_INDEX_OUT_OF_BOUND;
|
||||
return 0;
|
||||
}
|
||||
//CHexRecord *mRecordPtr = (CHexRecord*)&mRecordsList.GetAt(RecordIndex);
|
||||
CHexRecord *mRecordPtr = mRecordsList.at(RecordIndex);
|
||||
// CHexRecord *mRecordPtr = mRecordsTable[RecordIndex];
|
||||
return mRecordPtr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include "HexRecord.h"
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <QFile>
|
||||
|
||||
|
||||
class CHexFile
|
||||
{
|
||||
|
||||
enum eHexFileStatus
|
||||
{
|
||||
STATUS_OK,
|
||||
STATUS_OK_LAST_INDEX,
|
||||
ERR_INDEX_OUT_OF_BOUND
|
||||
};
|
||||
|
||||
public:
|
||||
CHexFile(void);
|
||||
~CHexFile(void);
|
||||
|
||||
int OpenDataFile(QString FilePath, bool CloseIfAlreadyParsed = true);
|
||||
int CloseOpenedHexFile();
|
||||
int ParseData(void);
|
||||
unsigned int GetNBRecords(void);
|
||||
unsigned long GetFileSize(void);
|
||||
unsigned long GetFirmwareSize(void){return mFirmwareDataSize;}
|
||||
bool HexFileLoaded(void){return mFileOpened;}
|
||||
bool HexDataValid(void){return mFileParsed;}
|
||||
unsigned long GetTotalParsedRecords(void){return mTotalParsedRecords;}
|
||||
|
||||
|
||||
|
||||
CHexRecord * GetRecord(int RecordIndex, int &Status);
|
||||
unsigned long mDiscardedRecords;
|
||||
unsigned long mTotalParsedRecords;
|
||||
|
||||
private:
|
||||
QFile *mHexfileHandle;
|
||||
bool mFileOpened;
|
||||
bool mFileParsed;
|
||||
bool mRecordsListValid;
|
||||
//CArray<CHexRecord*,CHexRecord*> mRecordsList;
|
||||
QList<CHexRecord*> mRecordsList;
|
||||
// CHexRecord* mRecordsTable[0x3000];
|
||||
unsigned int mRecordsTableSize;
|
||||
unsigned int mHighAddress;
|
||||
unsigned long mHexFileSize;
|
||||
unsigned long mFirmwareDataSize;
|
||||
|
||||
|
||||
};
|
||||
@@ -0,0 +1,177 @@
|
||||
#include "HexRecord.h"
|
||||
|
||||
|
||||
CHexRecord::CHexRecord(void)
|
||||
{
|
||||
mRecordData = NULL;
|
||||
}
|
||||
|
||||
CHexRecord::~CHexRecord(void)
|
||||
{
|
||||
mStartAddress = 0;
|
||||
mRecordSize = 0;
|
||||
mRecordType = 0;
|
||||
mExtendedAddress = 0;
|
||||
// delete[] mRecordData;
|
||||
}
|
||||
|
||||
int CHexRecord::DecodeRawRecord(QString *RawRecordData, unsigned int HighAddress)
|
||||
{
|
||||
bool OK;
|
||||
// CString RecordString;
|
||||
QString RecordString;
|
||||
bool IsAllFF = true;
|
||||
int StartIndex = RawRecordData->indexOf(QChar(':'));
|
||||
|
||||
if(StartIndex == -1)
|
||||
return -1;
|
||||
|
||||
RecordString = RawRecordData->right(RawRecordData->length()-1); //Remove all that is left of ':'
|
||||
|
||||
QString RecordSizeString;
|
||||
RecordSizeString = RecordString.mid(0,2);
|
||||
//sscanf_s(RecordSizeString.GetBuffer(),"%x",&mRecordSize);
|
||||
mRecordSize = RecordSizeString.toUInt(&OK,16);
|
||||
|
||||
QString RecordAddress;
|
||||
RecordAddress = RecordString.mid(2,4);
|
||||
//sscanf_s(RecordAddress.GetBuffer(),"%x",&mStartAddress);
|
||||
mStartAddress = RecordAddress.toUInt(&OK,16);
|
||||
mStartAddress |= (HighAddress & 0xFFFF0000);
|
||||
|
||||
if(mStartAddress == 0x1d0097F0)
|
||||
{
|
||||
mStartAddress = mStartAddress;
|
||||
}
|
||||
|
||||
QString RecordTypeString;
|
||||
RecordTypeString = RecordString.mid(6,2);
|
||||
//sscanf_s(RecordTypeString.GetBuffer(),"%x",&mRecordType);
|
||||
mRecordType = RecordTypeString.toUInt(&OK,16);
|
||||
|
||||
RecordString = RecordString.right(RecordString.length()- 8);
|
||||
|
||||
if(mRecordType >= MAX_RECORD_TYPE)
|
||||
return RET_UNKNOWN_RECORD_TYPE;
|
||||
|
||||
if(mRecordSize %2 != 0)
|
||||
{
|
||||
mRecordSize++;//Pad the last word if we do not have an even number of bytes in the record.
|
||||
}
|
||||
|
||||
|
||||
switch(mRecordType)
|
||||
{
|
||||
case DATA_RECORD_TYPE: //0x00
|
||||
{
|
||||
char *DataPtr;
|
||||
QString DataString;
|
||||
// mRecordData = new char[mRecordSize/*+10*/]; //I have no clue why I have to allocate more space but if I don't delete[] crashes. I think it's a scanf bug...
|
||||
// DataPtr = mRecordData.data();
|
||||
|
||||
for(unsigned int i = 0; i < mRecordSize; i++)
|
||||
{
|
||||
DataString = RecordString.mid(2*i,2);
|
||||
char DataByte = (char)DataString.toUShort(&OK,16);
|
||||
//sscanf_s(DataString.GetBuffer(),"%x",&mRecordData[i],sizeof(char)/*DataPtr*/);
|
||||
//mRecordData[i] = (char)DataString.toUShort(&OK,16);
|
||||
mRecordData.append(DataByte);
|
||||
if((unsigned char)DataByte != 0xFF)
|
||||
IsAllFF = false;
|
||||
//DataPtr++;
|
||||
}
|
||||
if(mRecordSize %2 != 0) //Is this really needed?
|
||||
{
|
||||
//*DataPtr++ = 0xFF; //Pad the last word if we do not have an even number of bytes in the record.
|
||||
mRecordData.append(0xFF);
|
||||
}
|
||||
|
||||
mRecordSize /= 4; //Transfom the size in WORD size...
|
||||
|
||||
//#ifdef IGNORE_ALL_FF_RECORDS
|
||||
if(IsAllFF)
|
||||
{
|
||||
|
||||
return RET_IGNORED_ALL_FF_RECORD;
|
||||
}
|
||||
else
|
||||
return RET_DATA_RECORD;
|
||||
//#else
|
||||
// return RET_DATA_RECORD;
|
||||
//#endif
|
||||
|
||||
break;
|
||||
}
|
||||
case EOF_RECORD_TYPE: //0x01
|
||||
{
|
||||
return RET_EOF_RECORD;
|
||||
break;
|
||||
}
|
||||
case EXTENDED_ADDRESS_TYPE: //0x02
|
||||
{
|
||||
return RET_UNMANAGED_RECORD_TYPE;
|
||||
|
||||
break;
|
||||
}
|
||||
case START_SEGMENT_ADDRESS_TYPE: //0x03
|
||||
{
|
||||
return RET_UNMANAGED_RECORD_TYPE;
|
||||
break;
|
||||
}
|
||||
case EXTENDED_LINEAR_ADDRESS_TYPE: //0x04
|
||||
{
|
||||
QString ExtendedAddressString;
|
||||
ExtendedAddressString = RecordString.mid(0,4);
|
||||
//sscanf_s(ExtendedAddressString.GetBuffer(),"%x",&mExtendedAddress);
|
||||
mExtendedAddress = ExtendedAddressString.toUInt(&OK,16);
|
||||
mExtendedAddress <<= 16;
|
||||
return RET_EXTENDED_LINEAR_ADDRESS;
|
||||
break;
|
||||
}
|
||||
case START_LINEAR_ADDRESS_TYPE: //0x05
|
||||
{
|
||||
return RET_UNMANAGED_RECORD_TYPE;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return RET_UNKNOWN_RECORD_TYPE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int CHexRecord::AppendRecord(CHexRecord *NewRecord)
|
||||
{
|
||||
unsigned int NewSize;
|
||||
|
||||
NewSize = GetRecordSizeInBytes() + NewRecord->GetRecordSizeInBytes();
|
||||
|
||||
// char *NewBuff = new char[NewSize];
|
||||
// memcpy(NewBuff,mRecordData,GetRecordSizeInBytes());
|
||||
// memcpy(&NewBuff[GetRecordSizeInBytes()],NewRecord->GetDataBuffer(),NewRecord->GetRecordSizeInBytes());
|
||||
|
||||
//delete[] mRecordData;
|
||||
//mRecordData = NewBuff;
|
||||
|
||||
mRecordData.append(NewRecord->GetData());
|
||||
mRecordSize = NewSize/4;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
CHexRecord& CHexRecord::operator = (const CHexRecord &rhs)
|
||||
{
|
||||
if(this == &rhs)
|
||||
return *this;
|
||||
|
||||
mExtendedAddress = rhs.mExtendedAddress;
|
||||
mRecordSize = rhs.mRecordSize;
|
||||
mStartAddress = rhs.mStartAddress;
|
||||
mRecordType = rhs.mRecordType;
|
||||
mRecordData = rhs.mRecordData;
|
||||
|
||||
// mRecordData = new char[mRecordSize*4];
|
||||
// memcpy(mRecordData,rhs.mRecordData,mRecordSize*4);
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
#pragma once
|
||||
#include <QString>
|
||||
#include <QByteArray>
|
||||
|
||||
#define IGNORE_ALL_FF_RECORDS
|
||||
|
||||
class CHexRecord
|
||||
{
|
||||
public:
|
||||
|
||||
enum eRecordTypes
|
||||
{
|
||||
DATA_RECORD_TYPE, //0x00
|
||||
EOF_RECORD_TYPE, //0x01
|
||||
EXTENDED_ADDRESS_TYPE, //0x02
|
||||
START_SEGMENT_ADDRESS_TYPE, //0x03
|
||||
EXTENDED_LINEAR_ADDRESS_TYPE, //0x04
|
||||
START_LINEAR_ADDRESS_TYPE, //0x05
|
||||
MAX_RECORD_TYPE
|
||||
};
|
||||
|
||||
enum eRetValues
|
||||
{
|
||||
RET_DATA_RECORD,
|
||||
RET_EOF_RECORD,
|
||||
RET_EXTENDED_ADDRESS,
|
||||
RET_START_SEGMENT_ADDRESS,
|
||||
RET_EXTENDED_LINEAR_ADDRESS,
|
||||
RET_IGNORED_ALL_FF_RECORD,
|
||||
RET_START_LINEAR_ADDRESS,
|
||||
RET_UNKNOWN_RECORD_TYPE,
|
||||
RET_INVALID_RECORD,
|
||||
RET_BAD_RECORD_CHECKSUM,
|
||||
RET_UNMANAGED_RECORD_TYPE
|
||||
};
|
||||
|
||||
//char *mRecordData;
|
||||
QByteArray mRecordData;
|
||||
unsigned int mStartAddress;
|
||||
unsigned int mRecordSize;
|
||||
unsigned int mRecordType;
|
||||
unsigned int mExtendedAddress;
|
||||
|
||||
|
||||
CHexRecord(void);
|
||||
~CHexRecord(void);
|
||||
|
||||
int SetRecordStartAddress(unsigned int Address);
|
||||
int SetRecordSize(unsigned int size);
|
||||
int DecodeRawRecord(QString *RawRecordData, unsigned int HighAddress);
|
||||
|
||||
unsigned int GetExtenedAddress(void){return mExtendedAddress;}
|
||||
unsigned int GetStartAddress(void){return mStartAddress;}
|
||||
char *GetDataBuffer(void){return mRecordData.data();}
|
||||
QByteArray GetData(void){return mRecordData;}
|
||||
unsigned int GetRecordSize(void){return mRecordData.size()/4;}
|
||||
unsigned int GetRecordSizeInBytes(void){return mRecordData.size();}
|
||||
unsigned int GetRecordType(void){return mRecordType;}
|
||||
unsigned int AppendRecord(CHexRecord *RecordToAppend);
|
||||
|
||||
CHexRecord& operator=(const CHexRecord &rhs);
|
||||
|
||||
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
#include "PICUploader.h"
|
||||
#include "GlobalDefine.h"
|
||||
|
||||
CPICUploader::CPICUploader(CPICUploaderGui *Gui)
|
||||
{
|
||||
mPICUploaderGui = Gui;
|
||||
mPICUploaderGui->mProgramHandle = this;
|
||||
}
|
||||
|
||||
|
||||
int CPICUploader::Start()
|
||||
{
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
||||
int CPICUploader::OpenHexFileRequest(QString FilePath)
|
||||
{
|
||||
int ret = mHexFile.OpenDataFile(FilePath);
|
||||
|
||||
if(ret == 0)
|
||||
return 0;
|
||||
|
||||
QString HexFileStats = QString("HexFileSize: %1\nFirmware Size: %4\nNb analyzed Records: %2\nNb Big Records: %3").arg(mHexFile.GetFileSize()).arg(mHexFile.GetTotalParsedRecords()).arg(mHexFile.GetNBRecords()).arg(mHexFile.GetFirmwareSize());
|
||||
|
||||
mPICUploaderGui->SetHexFileStats(HexFileStats);
|
||||
|
||||
//HexFileStats << "HexFileSize: " << mHexFile.GetFileSize() << "\n";
|
||||
// HexFileStats <<
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef PICUPLOADER_H
|
||||
#define PICUPLOADER_H
|
||||
|
||||
#include <QObject>
|
||||
#include "PICUploaderGui.h"
|
||||
#include "HexFile.h"
|
||||
|
||||
class CPICUploader : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CPICUploader(CPICUploaderGui *Gui);
|
||||
int OpenHexFileRequest(QString FilePath);
|
||||
|
||||
int Start();
|
||||
|
||||
CPICUploaderGui *mPICUploaderGui;
|
||||
|
||||
CHexFile mHexFile;
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
#endif // PICUPLOADER_H
|
||||
@@ -0,0 +1,34 @@
|
||||
#include "PICUploaderGui.h"
|
||||
#include "ui_PICUploaderGui.h"
|
||||
#include <QFileDialog>
|
||||
#include "PICUploader.h"
|
||||
|
||||
CPICUploaderGui::CPICUploaderGui(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::CPICUploaderGui)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(ui->mHexFileSelectBtn,SIGNAL(clicked(bool)),this,SLOT(OpenHexFileBtnClicked(bool)));
|
||||
|
||||
}
|
||||
|
||||
CPICUploaderGui::~CPICUploaderGui()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CPICUploaderGui::OpenHexFileBtnClicked(bool checked)
|
||||
{
|
||||
QString FileName = QFileDialog::getOpenFileName(0,"Select Firmware Hex File",QString(),"Hex files (*.hex)");
|
||||
if(mProgramHandle->OpenHexFileRequest(FileName) != 0)
|
||||
{
|
||||
ui->mOpenedHexFilePathLbl->setText(FileName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CPICUploaderGui::SetHexFileStats(QString Stats)
|
||||
{
|
||||
ui->mHexFileStatsLbl->setText(Stats);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#ifndef PICUPLOADERGUI_H
|
||||
#define PICUPLOADERGUI_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class CPICUploader;
|
||||
|
||||
namespace Ui {
|
||||
class CPICUploaderGui;
|
||||
}
|
||||
|
||||
class CPICUploaderGui : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CPICUploaderGui(QWidget *parent = nullptr);
|
||||
~CPICUploaderGui();
|
||||
|
||||
void SetHexFileStats(QString Stats);
|
||||
|
||||
CPICUploader *mProgramHandle;
|
||||
|
||||
private:
|
||||
Ui::CPICUploaderGui *ui;
|
||||
|
||||
public slots:
|
||||
void OpenHexFileBtnClicked(bool);
|
||||
};
|
||||
|
||||
#endif // PICUPLOADERGUI_H
|
||||
@@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CPICUploaderGui</class>
|
||||
<widget class="QDialog" name="CPICUploaderGui">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1024</width>
|
||||
<height>768</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
<y>20</y>
|
||||
<width>191</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Firmware Uploader</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="mHexFileSelectBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>110</y>
|
||||
<width>81</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open Hex File</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>690</x>
|
||||
<y>120</y>
|
||||
<width>181</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="mOpenedHexFilePathLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>140</y>
|
||||
<width>521</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>No File Opened</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="mHexFileStatsLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>170</y>
|
||||
<width>471</width>
|
||||
<height>131</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user