mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-03-15 07:29:15 +01:00
OP-1476 - Make uploader_tool almost working
This commit is contained in:
parent
7e73c59e90
commit
85b397bc1f
@ -26,7 +26,8 @@
|
||||
*/
|
||||
#include "port.h"
|
||||
#include "delay.h"
|
||||
port::port(QString name) : mstatus(port::closed)
|
||||
#include <QDebug>
|
||||
port::port(QString name, bool debug) : mstatus(port::closed), debug(debug)
|
||||
{
|
||||
timer.start();
|
||||
sport = new QSerialPort();
|
||||
@ -56,12 +57,20 @@ port::portstatus port::status()
|
||||
{
|
||||
return mstatus;
|
||||
}
|
||||
|
||||
int16_t port::pfSerialRead(void)
|
||||
{
|
||||
char c[1];
|
||||
|
||||
if (sport->bytesAvailable()) {
|
||||
sport->waitForBytesWritten(5);
|
||||
if (sport->bytesAvailable() || sport->waitForReadyRead(1)) {
|
||||
sport->read(c, 1);
|
||||
if (debug) {
|
||||
if (((uint8_t)c[0]) == 0xe1 || rxDebugBuff.count() > 50) {
|
||||
qDebug() << "PORT R " << rxDebugBuff.toHex();
|
||||
rxDebugBuff.clear();
|
||||
}
|
||||
rxDebugBuff.append(c[0]);
|
||||
}
|
||||
} else { return -1; }
|
||||
return (uint8_t)c[0];
|
||||
}
|
||||
@ -72,6 +81,14 @@ void port::pfSerialWrite(uint8_t c)
|
||||
|
||||
cc[0] = c;
|
||||
sport->write(cc, 1);
|
||||
if (debug) {
|
||||
if (((uint8_t)cc[0]) == 0xe1 || rxDebugBuff.count() > 50) {
|
||||
qDebug() << "PORT T " << txDebugBuff.toHex();
|
||||
txDebugBuff.clear();
|
||||
}
|
||||
txDebugBuff.append(cc[0]);
|
||||
}
|
||||
sport->waitForBytesWritten(1);
|
||||
}
|
||||
|
||||
uint32_t port::pfGetTime(void)
|
||||
|
@ -63,10 +63,13 @@ public:
|
||||
uint32_t RxError;
|
||||
uint32_t TxError;
|
||||
uint16_t flags;
|
||||
port(QString name);
|
||||
port(QString name, bool debug);
|
||||
virtual ~port();
|
||||
portstatus status();
|
||||
private:
|
||||
bool debug;
|
||||
QByteArray rxDebugBuff;
|
||||
QByteArray txDebugBuff;
|
||||
portstatus mstatus;
|
||||
QTime timer;
|
||||
QSerialPort *sport;
|
||||
|
@ -282,7 +282,7 @@ uint16_t qssp::ssp_SendDataBlock(uint8_t *data, uint16_t length)
|
||||
* \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;
|
||||
|
||||
@ -525,6 +525,7 @@ uint16_t qssp::sf_crc16(uint16_t crc, uint8_t data)
|
||||
{
|
||||
#ifdef SPP_USES_CRC
|
||||
return (crc >> 8) ^ CRC_TABLE[(crc ^ data) & 0x00FF];
|
||||
|
||||
#else
|
||||
uint8_t cka = crc & 0xff;
|
||||
uint8_t ckb = (crc >> 8) & 0xff;
|
||||
|
@ -38,6 +38,7 @@
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#define SPP_USES_CRC
|
||||
#define SSP_TX_IDLE 0 // not expecting a ACK packet (no current transmissions in progress)
|
||||
#define SSP_TX_WAITING 1 // waiting for a valid ACK to arrive
|
||||
#define SSP_TX_TIMEOUT 2 // failed to receive a valid ACK in the timeout period, after retrying.
|
||||
|
@ -34,7 +34,6 @@ void qsspt::run()
|
||||
while (!endthread) {
|
||||
receivestatus = this->ssp_ReceiveProcess();
|
||||
sendstatus = this->ssp_SendProcess();
|
||||
msleep(1);
|
||||
sendbufmutex.lock();
|
||||
if (datapending && receivestatus == SSP_TX_IDLE) {
|
||||
this->ssp_SendData(mbuf, msize);
|
||||
@ -48,6 +47,13 @@ void qsspt::run()
|
||||
}
|
||||
bool qsspt::sendData(uint8_t *buf, uint16_t size)
|
||||
{
|
||||
if (debug) {
|
||||
QByteArray data;
|
||||
for (int i = 0; i < size; i++) {
|
||||
data.append((uint8_t)buf[i]);
|
||||
}
|
||||
qDebug() << "SSP TX " << data.toHex();
|
||||
}
|
||||
if (datapending) {
|
||||
return false;
|
||||
}
|
||||
@ -89,6 +95,9 @@ int qsspt::read_Packet(void *data)
|
||||
}
|
||||
QByteArray arr = queue.dequeue();
|
||||
memcpy(data, (uint8_t *)arr.data(), arr.length());
|
||||
if (debug) {
|
||||
qDebug() << "SSP RX " << arr.toHex();
|
||||
}
|
||||
mutex.unlock();
|
||||
return arr.length();
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ int main(int argc, char *argv[])
|
||||
cout << "| -p <file> : program hw (requires:-d - optionals:-v,-w) |\n";
|
||||
cout << "| -v : verify (requires:-d) |\n";
|
||||
cout << "| -dn <file> : download firmware to file (requires:-d) |\n";
|
||||
// cout<<"| -dd <file> : download discription (requires:-d) |\n";
|
||||
// cout << "| -dd <file> : download discription (requires:-d) |\n";
|
||||
cout << "| -d <number Of Device : (requires: -p or -dn) |\n";
|
||||
cout << "| -w <description> : (requires: -p) |\n";
|
||||
cout << "| -ca <file> : compares byte by byte current firmware with file|\n";
|
||||
@ -198,8 +198,9 @@ int main(int argc, char *argv[])
|
||||
cout << "Error:Invalid Device";
|
||||
return -1;
|
||||
}
|
||||
// if(dfu.numberOfDevices==1)
|
||||
// dfu.use_delay=false;
|
||||
if (dfu.numberOfDevices == 1) {
|
||||
dfu.use_delay = false;
|
||||
}
|
||||
if (!dfu.enterDFU(device)) {
|
||||
cout << "Error:Could not enter DFU mode\n";
|
||||
return -1;
|
||||
@ -251,7 +252,9 @@ int main(int argc, char *argv[])
|
||||
} else if (action == OP_DFU::actionJump) {
|
||||
dfu.JumpToApp(false, false);
|
||||
}
|
||||
|
||||
while(!dfu.isFinished()){
|
||||
QThread::msleep(500);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return a.exec();
|
||||
|
@ -42,13 +42,13 @@ DFUObject::DFUObject(bool _debug, bool _use_serial, QString portname) :
|
||||
qRegisterMetaType<OP_DFU::Status>("Status");
|
||||
|
||||
if (use_serial) {
|
||||
info = new port(portname);
|
||||
info = new port(portname, debug);
|
||||
info->rxBuf = sspRxBuf;
|
||||
info->rxBufSize = MAX_PACKET_DATA_LEN;
|
||||
info->txBuf = sspTxBuf;
|
||||
info->txBufSize = MAX_PACKET_DATA_LEN;
|
||||
info->max_retry = 10;
|
||||
info->timeoutLen = 1000;
|
||||
info->max_retry = 3;
|
||||
info->timeoutLen = 100;
|
||||
if (info->status() != port::open) {
|
||||
cout << "Could not open serial port\n";
|
||||
mready = false;
|
||||
@ -128,19 +128,19 @@ DFUObject::~DFUObject()
|
||||
delete info;
|
||||
}
|
||||
} /*else {
|
||||
hidHandle.close(0);
|
||||
}*/
|
||||
hidHandle.close(0);
|
||||
}*/
|
||||
}
|
||||
|
||||
void DFUObject::sendReset(void)
|
||||
{
|
||||
qDebug() << "Requesting user mode reset";
|
||||
char aa[255] = { 0x02, 0x3E, 0x3C, 0x20, 0x75, 0x00, 0x20, 0x4F, 0x67, 0x34, 0x62, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // 63
|
||||
char ba[255] = { 0x02, 0x3E, 0x3C, 0x20, 0x75, 0x00, 0x20, 0x4F, 0x67, 0x34, 0xB9, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
char ca[255] = { 0x02, 0x3E, 0x3C, 0x20, 0x75, 0x00, 0x20, 0x4F, 0x67, 0x34, 0x10, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
char bb[255] = { 0x02, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x8D, 0x19, 0x00, 0x00, 0x13 };
|
||||
char ab[255] = { 0x02, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x1B, 0x19, 0x00, 0x00, 0x76 };
|
||||
char cb[255] = { 0x02, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x78, 0x1C, 0x00, 0x00, 0x25 };
|
||||
uint8_t aa[255] = { 0x02, 0x3E, 0x3C, 0x20, 0x75, 0x00, 0x20, 0x4F, 0x67, 0x34, 0x62, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // 63
|
||||
uint8_t ba[255] = { 0x02, 0x3E, 0x3C, 0x20, 0x75, 0x00, 0x20, 0x4F, 0x67, 0x34, 0xB9, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
uint8_t ca[255] = { 0x02, 0x3E, 0x3C, 0x20, 0x75, 0x00, 0x20, 0x4F, 0x67, 0x34, 0x10, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
uint8_t bb[255] = { 0x02, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x8D, 0x19, 0x00, 0x00, 0x13 };
|
||||
uint8_t ab[255] = { 0x02, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x1B, 0x19, 0x00, 0x00, 0x76 };
|
||||
uint8_t cb[255] = { 0x02, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x78, 0x1C, 0x00, 0x00, 0x25 };
|
||||
// 125
|
||||
/*if (!use_serial) {
|
||||
hidHandle.send(0, aa, 64, 5000);
|
||||
@ -153,28 +153,28 @@ void DFUObject::sendReset(void)
|
||||
hidHandle.send(0, cb, 64, 5000);
|
||||
delay::msleep(100);
|
||||
hidHandle.close(1);
|
||||
} else {*/
|
||||
char a[255];
|
||||
char b[255];
|
||||
char c[255];
|
||||
memcpy(a, aa + 2, 62);
|
||||
memcpy(a + 62, ab + 2, 60);
|
||||
memcpy(b, ba + 2, 62);
|
||||
memcpy(b + 62, bb + 2, 60);
|
||||
memcpy(c, ca + 2, 62);
|
||||
memcpy(c + 62, cb + 2, 60);
|
||||
for (int x = 0; x < 123; ++x) {
|
||||
info->pfSerialWrite(a[x]);
|
||||
}
|
||||
delay::msleep(600);
|
||||
for (int x = 0; x < 123; ++x) {
|
||||
info->pfSerialWrite(b[x]);
|
||||
}
|
||||
delay::msleep(600);
|
||||
for (int x = 0; x < 123; ++x) {
|
||||
info->pfSerialWrite(c[x]);
|
||||
}
|
||||
//}
|
||||
} else {*/
|
||||
char a[255];
|
||||
char b[255];
|
||||
char c[255];
|
||||
memcpy(a, aa + 2, 62);
|
||||
memcpy(a + 62, ab + 2, 60);
|
||||
memcpy(b, ba + 2, 62);
|
||||
memcpy(b + 62, bb + 2, 60);
|
||||
memcpy(c, ca + 2, 62);
|
||||
memcpy(c + 62, cb + 2, 60);
|
||||
for (int x = 0; x < 123; ++x) {
|
||||
info->pfSerialWrite(a[x]);
|
||||
}
|
||||
delay::msleep(600);
|
||||
for (int x = 0; x < 123; ++x) {
|
||||
info->pfSerialWrite(b[x]);
|
||||
}
|
||||
delay::msleep(600);
|
||||
for (int x = 0; x < 123; ++x) {
|
||||
info->pfSerialWrite(c[x]);
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
bool DFUObject::SaveByteArrayToFile(QString const & sfile, const QByteArray &array)
|
||||
@ -211,6 +211,7 @@ bool DFUObject::enterDFU(int const &devNumber)
|
||||
buf[9] = 1; // DFU Data3
|
||||
|
||||
int result = sendData(buf, BUF_LEN);
|
||||
|
||||
if (result < 1) {
|
||||
return false;
|
||||
}
|
||||
@ -310,26 +311,22 @@ bool DFUObject::UploadData(qint32 const & numberOfBytes, QByteArray & data)
|
||||
buf[5] = packetcount; // DFU Count
|
||||
char *pointer = data.data();
|
||||
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];
|
||||
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);
|
||||
// for (int y=0;y<packetsize*4;++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];
|
||||
//for (int y=0;y<packetsize*4;++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];
|
||||
// delay::msleep(send_delay);
|
||||
|
||||
// if(StatusRequest()!=OP_DFU::uploading) return false;
|
||||
if(StatusRequest()!=OP_DFU::uploading) return false;
|
||||
int result = sendData(buf, BUF_LEN);
|
||||
// qDebug()<<"sent:"<<result;
|
||||
qDebug()<<"sent:"<<result;
|
||||
if (result < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 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){}
|
||||
@ -513,16 +510,16 @@ int DFUObject::ResetDevice(void)
|
||||
{
|
||||
char buf[BUF_LEN];
|
||||
|
||||
buf[0] = 0x02; // reportID
|
||||
buf[1] = OP_DFU::Reset; // DFU Command
|
||||
buf[2] = 0;
|
||||
-- buf[3] = 0;
|
||||
buf[4] = 0;
|
||||
buf[5] = 0;
|
||||
buf[6] = 0;
|
||||
buf[7] = 0;
|
||||
buf[8] = 0;
|
||||
buf[9] = 0;
|
||||
buf[0] = 0x02; // reportID
|
||||
buf[1] = OP_DFU::Reset; // DFU Command
|
||||
buf[2] = 0;
|
||||
buf[3] = 0;
|
||||
buf[4] = 0;
|
||||
buf[5] = 0;
|
||||
buf[6] = 0;
|
||||
buf[7] = 0;
|
||||
buf[8] = 0;
|
||||
buf[9] = 0;
|
||||
|
||||
return sendData(buf, BUF_LEN);
|
||||
// return hidHandle.send(0,buf, BUF_LEN, 500);
|
||||
@ -656,7 +653,6 @@ bool DFUObject::findDevices()
|
||||
if (result < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
result = receiveData(buf, BUF_LEN);
|
||||
if (result < 1) {
|
||||
return false;
|
||||
@ -1072,7 +1068,7 @@ int DFUObject::sendData(void *data, int size)
|
||||
{
|
||||
/*if (!use_serial) {
|
||||
return hidHandle.send(0, data, size, 5000);
|
||||
}*/
|
||||
}*/
|
||||
|
||||
// Serial Mode:
|
||||
if (serialhandle->sendData((uint8_t *)data + 1, size - 1)) {
|
||||
@ -1096,14 +1092,16 @@ int DFUObject::receiveData(void *data, int size)
|
||||
{
|
||||
/*if (!use_serial) {
|
||||
return hidHandle.receive(0, data, size, 10000);
|
||||
}*/
|
||||
}*/
|
||||
|
||||
// Serial Mode:
|
||||
int x;
|
||||
QTime time;
|
||||
|
||||
time.start();
|
||||
while (true) {
|
||||
if ((x = serialhandle->read_Packet(((char *)data) + 1) != -1) || time.elapsed() > 10000) {
|
||||
msleep(10);
|
||||
if (time.elapsed() > 10000) {
|
||||
qDebug() << "____timeout";
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
#define OP_DFU_H
|
||||
|
||||
#include <QByteArray>
|
||||
//#include <ophid/inc/ophid_hidapi.h>
|
||||
//#include <ophid/inc/ophid_usbmon.h>
|
||||
//#include <ophid/inc/ophid_usbsignal.h>
|
||||
// #include <ophid/inc/ophid_hidapi.h>
|
||||
// #include <ophid/inc/ophid_usbmon.h>
|
||||
// #include <ophid/inc/ophid_usbsignal.h>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QThread>
|
||||
@ -41,19 +41,19 @@ enum CompareType {
|
||||
bytetobytecompare
|
||||
};
|
||||
// Command Line Options
|
||||
#define DOWNLOAD "-dn" // done
|
||||
#define DEVICE "-d" // done
|
||||
// #define DOWNDESCRIPTION "-dd" //done
|
||||
#define PROGRAMFW "-p" // done
|
||||
#define PROGRAMDESC "-w" // done
|
||||
#define VERIFY "-v" // done
|
||||
#define COMPARECRC "-cc"
|
||||
#define COMPAREALL "-ca"
|
||||
#define STATUSREQUEST "-s" // done
|
||||
#define LISTDEVICES "-ls" // done
|
||||
#define RESET "-r"
|
||||
#define JUMP "-j"
|
||||
#define USE_SERIAL "-t"
|
||||
#define DOWNLOAD "-dn" // done
|
||||
#define DEVICE "-d" // done
|
||||
#define DOWNDESCRIPTION "-dd" // done
|
||||
#define PROGRAMFW "-p" // done
|
||||
#define PROGRAMDESC "-w" // done
|
||||
#define VERIFY "-v" // done
|
||||
#define COMPARECRC "-cc"
|
||||
#define COMPAREALL "-ca"
|
||||
#define STATUSREQUEST "-s" // done
|
||||
#define LISTDEVICES "-ls" // done
|
||||
#define RESET "-r"
|
||||
#define JUMP "-j"
|
||||
#define USE_SERIAL "-t"
|
||||
|
||||
Q_ENUMS(Status)
|
||||
enum Status {
|
||||
@ -197,7 +197,7 @@ private:
|
||||
|
||||
|
||||
// USB Bootloader:
|
||||
//opHID_hidapi hidHandle;
|
||||
// opHID_hidapi hidHandle;
|
||||
int setStartBit(int command)
|
||||
{
|
||||
return command | 0x20;
|
||||
|
Loading…
x
Reference in New Issue
Block a user