diff --git a/ground/src/experimental/USB_UPLOAD_TOOL/delay.cpp b/ground/src/experimental/USB_UPLOAD_TOOL/delay.cpp new file mode 100644 index 000000000..b8bb87265 --- /dev/null +++ b/ground/src/experimental/USB_UPLOAD_TOOL/delay.cpp @@ -0,0 +1,2 @@ +#include "delay.h" + diff --git a/ground/src/experimental/USB_UPLOAD_TOOL/delay.h b/ground/src/experimental/USB_UPLOAD_TOOL/delay.h new file mode 100644 index 000000000..ccf14ee5b --- /dev/null +++ b/ground/src/experimental/USB_UPLOAD_TOOL/delay.h @@ -0,0 +1,13 @@ +#ifndef DELAY_H +#define DELAY_H +#include + +class delay : public QThread +{ +public: + static void msleep(unsigned long msecs) + { + QThread::msleep(msecs); + } +}; +#endif // DELAY_H diff --git a/ground/src/experimental/USB_UPLOAD_TOOL/main.cpp b/ground/src/experimental/USB_UPLOAD_TOOL/main.cpp index 91bb00196..47c7c8982 100644 --- a/ground/src/experimental/USB_UPLOAD_TOOL/main.cpp +++ b/ground/src/experimental/USB_UPLOAD_TOOL/main.cpp @@ -184,6 +184,11 @@ int main(int argc, char *argv[]) cout<<"Could not enter DFU mode\n"; return -1; } + if (debug) + { + OP_DFU::Status ret=dfu.StatusRequest(); + qDebug()<>16; buf[10] = crc>>8; buf[11] = crc; - - qDebug()<<"Number of packets:"<>24;//DFU Count buf[3] = packetcount>>16;//DFU Count buf[4] = packetcount>>8;//DFU Count @@ -151,8 +148,9 @@ bool OP_DFU::UploadData(qint32 const & numberOfBytes, QByteArray & data) // } // 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); int result = hidHandle.send(0,buf, BUF_LEN, 5000); + // qDebug()<<"sent:"< #include #include +#include "delay.h" using namespace std; #define BUF_LEN 64 @@ -41,19 +42,20 @@ public: enum Status { - DFUidle, - uploading, - wrong_packet_received, - too_many_packets, - too_few_packets, - Last_operation_Success, - downloading, - idle, - Last_operation_failed, - outsideDevCapabilities, - CRC_Fail, - failed_jump, - abort + DFUidle,//0 + uploading,//1 + wrong_packet_received,//2 + too_many_packets,//3 + too_few_packets,//4 + Last_operation_Success,//5 + downloading,//6 + idle,//7 + Last_operation_failed,//8 + uploadingStarting,//9 + outsideDevCapabilities,//10 + CRC_Fail,//11 + failed_jump,//12 + abort//13 }; enum Actions @@ -121,6 +123,7 @@ public: quint32 CRC32WideFast(quint32 Crc, quint32 Size, quint32 *Buffer); quint32 CRCFromQBArray(QByteArray array, quint32 Size); void test(); + int send_delay; private: bool debug; int RWFlags; diff --git a/ground/src/experimental/USB_UPLOAD_TOOL/upload.pro b/ground/src/experimental/USB_UPLOAD_TOOL/upload.pro index b89b2dbd1..f36bf6334 100644 --- a/ground/src/experimental/USB_UPLOAD_TOOL/upload.pro +++ b/ground/src/experimental/USB_UPLOAD_TOOL/upload.pro @@ -15,9 +15,11 @@ CONFIG -= app_bundle TEMPLATE = app SOURCES += main.cpp \ - op_dfu.cpp + op_dfu.cpp \ + delay.cpp HEADERS += ../../plugins/rawhid/pjrc_rawhid.h \ - op_dfu.h + op_dfu.h \ + delay.h win32 { SOURCES += ../../plugins/rawhid/pjrc_rawhid_win.cpp