1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-01 18:29:16 +01:00

OP-21/Flight Bootloader PC APP- Cosmetic changes only.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1549 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
zedamota 2010-09-06 19:05:41 +00:00 committed by zedamota
parent 5c4ba7140b
commit 609d215749
3 changed files with 35 additions and 26 deletions

View File

@ -45,11 +45,11 @@ int main(int argc, char *argv[])
cout<<"| |\n";
cout<<"| examples: |\n";
cout<<"| |\n";
cout<<"| program and verify device #1 |\n";
cout<<"| OPUploadTool -p c:/OpenPilot.bin -w \"Openpilot Firmware\" -v -d 1 |\n";
cout<<"| program and verify device #0 |\n";
cout<<"| OPUploadTool -p c:/OpenPilot.bin -w \"Openpilot Firmware\" -v -d 0 |\n";
cout<<"| |\n";
cout<<"| Perform a quick compare of FW in file with FW in device #2 |\n";
cout<<"| OPUploadTool -ch c:/OpenPilot.bin -d 2 |\n";
cout<<"| Perform a quick compare of FW in file with FW in device #1 |\n";
cout<<"| OPUploadTool -ch c:/OpenPilot2.bin -d 2 |\n";
cout<<"|________________________________________________________________________|\n";
return 0;
@ -99,8 +99,7 @@ int main(int argc, char *argv[])
cout<<("Device not specified\n");
return -1;
}
if(args.contains(VERIFY))
action=OP_DFU::actionProgramAndVerify;
}
else if(args.contains(COMPAREHASH) || args.contains(COMPAREALL))
{
@ -214,7 +213,7 @@ int main(int argc, char *argv[])
}
return 0;
}
if(device>dfu.numberOfDevices)
if(device>dfu.numberOfDevices-1)
{
cout<<"Error:Invalid Device";
return -1;

View File

@ -28,7 +28,7 @@ OP_DFU::OP_DFU(bool _debug): debug(_debug)
if(debug)
qDebug() << numDevices << " device(s) opened";
}
bool OP_DFU::SaveByteArrayToFile(QString sfile, const QByteArray &array)
bool OP_DFU::SaveByteArrayToFile(QString const & sfile, const QByteArray &array)
{
QFile file(sfile);
//QFile file("in.txt");
@ -43,7 +43,7 @@ bool OP_DFU::SaveByteArrayToFile(QString sfile, const QByteArray &array)
return true;
}
bool OP_DFU::enterDFU(int devNumber)
bool OP_DFU::enterDFU(int const &devNumber)
{
char buf[BUF_LEN];
buf[0] =0x02;//reportID
@ -64,7 +64,7 @@ bool OP_DFU::enterDFU(int devNumber)
qDebug() << result << " bytes sent";
return true;
}
bool OP_DFU::StartUpload(qint32 numberOfBytes, TransferTypes type)
bool OP_DFU::StartUpload(qint32 const & numberOfBytes, TransferTypes const & type)
{
int lastPacketCount;
qint32 numberOfPackets=numberOfBytes/4/14;
@ -99,7 +99,7 @@ bool OP_DFU::StartUpload(qint32 numberOfBytes, TransferTypes type)
}
return false;
}
bool OP_DFU::UploadData(qint32 numberOfBytes, QByteArray data)
bool OP_DFU::UploadData(qint32 const & numberOfBytes, QByteArray & data)
{
int lastPacketCount;
qint32 numberOfPackets=numberOfBytes/4/14;
@ -156,9 +156,10 @@ bool OP_DFU::UploadData(qint32 numberOfBytes, QByteArray data)
// qDebug() << "UPLOAD:"<<"Data="<<(int)buf[6]<<(int)buf[7]<<(int)buf[8]<<(int)buf[9]<<";"<<result << " bytes sent";
}
cout<<"\n";
return true;
}
OP_DFU::Status OP_DFU::UploadDescription(QString description)
OP_DFU::Status OP_DFU::UploadDescription(QString & description)
{
if(description.length()%4!=0)
{
@ -185,7 +186,7 @@ OP_DFU::Status OP_DFU::UploadDescription(QString description)
qDebug()<<"Upload description Status="<<ret;
return ret;
}
QString OP_DFU::DownloadDescription(int numberOfChars)
QString OP_DFU::DownloadDescription(int const & numberOfChars)
{
// enterDFU(devNumber);
QByteArray arr=StartDownload(numberOfChars,Descript);
@ -193,7 +194,7 @@ QString OP_DFU::DownloadDescription(int numberOfChars)
return str;
}
QByteArray OP_DFU::StartDownload(qint32 numberOfBytes, TransferTypes type)
QByteArray OP_DFU::StartDownload(qint32 const & numberOfBytes, TransferTypes const & type)
{
int lastPacketCount;
qint32 numberOfPackets=numberOfBytes/4/14;
@ -244,6 +245,7 @@ QByteArray OP_DFU::StartDownload(qint32 numberOfBytes, TransferTypes type)
size=14*4;
ret.append(buf+6,size);
}
cout<<"\n";
StatusRequest();
return ret;
}
@ -451,10 +453,15 @@ OP_DFU::Status OP_DFU::UploadFirmware(const QString &sfile, const bool &verify)
OP_DFU::Status ret=StatusRequest();
if(ret==OP_DFU::Last_operation_Success)
{
cout<<"Firmware Uploading succeeded...going to upload hash\n";
}
else
{
return OP_DFU::abort;
}
if(verify)
{
cout<<"Starting code verification\n";
if(arr==StartDownload(arr.length(),OP_DFU::FW))
cout<<"Verify:PASSED\n";
else
@ -476,6 +483,7 @@ OP_DFU::Status OP_DFU::UploadFirmware(const QString &sfile, const bool &verify)
qDebug()<<"StartUpload failed";
return OP_DFU::abort;
}
cout<<"Firmware Uploading succeeded...going to upload hash\n";
if(!UploadData(hash.length(),hash))
{
if(debug)
@ -559,7 +567,7 @@ void OP_DFU::CopyWords(char *source, char *destination, int count)
*(destination+x+3)=source[x+0];
}
}
QString OP_DFU::StatusToString(OP_DFU::Status status)
QString OP_DFU::StatusToString(OP_DFU::Status const & status)
{
switch(status)
{
@ -585,10 +593,12 @@ QString OP_DFU::StatusToString(OP_DFU::Status status)
return "outsideDevCapabilities";
case abort:
return "abort";
default:
return "unknown";
}
}
void OP_DFU::printProgBar( int percent,QString const& label){
void OP_DFU::printProgBar( int const & percent,QString const& label){
std::string bar;
for(int i = 0; i < 50; i++){

View File

@ -97,24 +97,24 @@ public:
void JumpToApp();
void ResetDevice(void);
bool enterDFU(int devNumber);
bool StartUpload(qint32 numberOfBytes, TransferTypes type);
bool UploadData(qint32 numberOfPackets,QByteArray data);
Status UploadDescription(QString description);
bool enterDFU(int const &devNumber);
bool StartUpload(qint32 const &numberOfBytes, TransferTypes const & type);
bool UploadData(qint32 const & numberOfPackets,QByteArray & data);
Status UploadDescription(QString & description);
Status UploadFirmware(const QString &sfile, const bool &verify);
Status StatusRequest();
bool EndOperation();
void printProgBar( int percent,QString const& label);
QString DownloadDescription(int numberOfChars);
QByteArray StartDownload(qint32 numberOfBytes, TransferTypes type);
bool SaveByteArrayToFile(QString file,QByteArray const &array);
void printProgBar( int const & percent,QString const& label);
QString DownloadDescription(int const & numberOfChars);
QByteArray StartDownload(qint32 const & numberOfBytes, TransferTypes const & type);
bool SaveByteArrayToFile(QString const & file,QByteArray const &array);
void CopyWords(char * source, char* destination, int count);
// QByteArray DownloadData(int devNumber,int numberOfPackets);
OP_DFU(bool debug);
bool findDevices();
QList<device> devices;
int numberOfDevices;
QString StatusToString(OP_DFU::Status);
QString StatusToString(OP_DFU::Status const & status);
OP_DFU::Status CompareFirmware(const QString &sfile, const CompareType &type);
private:
bool debug;