1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-19 04:52:12 +01:00

OP-1476 - Clanup upload_tool and add Makefile target

This commit is contained in:
Alessio Morale 2014-09-07 23:01:20 +02:00
parent b971b713d6
commit 1de46ae493
6 changed files with 333 additions and 260 deletions

View File

@ -439,7 +439,7 @@ sim_osx_%: uavobjects_flight
############################## ##############################
.PHONY: all_ground .PHONY: all_ground
all_ground: openpilotgcs all_ground: openpilotgcs uploader
# Convenience target for the GCS # Convenience target for the GCS
.PHONY: gcs gcs_clean .PHONY: gcs gcs_clean
@ -479,6 +479,40 @@ openpilotgcs_clean:
@$(ECHO) " CLEAN $(call toprel, $(BUILD_DIR)/openpilotgcs_$(GCS_BUILD_CONF))" @$(ECHO) " CLEAN $(call toprel, $(BUILD_DIR)/openpilotgcs_$(GCS_BUILD_CONF))"
$(V1) [ ! -d "$(BUILD_DIR)/openpilotgcs_$(GCS_BUILD_CONF)" ] || $(RM) -r "$(BUILD_DIR)/openpilotgcs_$(GCS_BUILD_CONF)" $(V1) [ ! -d "$(BUILD_DIR)/openpilotgcs_$(GCS_BUILD_CONF)" ] || $(RM) -r "$(BUILD_DIR)/openpilotgcs_$(GCS_BUILD_CONF)"
################################
#
# Serial Uploader tool
#
################################
.NOTPARALLEL:
.PHONY: uploader
uploader: uploader_qmake uploader_make
.PHONY: uploader_qmake
uploader_qmake:
ifeq ($(QMAKE_SKIP),)
$(V1) $(MKDIR) -p $(BUILD_DIR)/uploader_$(GCS_BUILD_CONF)
$(V1) ( cd $(BUILD_DIR)/uploader_$(GCS_BUILD_CONF) && \
$(QMAKE) $(ROOT_DIR)/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/upload.pro -spec $(QT_SPEC) -r CONFIG+="$(GCS_BUILD_CONF) $(GCS_SILENT)" $(GCS_QMAKE_OPTS) \
)
else
@$(ECHO) "skipping qmake"
endif
.PHONY: uploader_make
uploader_make:
$(V1) $(MKDIR) -p $(BUILD_DIR)/uploader_$(GCS_BUILD_CONF)
$(V1) ( cd $(BUILD_DIR)/uploader_$(GCS_BUILD_CONF)/$(MAKE_DIR) && \
$(MAKE) -w ; \
)
.PHONY: uploader_clean
uploader_clean:
@$(ECHO) " CLEAN $(call toprel, $(BUILD_DIR)/uploader_$(GCS_BUILD_CONF))"
$(V1) [ ! -d "$(BUILD_DIR)/uploader_$(GCS_BUILD_CONF)" ] || $(RM) -r "$(BUILD_DIR)/uploader_$(GCS_BUILD_CONF)"
################################ ################################
# #
# Android GCS related components # Android GCS related components
@ -972,6 +1006,14 @@ help:
@$(ECHO) " gcs_clean - Remove the Ground Control System (GCS) application (debug|release)" @$(ECHO) " gcs_clean - Remove the Ground Control System (GCS) application (debug|release)"
@$(ECHO) " Supported build configurations: GCS_BUILD_CONF=debug|release (default is $(GCS_BUILD_CONF))" @$(ECHO) " Supported build configurations: GCS_BUILD_CONF=debug|release (default is $(GCS_BUILD_CONF))"
@$(ECHO) @$(ECHO)
@$(ECHO) " [UPLOADER TOOL]"
@$(ECHO) " uploader - Build the serial uploader tool (debug|release)"
@$(ECHO) " Skip qmake: QMAKE_SKIP=1"
@$(ECHO) " Example: make gcs QMAKE_SKIP=1"
@$(ECHO) " uploader_clean - Remove the serial uploader tool (debug|release)"
@$(ECHO) " Supported build configurations: GCS_BUILD_CONF=debug|release (default is $(GCS_BUILD_CONF))"
@$(ECHO)
@$(ECHO)
@$(ECHO) " [AndroidGCS]" @$(ECHO) " [AndroidGCS]"
@$(ECHO) " androidgcs - Build the Android Ground Control System (GCS) application" @$(ECHO) " androidgcs - Build the Android Ground Control System (GCS) application"
@$(ECHO) " androidgcs_install - Use ADB to install the Android GCS application" @$(ECHO) " androidgcs_install - Use ADB to install the Android GCS application"

View File

@ -61,8 +61,9 @@ port::portstatus port::status()
int16_t port::pfSerialRead(void) int16_t port::pfSerialRead(void)
{ {
char c[1]; char c[1];
sport->waitForBytesWritten(5);
if (sport->bytesAvailable() || sport->waitForReadyRead(1)) { sport->waitForBytesWritten(1);
if (sport->bytesAvailable() || sport->waitForReadyRead(0)) {
sport->read(c, 1); sport->read(c, 1);
if (debug) { if (debug) {
if (((uint8_t)c[0]) == 0xe1 || rxDebugBuff.count() > 50) { if (((uint8_t)c[0]) == 0xe1 || rxDebugBuff.count() > 50) {

View File

@ -282,7 +282,7 @@ uint16_t qssp::ssp_SendDataBlock(uint8_t *data, uint16_t length)
* \note * \note
* *
*/ */
int16_t qssp:: ssp_SendData(const uint8_t *data, const uint16_t length) int16_t qssp::ssp_SendData(const uint8_t *data, const uint16_t length)
{ {
int16_t value = SSP_TX_WAITING; int16_t value = SSP_TX_WAITING;

View File

@ -3,259 +3,283 @@
#include "op_dfu.h" #include "op_dfu.h"
#include <QStringList> #include <QStringList>
#define PRIVATE false void showProgress(QString status);
void progressUpdated(int percent);
void usage(QTextStream *standardOutput);
QString label;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
///SSP/////////////////////////////////
/////////////////////////////////////////////
QCoreApplication a(argc, argv); QCoreApplication a(argc, argv);
QTextStream standardOutput(stdout);
int argumentCount = QCoreApplication::arguments().size();
bool use_serial = false;
bool verify;
bool debug = false;
bool umodereset = false;
OP_DFU::Actions action;
QString file;
QString serialport;
QString description;
int device = -1;
QStringList args = QCoreApplication::arguments();
// argc=4; if (args.contains("-debug")) {
// argv[1]="-ls"; debug = true;
// argv[2]="-t"; }
// argv[3]="COM3"; if (args.contains("-ur")) {
if (argc > 1 || !PRIVATE) { umodereset = true;
bool use_serial = false; }
bool verify; standardOutput << "OpenPilot serial firmware uploader tool." << endl;
bool debug = false; if (args.indexOf(PROGRAMFW) + 1 < args.length()) {
bool umodereset = false; file = args[args.indexOf(PROGRAMFW) + 1];
OP_DFU::Actions action; }
QString file; if (args.contains(DEVICE)) {
QString serialport; if (args.indexOf(DEVICE) + 1 < args.length()) {
QString description; device = (args[args.indexOf(DEVICE) + 1]).toInt();
int device = -1;
QStringList args;
for (int i = 0; i < argc; ++i) {
args << argv[i];
} }
if (args.contains("-debug")) { } else {
debug = true; device = 0;
}
if (argumentCount == 0 || args.contains("-?") || !args.contains(USE_SERIAL)) {
usage(&standardOutput);
return -1;
} else if (args.contains(PROGRAMFW)) {
if (args.contains(VERIFY)) {
verify = true;
} else {
verify = false;
} }
if (args.contains("-ur")) { if (args.contains(PROGRAMDESC)) {
umodereset = true; if (args.indexOf(PROGRAMDESC) + 1 < args.length()) {
description = (args[args.indexOf(PROGRAMDESC) + 1]);
}
} }
if (args.contains("-?") || (!PRIVATE && argc == 1)) { action = OP_DFU::actionProgram;
cout << "_________________________________________________________________________\n"; } else if (args.contains(COMPARECRC) || args.contains(COMPAREALL)) {
cout << "| Commands |\n"; int index;
cout << "| |\n"; if (args.contains(COMPARECRC)) {
cout << "| -ls : lists available devices |\n"; index = args.indexOf(COMPARECRC);
cout << "| -p <file> : program hw (requires:-d - optionals:-v,-w) |\n"; action = OP_DFU::actionCompareCrc;
cout << "| -v : verify (requires:-d) |\n"; } else {
cout << "| -dn <file> : download firmware to file (requires:-d) |\n"; index = args.indexOf(COMPAREALL);
// cout << "| -dd <file> : download discription (requires:-d) |\n"; action = OP_DFU::actionCompareAll;
cout << "| -d <number Of Device : (requires: -p or -dn) |\n"; }
cout << "| -w <description> : (requires: -p) |\n"; } else if (args.contains(DOWNLOAD)) {
cout << "| -ca <file> : compares byte by byte current firmware with file|\n"; int index;
cout << "| -cc <file> : compares CRC of current firmware with file |\n"; index = args.indexOf(DOWNLOAD);
cout << "| -s : requests status of device |\n"; action = OP_DFU::actionDownload;
cout << "| -r : resets the device |\n"; } else if (args.contains(STATUSREQUEST)) {
cout << "| -j : exits bootloader and jumps to user FW |\n"; action = OP_DFU::actionStatusReq;
cout << "| -debug : prints debug information |\n"; } else if (args.contains(RESET)) {
cout << "| -t <port> : uses serial port(requires:-ur) |\n"; action = OP_DFU::actionReset;
cout << "| -ur <port> : user mode reset* |\n"; } else if (args.contains(JUMP)) {
cout << "| |\n"; action = OP_DFU::actionJump;
cout << "| examples: |\n"; } else if (args.contains(LISTDEVICES)) {
cout << "| |\n"; action = OP_DFU::actionListDevs;
cout << "| program and verify device #0 |\n"; }
cout << "| OPUploadTool -p c:/OpenPilot.bin -w \"OpenPilot Firmware\" -v -d 0 |\n"; if ((file.isEmpty() || device == -1) && action != OP_DFU::actionReset && action != OP_DFU::actionStatusReq && action != OP_DFU::actionListDevs && action != OP_DFU::actionJump) {
cout << "| |\n"; usage(&standardOutput);
cout << "| Perform a quick compare of FW in file with FW in device #1 |\n"; return -1;
cout << "| OPUploadTool -ch c:/OpenPilot2.bin -d 2 |\n"; }
cout << "| |\n"; if (args.contains(USE_SERIAL)) {
cout << "| *requires valid user space firmwares already running |\n"; if (args.indexOf(USE_SERIAL) + 1 < args.length()) {
cout << "|________________________________________________________________________|\n"; serialport = (args[args.indexOf(USE_SERIAL) + 1]);
use_serial = true;
}
}
if (debug) {
qDebug() << "Action=" << (int)action << endl;
qDebug() << "File=" << file << endl;
qDebug() << "Device=" << device << endl;
qDebug() << "Action=" << action << endl;
qDebug() << "Desctription" << description << endl;
qDebug() << "Use Serial port" << use_serial << endl;
if (use_serial) {
qDebug() << "Port Name" << serialport << endl;
}
}
if (use_serial) {
if (args.contains(NO_COUNTDOWN)) {} else {
standardOutput << "Connect the board" << endl;
label = "";
for (int i = 0; i < 6; i++) {
progressUpdated(i * 100 / 5);
QThread::msleep(500);
}
}
standardOutput << endl << "Connect the board NOW" << endl;
QThread::msleep(1000);
}
///////////////////////////////////ACTIONS START///////////////////////////////////////////////////
OP_DFU::DFUObject dfu(debug, use_serial, serialport);
QObject::connect(&dfu, &OP_DFU::DFUObject::operationProgress, showProgress);
QObject::connect(&dfu, &OP_DFU::DFUObject::progressUpdated, progressUpdated);
if (!dfu.ready()) {
return -1;
}
dfu.AbortOperation();
if (!dfu.enterDFU(0)) {
standardOutput << "Could not enter DFU mode\n" << endl;
return -1;
}
if (debug) {
OP_DFU::Status ret = dfu.StatusRequest();
qDebug() << dfu.StatusToString(ret);
}
if (!(action == OP_DFU::actionStatusReq || action == OP_DFU::actionReset || action == OP_DFU::actionJump)) {
dfu.findDevices();
if (action == OP_DFU::actionListDevs) {
standardOutput << "Found " << dfu.numberOfDevices << "\n" << endl;
for (int x = 0; x < dfu.numberOfDevices; ++x) {
standardOutput << "Device #" << x << "\n" << endl;
standardOutput << "Device ID=" << dfu.devices[x].ID << "\n" << endl;
standardOutput << "Device Readable=" << dfu.devices[x].Readable << "\n" << endl;
standardOutput << "Device Writable=" << dfu.devices[x].Writable << "\n" << endl;
standardOutput << "Device SizeOfCode=" << dfu.devices[x].SizeOfCode << "\n" << endl;
standardOutput << "BL Version=" << dfu.devices[x].BL_Version << "\n" << endl;
standardOutput << "Device SizeOfDesc=" << dfu.devices[x].SizeOfDesc << "\n" << endl;
standardOutput << "FW CRC=" << dfu.devices[x].FW_CRC << "\n";
int size = ((OP_DFU::device)dfu.devices[x]).SizeOfDesc;
dfu.enterDFU(x);
standardOutput << "Description:" << dfu.DownloadDescription(size).toLatin1().data() << "\n" << endl;
standardOutput << "\n";
}
return 0; return 0;
} else if (args.contains(PROGRAMFW)) {
if (args.contains(VERIFY)) {
verify = true;
} else {
verify = false;
}
if (args.contains(PROGRAMDESC)) {
if (args.indexOf(PROGRAMDESC) + 1 < args.length()) {
description = (args[args.indexOf(PROGRAMDESC) + 1]);
}
}
action = OP_DFU::actionProgram;
if (args.contains(DEVICE)) {
if (args.indexOf(DEVICE) + 1 < args.length()) {
device = (args[args.indexOf(DEVICE) + 1]).toInt();
}
if (args.indexOf(PROGRAMFW) + 1 < args.length()) {
file = args[args.indexOf(PROGRAMFW) + 1];
}
} else {
cout << ("Device not specified\n");
return -1;
}
} else if (args.contains(COMPARECRC) || args.contains(COMPAREALL)) {
int index;
if (args.contains(COMPARECRC)) {
index = args.indexOf(COMPARECRC);
action = OP_DFU::actionCompareCrc;
} else {
index = args.indexOf(COMPAREALL);
action = OP_DFU::actionCompareAll;
}
if (args.contains(DEVICE)) {
if (args.indexOf(DEVICE) + 1 < args.length()) {
device = (args[args.indexOf(DEVICE) + 1]).toInt();
}
if (index + 1 < args.length()) {
file = args[index + 1];
}
} else {
cout << "Device not specified";
return -1;
}
} else if (args.contains(DOWNLOAD)) {
int index;
index = args.indexOf(DOWNLOAD);
action = OP_DFU::actionDownload;
if (args.contains(DEVICE)) {
if (args.indexOf(DEVICE) + 1 < args.length()) {
device = (args[args.indexOf(DEVICE) + 1]).toInt();
}
if (index + 1 < args.length()) {
file = args[index + 1];
}
} else {
cout << "Device not specified";
return -1;
}
} else if (args.contains(STATUSREQUEST)) {
action = OP_DFU::actionStatusReq;
} else if (args.contains(RESET)) {
action = OP_DFU::actionReset;
} else if (args.contains(JUMP)) {
action = OP_DFU::actionJump;
} else if (args.contains(LISTDEVICES)) {
action = OP_DFU::actionListDevs;
} }
if ((file.isEmpty() || device == -1) && action != OP_DFU::actionReset && action != OP_DFU::actionStatusReq && action != OP_DFU::actionListDevs && action != OP_DFU::actionJump) { if (device > dfu.numberOfDevices - 1) {
cout << "wrong parameters"; standardOutput << "Error:Invalid Device" << endl;
return -1; return -1;
} }
if (args.contains(USE_SERIAL)) { if (dfu.numberOfDevices == 1) {
if (args.indexOf(USE_SERIAL) + 1 < args.length()) { dfu.use_delay = false;
serialport = (args[args.indexOf(USE_SERIAL) + 1]);
use_serial = true;
}
} }
if (debug) { if (!dfu.enterDFU(device)) {
qDebug() << "Action=" << (int)action; standardOutput << "Error:Could not enter DFU mode\n" << endl;
qDebug() << "File=" << file;
qDebug() << "Device=" << device;
qDebug() << "Action=" << action;
qDebug() << "Desctription" << description;
qDebug() << "Use Serial port" << use_serial;
if (use_serial) {
qDebug() << "Port Name" << serialport;
}
}
///////////////////////////////////ACTIONS START///////////////////////////////////////////////////
OP_DFU::DFUObject dfu(debug, use_serial, serialport);
if (!dfu.ready()) {
return -1; return -1;
} }
if (action == OP_DFU::actionProgram) {
dfu.AbortOperation(); if (((OP_DFU::device)dfu.devices[device]).Writable == false) {
if (!dfu.enterDFU(0)) { standardOutput << "ERROR device not Writable\n" << endl;
cout << "Could not enter DFU mode\n"; return false;
return -1;
}
if (debug) {
OP_DFU::Status ret = dfu.StatusRequest();
qDebug() << dfu.StatusToString(ret);
}
if (!(action == OP_DFU::actionStatusReq || action == OP_DFU::actionReset || action == OP_DFU::actionJump)) {
dfu.findDevices();
if (action == OP_DFU::actionListDevs) {
cout << "Found " << dfu.numberOfDevices << "\n";
for (int x = 0; x < dfu.numberOfDevices; ++x) {
cout << "Device #" << x << "\n";
cout << "Device ID=" << dfu.devices[x].ID << "\n";
cout << "Device Readable=" << dfu.devices[x].Readable << "\n";
cout << "Device Writable=" << dfu.devices[x].Writable << "\n";
cout << "Device SizeOfCode=" << dfu.devices[x].SizeOfCode << "\n";
cout << "BL Version=" << dfu.devices[x].BL_Version << "\n";
cout << "Device SizeOfDesc=" << dfu.devices[x].SizeOfDesc << "\n";
cout << "FW CRC=" << dfu.devices[x].FW_CRC << "\n";
int size = ((OP_DFU::device)dfu.devices[x]).SizeOfDesc;
dfu.enterDFU(x);
cout << "Description:" << dfu.DownloadDescription(size).toLatin1().data() << "\n";
cout << "\n";
}
return 0;
} }
if (device > dfu.numberOfDevices - 1) { standardOutput << "Uploading..." << endl;
cout << "Error:Invalid Device"; bool retstatus = dfu.UploadFirmware(file.toLatin1(), verify, device);
if (!retstatus) {
standardOutput << "Upload failed with code:" << retstatus << endl;
return -1; return -1;
} }
if (dfu.numberOfDevices == 1) { if (!description.isEmpty()) {
dfu.use_delay = false; retstatus = dfu.UploadDescription(description);
} if (retstatus != OP_DFU::Last_operation_Success) {
if (!dfu.enterDFU(device)) { standardOutput << "Upload failed with code:" << retstatus << endl;
cout << "Error:Could not enter DFU mode\n";
return -1;
}
if (action == OP_DFU::actionProgram) {
if (((OP_DFU::device)dfu.devices[device]).Writable == false) {
cout << "ERROR device not Writable\n";
return false;
}
bool retstatus = dfu.UploadFirmware(file.toLatin1(), verify, device);
if (!retstatus) {
cout << "Upload failed with code:" << retstatus;
return -1; return -1;
} }
if (!description.isEmpty()) {
retstatus = dfu.UploadDescription(description);
if (retstatus != OP_DFU::Last_operation_Success) {
cout << "Upload failed with code:" << retstatus;
return -1;
}
}
cout << "Uploading Succeded!\n";
} else if (action == OP_DFU::actionDownload) {
if (((OP_DFU::device)dfu.devices[device]).Readable == false) {
cout << "ERROR device not readable\n";
return false;
}
qint32 size = ((OP_DFU::device)dfu.devices[device]).SizeOfCode;
QByteArray fw;
dfu.DownloadFirmware(&fw, 0);
bool ret = dfu.SaveByteArrayToFile(file.toLatin1(), fw);
return ret;
} else if (action == OP_DFU::actionCompareCrc) {
dfu.CompareFirmware(file.toLatin1(), OP_DFU::crccompare, device);
return 1;
} else if (action == OP_DFU::actionCompareAll) {
if (((OP_DFU::device)dfu.devices[device]).Readable == false) {
cout << "ERROR device not readable\n";
return false;
}
dfu.CompareFirmware(file.toLatin1(), OP_DFU::bytetobytecompare, device);
return 1;
} }
} else if (action == OP_DFU::actionStatusReq) { while (!dfu.isFinished()) {
cout << "Current device status=" << dfu.StatusToString(dfu.StatusRequest()).toLatin1().data() << "\n"; QThread::msleep(500);
} else if (action == OP_DFU::actionReset) { }
dfu.ResetDevice(); standardOutput << "Uploading Succeded!\n" << endl;
} else if (action == OP_DFU::actionJump) { } else if (action == OP_DFU::actionDownload) {
dfu.JumpToApp(false, false); if (((OP_DFU::device)dfu.devices[device]).Readable == false) {
standardOutput << "ERROR device not readable\n" << endl;
return false;
}
qint32 size = ((OP_DFU::device)dfu.devices[device]).SizeOfCode;
QByteArray fw;
dfu.DownloadFirmware(&fw, 0);
bool ret = dfu.SaveByteArrayToFile(file.toLatin1(), fw);
return ret;
} else if (action == OP_DFU::actionCompareCrc) {
dfu.CompareFirmware(file.toLatin1(), OP_DFU::crccompare, device);
return 1;
} else if (action == OP_DFU::actionCompareAll) {
if (((OP_DFU::device)dfu.devices[device]).Readable == false) {
standardOutput << "ERROR device not readable\n" << endl;
return false;
}
dfu.CompareFirmware(file.toLatin1(), OP_DFU::bytetobytecompare, device);
return 1;
} }
while(!dfu.isFinished()){ } else if (action == OP_DFU::actionStatusReq) {
QThread::msleep(500); standardOutput << "Current device status=" << dfu.StatusToString(dfu.StatusRequest()).toLatin1().data() << "\n" << endl;
} } else if (action == OP_DFU::actionReset) {
return 0; dfu.ResetDevice();
} else if (action == OP_DFU::actionJump) {
dfu.JumpToApp(false, false);
} }
return a.exec(); return 0;
// return a.exec();
}
void showProgress(QString status)
{
QTextStream standardOutput(stdout);
standardOutput << status << endl;
label = status;
}
void progressUpdated(int percent)
{
std::string bar;
for (int i = 0; i < 50; i++) {
if (i < (percent / 2)) {
bar.replace(i, 1, "=");
} else if (i == (percent / 2)) {
bar.replace(i, 1, ">");
} else {
bar.replace(i, 1, " ");
}
}
std::cout << "\r" << label.toLatin1().data() << "[" << bar << "] ";
std::cout.width(3);
std::cout << percent << "% " << std::flush;
}
void usage(QTextStream *standardOutput)
{
*standardOutput << "_________________________________________________________________________\n";
*standardOutput << "| Commands |\n";
*standardOutput << "| |\n";
*standardOutput << "| -ls : lists available devices |\n";
*standardOutput << "| -p <file> : program hw (requires:-d - optionals:-v,-w) |\n";
*standardOutput << "| -v : verify (requires:-d) |\n";
*standardOutput << "| -dn <file> : download firmware to file |\n";
// *standardOutput << "| -dd <file> : download discription (requires:-d) |\n";
*standardOutput << "| -d <Device Number> : target device number (default 0, first device) |\n";
// *standardOutput << "| -w <description> : (requires: -p) |\n";
*standardOutput << "| -ca <file> : compares byte by byte current firmware with file|\n";
*standardOutput << "| -cc <file> : compares CRC of current firmware with file |\n";
*standardOutput << "| -s : requests status of device |\n";
*standardOutput << "| -r : resets the device |\n";
*standardOutput << "| -j : exits bootloader and jumps to user FW |\n";
*standardOutput << "| -debug : prints debug information |\n";
*standardOutput << "| -t <port> : uses serial port |\n";
*standardOutput << "| -i : immediate, doesn't show the connection countdown|\n";
// *standardOutput << "| -ur <port> : user mode reset* |\n";
*standardOutput << "| |\n";
*standardOutput << "| examples: |\n";
*standardOutput << "| |\n";
*standardOutput << "| program and verify the fist device device connected to COM1 |\n";
*standardOutput << "| OPUploadTool -p c:/gpsp.opfw -v -t COM1 |\n";
*standardOutput << "| |\n";
*standardOutput << "| program and verify the fist device device connected to COM1 |\n";
*standardOutput << "| OPUploadTool -p c:/gpsp.opfw -v -t COM1 |\n";
*standardOutput << "| |\n";
*standardOutput << "| Perform a quick compare of FW in file with FW in device #1 |\n";
*standardOutput << "| OPUploadTool -ch /home/user1/gpsp.opfw -t ttyUSB0 |\n";
*standardOutput << "| |\n";
// *standardOutput << "| *requires valid user space firmwares already running |\n";
*standardOutput << "|________________________________________________________________________|\n";
*standardOutput << endl;
}
void howToUsage(QTextStream *standardOutput)
{
*standardOutput << "run the tool with -? for more informations" << endl;
} }

View File

@ -42,7 +42,7 @@ DFUObject::DFUObject(bool _debug, bool _use_serial, QString portname) :
qRegisterMetaType<OP_DFU::Status>("Status"); qRegisterMetaType<OP_DFU::Status>("Status");
if (use_serial) { if (use_serial) {
info = new port(portname, debug); info = new port(portname, false);
info->rxBuf = sspRxBuf; info->rxBuf = sspRxBuf;
info->rxBufSize = MAX_PACKET_DATA_LEN; info->rxBufSize = MAX_PACKET_DATA_LEN;
info->txBuf = sspTxBuf; info->txBuf = sspTxBuf;
@ -54,7 +54,7 @@ DFUObject::DFUObject(bool _debug, bool _use_serial, QString portname) :
mready = false; mready = false;
return; return;
} }
serialhandle = new qsspt(info, debug); serialhandle = new qsspt(info, false);
int count = 0; int count = 0;
while ((serialhandle->ssp_Synchronise() == false) && (count < 10)) { while ((serialhandle->ssp_Synchronise() == false) && (count < 10)) {
@ -311,25 +311,30 @@ bool DFUObject::UploadData(qint32 const & numberOfBytes, QByteArray & data)
buf[5] = packetcount; // DFU Count buf[5] = packetcount; // DFU Count
char *pointer = data.data(); char *pointer = data.data();
pointer = pointer + 4 * 14 * packetcount; pointer = pointer + 4 * 14 * packetcount;
qDebug()<<"Packet Number="<<packetcount<<"Data0="<<(int)data[0]<<" Data1="<<(int)data[1]<<" Data0="<<(int)data[2]<<" Data0="<<(int)data[3]<<" buf6="<<(int)buf[6]<<" buf7="<<(int)buf[7]<<" buf8="<<(int)buf[8]<<" buf9="<<(int)buf[9]; // if (debug) {
// qDebug() << "Packet Number=" << packetcount << "Data0=" << (int)data[0] << " Data1=" << (int)data[1] << " Data0=" << (int)data[2] << " Data0=" << (int)data[3] << " buf6=" << (int)buf[6] << " buf7=" << (int)buf[7] << " buf8=" << (int)buf[8] << " buf9=" << (int)buf[9];
// }
CopyWords(pointer, buf + 6, packetsize * 4); CopyWords(pointer, buf + 6, packetsize * 4);
//for (int y=0;y<packetsize*4;++y) { // for (int y=0;y<packetsize*4;++y) {
// qDebug()<<y<<":"<<(int)data[packetcount*14*4+y]<<"---"<<(int)buf[6+y]; // qDebug()<<y<<":"<<(int)data[packetcount*14*4+y]<<"---"<<(int)buf[6+y];
//} // }
//qDebug()<<" Data0="<<(int)data[0]<<" Data0="<<(int)data[1]<<" Data0="<<(int)data[2]<<" Data0="<<(int)data[3]<<" buf6="<<(int)buf[6]<<" buf7="<<(int)buf[7]<<" buf8="<<(int)buf[8]<<" buf9="<<(int)buf[9]; // qDebug()<<" Data0="<<(int)data[0]<<" Data0="<<(int)data[1]<<" Data0="<<(int)data[2]<<" Data0="<<(int)data[3]<<" buf6="<<(int)buf[6]<<" buf7="<<(int)buf[7]<<" buf8="<<(int)buf[8]<<" buf9="<<(int)buf[9];
// delay::msleep(send_delay); // delay::msleep(send_delay);
if(StatusRequest()!=OP_DFU::uploading) return false; if (StatusRequest() != OP_DFU::uploading) {
return false;
}
int result = sendData(buf, BUF_LEN); int result = sendData(buf, BUF_LEN);
qDebug()<<"sent:"<<result; // if (debug) {
// qDebug() << "sent:" << result;
// }
if (result < 1) { if (result < 1) {
return false; return false;
} }
// if (debug) {
qDebug() << "UPLOAD:"<<"Data="<<(int)buf[6]<<(int)buf[7]<<(int)buf[8]<<(int)buf[9]<<";"<<result << " bytes sent"; // qDebug() << "UPLOAD:" << "Data=" << (int)buf[6] << (int)buf[7] << (int)buf[8] << (int)buf[9] << ";" << result << " bytes sent";
// }
} }
cout << "\n";
// while(true){}
return true; return true;
} }
@ -510,16 +515,16 @@ int DFUObject::ResetDevice(void)
{ {
char buf[BUF_LEN]; char buf[BUF_LEN];
buf[0] = 0x02; // reportID buf[0] = 0x02; // reportID
buf[1] = OP_DFU::Reset; // DFU Command buf[1] = OP_DFU::Reset; // DFU Command
buf[2] = 0; buf[2] = 0;
buf[3] = 0; buf[3] = 0;
buf[4] = 0; buf[4] = 0;
buf[5] = 0; buf[5] = 0;
buf[6] = 0; buf[6] = 0;
buf[7] = 0; buf[7] = 0;
buf[8] = 0; buf[8] = 0;
buf[9] = 0; buf[9] = 0;
return sendData(buf, BUF_LEN); return sendData(buf, BUF_LEN);
// return hidHandle.send(0,buf, BUF_LEN, 500); // return hidHandle.send(0,buf, BUF_LEN, 500);

View File

@ -54,6 +54,7 @@ enum CompareType {
#define RESET "-r" #define RESET "-r"
#define JUMP "-j" #define JUMP "-j"
#define USE_SERIAL "-t" #define USE_SERIAL "-t"
#define NO_COUNTDOWN "-i"
Q_ENUMS(Status) Q_ENUMS(Status)
enum Status { enum Status {