Merge branch '2.2' into 2.3

This commit is contained in:
3djc
2018-07-06 07:16:27 +02:00
6 changed files with 87 additions and 72 deletions
+31 -17
View File
@@ -82,8 +82,9 @@ const char * const OPENTX_COMPANION_DOWNLOAD_URL[] = {
}; };
MainWindow::MainWindow(): MainWindow::MainWindow():
downloadDialog_forWait(NULL), downloadDialog_forWait(nullptr),
checkForUpdatesState(0), checkForUpdatesState(0),
networkManager(nullptr),
windowsListActions(new QActionGroup(this)) windowsListActions(new QActionGroup(this))
{ {
// setUnifiedTitleAndToolBarOnMac(true); // setUnifiedTitleAndToolBarOnMac(true);
@@ -260,39 +261,50 @@ QString MainWindow::getCompanionUpdateBaseUrl()
void MainWindow::checkForUpdates() void MainWindow::checkForUpdates()
{ {
if (!checkForUpdatesState) {
closeUpdatesWaitDialog();
if (networkManager) {
networkManager->deleteLater();
networkManager = nullptr;
}
return;
}
if (checkForUpdatesState & SHOW_DIALOG_WAIT) { if (checkForUpdatesState & SHOW_DIALOG_WAIT) {
checkForUpdatesState -= SHOW_DIALOG_WAIT; checkForUpdatesState -= SHOW_DIALOG_WAIT;
downloadDialog_forWait = new downloadDialog(NULL, tr("Checking for updates")); downloadDialog_forWait = new downloadDialog(NULL, tr("Checking for updates"));
downloadDialog_forWait->show(); downloadDialog_forWait->show();
} }
if (networkManager)
disconnect(networkManager, 0, this, 0);
else
networkManager = new QNetworkAccessManager(this);
QUrl url;
if (checkForUpdatesState & CHECK_COMPANION) { if (checkForUpdatesState & CHECK_COMPANION) {
checkForUpdatesState -= CHECK_COMPANION; checkForUpdatesState -= CHECK_COMPANION;
// TODO why create each time a network manager? url.setUrl(QString("%1/%2").arg(getCompanionUpdateBaseUrl()).arg(COMPANION_STAMP));
networkManager = new QNetworkAccessManager(this); connect(networkManager, &QNetworkAccessManager::finished, this, &MainWindow::checkForCompanionUpdateFinished);
connect(networkManager, SIGNAL(finished(QNetworkReply*)),this, SLOT(checkForCompanionUpdateFinished(QNetworkReply*)));
QUrl url(QString("%1/%2").arg(getCompanionUpdateBaseUrl()).arg(COMPANION_STAMP));
qDebug() << "Checking for Companion update " << url.url(); qDebug() << "Checking for Companion update " << url.url();
QNetworkRequest request(url);
request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
networkManager->get(request);
} }
else if (checkForUpdatesState & CHECK_FIRMWARE) { else if (checkForUpdatesState & CHECK_FIRMWARE) {
checkForUpdatesState -= CHECK_FIRMWARE; checkForUpdatesState -= CHECK_FIRMWARE;
QString stamp = getCurrentFirmware()->getStampUrl(); const QString stamp = getCurrentFirmware()->getStampUrl();
if (!stamp.isEmpty()) { if (!stamp.isEmpty()) {
networkManager = new QNetworkAccessManager(this); url.setUrl(stamp);
connect(networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(checkForFirmwareUpdateFinished(QNetworkReply*))); connect(networkManager, &QNetworkAccessManager::finished, this, &MainWindow::checkForFirmwareUpdateFinished);
QUrl url(stamp);
qDebug() << "Checking for firmware update " << url.url(); qDebug() << "Checking for firmware update " << url.url();
QNetworkRequest request(url);
request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
networkManager->get(request);
} }
} }
else if (checkForUpdatesState==0) { if (!url.isValid()) {
closeUpdatesWaitDialog(); checkForUpdates();
return;
} }
QNetworkRequest request(url);
request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
networkManager->get(request);
} }
void MainWindow::onUpdatesError() void MainWindow::onUpdatesError()
@@ -328,6 +340,7 @@ QString MainWindow::seekCodeString(const QByteArray & qba, const QString & label
void MainWindow::checkForCompanionUpdateFinished(QNetworkReply * reply) void MainWindow::checkForCompanionUpdateFinished(QNetworkReply * reply)
{ {
QByteArray qba = reply->readAll(); QByteArray qba = reply->readAll();
reply->deleteLater();
QString version = seekCodeString(qba, "VERSION"); QString version = seekCodeString(qba, "VERSION");
if (version.isNull()) if (version.isNull())
return onUpdatesError(); return onUpdatesError();
@@ -439,6 +452,7 @@ void MainWindow::checkForFirmwareUpdateFinished(QNetworkReply * reply)
bool ignore = false; bool ignore = false;
QByteArray qba = reply->readAll(); QByteArray qba = reply->readAll();
reply->deleteLater();
QString versionString = seekCodeString(qba, "VERSION"); QString versionString = seekCodeString(qba, "VERSION");
QString dateString = seekCodeString(qba, "DATE"); QString dateString = seekCodeString(qba, "DATE");
if (versionString.isNull() || dateString.isNull()) if (versionString.isNull() || dateString.isNull())
@@ -48,5 +48,6 @@ void ReleaseNotesFirmwareDialog::replyFinished(QNetworkReply * reply)
{ {
ui->textEditor->setHtml(reply->readAll()); ui->textEditor->setHtml(reply->readAll());
ui->textEditor->setOpenExternalLinks(true); ui->textEditor->setOpenExternalLinks(true);
reply->deleteLater();
} }
+17 -14
View File
@@ -22,7 +22,10 @@
// i.e. BACKUP RAM Backup/Restore functions // i.e. BACKUP RAM Backup/Restore functions
#include <inttypes.h> #include <inttypes.h>
#include "board.h"
#include "dataconstants.h" #include "dataconstants.h"
#include "definitions.h"
#define ARM_FIELD(x) x; #define ARM_FIELD(x) x;
#define AVR_FIELD(x) #define AVR_FIELD(x)
@@ -168,10 +171,10 @@ PACK(struct CustomFunctionData {
NOBACKUP(CFN_SPARE_TYPE spare); NOBACKUP(CFN_SPARE_TYPE spare);
}) all; }) all;
PACK(struct { NOBACKUP(PACK(struct {
int32_t val1; int32_t val1;
NOBACKUP(CFN_SPARE_TYPE val2); NOBACKUP(CFN_SPARE_TYPE val2);
}) clear; }) clear);
}); });
uint8_t active; uint8_t active;
}); });
@@ -371,11 +374,11 @@ PACK(struct MavlinkTelemetryData {
PACK(struct TelemetrySensor { PACK(struct TelemetrySensor {
union { union {
uint16_t id; // data identifier, for FrSky we can reuse existing ones. Source unit is derived from type. uint16_t id; // data identifier, for FrSky we can reuse existing ones. Source unit is derived from type.
uint16_t persistentValue; NOBACKUP(uint16_t persistentValue);
}; };
union { union {
uint8_t instance; // instance ID to allow handling multiple instances of same value type, for FrSky can be the physical ID of the sensor uint8_t instance; // instance ID to allow handling multiple instances of same value type, for FrSky can be the physical ID of the sensor
uint8_t formula; NOBACKUP(uint8_t formula);
}; };
char label[TELEM_LABEL_LEN]; // user defined label char label[TELEM_LABEL_LEN]; // user defined label
uint8_t type:1; // 0=custom / 1=calculated uint8_t type:1; // 0=custom / 1=calculated
@@ -388,27 +391,27 @@ PACK(struct TelemetrySensor {
uint8_t onlyPositive:1; uint8_t onlyPositive:1;
uint8_t subId:3; uint8_t subId:3;
union { union {
PACK(struct { NOBACKUP(PACK(struct {
uint16_t ratio; uint16_t ratio;
int16_t offset; int16_t offset;
}) custom; }) custom);
PACK(struct { NOBACKUP(PACK(struct {
uint8_t source; uint8_t source;
uint8_t index; uint8_t index;
uint16_t spare; uint16_t spare;
}) cell; }) cell);
PACK(struct { NOBACKUP(PACK(struct {
int8_t sources[4]; int8_t sources[4];
}) calc; }) calc);
PACK(struct { NOBACKUP(PACK(struct {
uint8_t source; uint8_t source;
uint8_t spare[3]; uint8_t spare[3];
}) consumption; }) consumption);
PACK(struct { NOBACKUP(PACK(struct {
uint8_t gps; uint8_t gps;
uint8_t alt; uint8_t alt;
uint16_t spare; uint16_t spare;
}) dist; }) dist);
uint32_t param; uint32_t param;
}; };
NOBACKUP( NOBACKUP(
+24 -35
View File
@@ -1,4 +1,4 @@
//This file was auto-generated by generate_datacopy.py script on Sat May 7 11:05:00 2016. Do not edit this file! //This file was auto-generated by generate_datacopy.py script on Mon Jul 2 14:20:48 2018. Do not edit this file!
@@ -91,7 +91,7 @@ void copytrim_t(A * dest, B * src)
template <class A, class B> template <class A, class B>
void copyFlightModeData(A * dest, B * src) void copyFlightModeData(A * dest, B * src)
{ {
for (int i=0; i<NUM_STICKS; i++) { for (int i=0; i<6; i++) {
copytrim_t(&dest->trim[i], &src->trim[i]); copytrim_t(&dest->trim[i], &src->trim[i]);
} }
dest->swtch = src->swtch; dest->swtch = src->swtch;
@@ -101,6 +101,14 @@ void copyFlightModeData(A * dest, B * src)
memcpy(dest->gvars, src->gvars, sizeof(dest->gvars)); memcpy(dest->gvars, src->gvars, sizeof(dest->gvars));
} }
template <class A, class B>
void copyCurveData(A * dest, B * src)
{
dest->type = src->type;
dest->smooth = src->smooth;
dest->points = src->points;
}
template <class A, class B> template <class A, class B>
void copyGVarData(A * dest, B * src) void copyGVarData(A * dest, B * src)
{ {
@@ -122,6 +130,7 @@ void copyTimerData(A * dest, B * src)
dest->minuteBeep = src->minuteBeep; dest->minuteBeep = src->minuteBeep;
dest->persistent = src->persistent; dest->persistent = src->persistent;
dest->countdownStart = src->countdownStart; dest->countdownStart = src->countdownStart;
dest->direction = src->direction;
} }
template <class A, class B> template <class A, class B>
@@ -146,10 +155,13 @@ void copyScriptData(A * dest, B * src)
} }
template <class A, class B> template <class A, class B>
void copyFrSkyRSSIAlarm(A * dest, B * src) void copyRssiAlarmData(A * dest, B * src)
{ {
dest->level = src->level; dest->disabled = src->disabled;
dest->value = src->value; dest->spare = src->spare;
dest->warning = src->warning;
dest->spare2 = src->spare2;
dest->critical = src->critical;
} }
template <class A, class B> template <class A, class B>
@@ -161,9 +173,6 @@ void copyFrSkyTelemetryData(A * dest, B * src)
dest->varioCenterMin = src->varioCenterMin; dest->varioCenterMin = src->varioCenterMin;
dest->varioMin = src->varioMin; dest->varioMin = src->varioMin;
dest->varioMax = src->varioMax; dest->varioMax = src->varioMax;
for (int i=0; i<2; i++) {
copyFrSkyRSSIAlarm(&dest->rssiAlarms[i], &src->rssiAlarms[i]);
}
} }
template <class A, class B> template <class A, class B>
@@ -181,7 +190,7 @@ void copyTelemetrySensor(A * dest, B * src)
dest->persistent = src->persistent; dest->persistent = src->persistent;
dest->onlyPositive = src->onlyPositive; dest->onlyPositive = src->onlyPositive;
dest->subId = src->subId; dest->subId = src->subId;
copyTelemetrySensor_custom(&dest->custom, &src->custom); dest->param = src->param;
} }
template <class A, class B> template <class A, class B>
@@ -205,23 +214,6 @@ void copyModelHeader(A * dest, B * src)
memcpy(dest->modelId, src->modelId, sizeof(dest->modelId)); memcpy(dest->modelId, src->modelId, sizeof(dest->modelId));
} }
template <class A, class B>
void copyZone(A * dest, B * src)
{
dest->x = src->x;
dest->y = src->y;
dest->w = src->w;
dest->h = src->h;
}
template <class A, class B>
void copyZoneOption(A * dest, B * src)
{
dest->name = src->name;
dest->type = src->type;
dest->deflt = src->deflt;
}
template <class A, class B> template <class A, class B>
void copyCustomScreenData(A * dest, B * src) void copyCustomScreenData(A * dest, B * src)
{ {
@@ -257,7 +249,9 @@ void copyModelData(A * dest, B * src)
for (int i=0; i<64; i++) { for (int i=0; i<64; i++) {
copyExpoData(&dest->expoData[i], &src->expoData[i]); copyExpoData(&dest->expoData[i], &src->expoData[i]);
} }
memcpy(dest->curves, src->curves, sizeof(dest->curves)); for (int i=0; i<32; i++) {
copyCurveData(&dest->curves[i], &src->curves[i]);
}
memcpy(dest->points, src->points, sizeof(dest->points)); memcpy(dest->points, src->points, sizeof(dest->points));
for (int i=0; i<64; i++) { for (int i=0; i<64; i++) {
copyLogicalSwitchData(&dest->logicalSw[i], &src->logicalSw[i]); copyLogicalSwitchData(&dest->logicalSw[i], &src->logicalSw[i]);
@@ -309,10 +303,12 @@ void copyTrainerData(A * dest, B * src)
template <class A, class B> template <class A, class B>
void copyRadioData(A * dest, B * src) void copyRadioData(A * dest, B * src)
{ {
for (int i=0; i<11; i++) { for (int i=0; i<13; i++) {
copyCalibData(&dest->calib[i], &src->calib[i]); copyCalibData(&dest->calib[i], &src->calib[i]);
} }
dest->stickMode = src->stickMode; dest->stickMode = src->stickMode;
dest->telemetryBaudrate = src->telemetryBaudrate;
dest->splashSpares = src->splashSpares;
dest->switchesDelay = src->switchesDelay; dest->switchesDelay = src->switchesDelay;
for (int i=0; i<64; i++) { for (int i=0; i<64; i++) {
copyCustomFunctionData(&dest->customFn[i], &src->customFn[i]); copyCustomFunctionData(&dest->customFn[i], &src->customFn[i]);
@@ -330,13 +326,6 @@ void copyCustomFunctionData_all(A * dest, B * src)
dest->param = src->param; dest->param = src->param;
} }
template <class A, class B>
void copyTelemetrySensor_custom(A * dest, B * src)
{
dest->ratio = src->ratio;
dest->offset = src->offset;
}
template <class A, class B> template <class A, class B>
void copyModuleData_ppm(A * dest, B * src) void copyModuleData_ppm(A * dest, B * src)
{ {
+1 -1
View File
@@ -155,7 +155,7 @@ set(STM32LIB_SRC
if(PYTHONINTERP_FOUND) if(PYTHONINTERP_FOUND)
add_custom_target(datacopy add_custom_target(datacopy
WORKING_DIRECTORY ${RADIO_DIRECTORY}/src WORKING_DIRECTORY ${RADIO_DIRECTORY}/src
COMMAND ${PYTHON_EXECUTABLE} ${RADIO_DIRECTORY}/util/generate_datacopy.py datastructs.h -DPCBHORUS -DCPUARM -DCOLORLCD -DCPUARM -DBACKUP > storage/datacopy.cpp COMMAND ${PYTHON_EXECUTABLE} ${RADIO_DIRECTORY}/util/generate_datacopy.py datastructs.h -DPCBHORUS -DPCBX10 -DCPUARM -DCOLORLCD -DBACKUP -DVIRTUAL_INPUTS -Itargets/horus > storage/datacopy.cpp
DEPENDS ${RADIO_DIRECTORY}/src/datastructs.h ${RADIO_DIRECTORY}/util/generate_datacopy.py DEPENDS ${RADIO_DIRECTORY}/src/datastructs.h ${RADIO_DIRECTORY}/util/generate_datacopy.py
) )
endif() endif()
+13 -5
View File
@@ -8,8 +8,16 @@ import time
import os import os
if sys.platform == "darwin": if sys.platform == "darwin":
clang.cindex.Config.set_library_file('/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib') if os.path.exists('/usr/local/Cellar/llvm/6.0.0/lib/libclang.dylib'):
clang.cindex.Config.set_library_file('/usr/local/Cellar/llvm/6.0.0/lib/libclang.dylib')
elif os.path.exists('/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib'):
clang.cindex.Config.set_library_file('/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib')
elif os.path.exists('/Library/Developer/CommandLineTools/usr/lib/libclang.dylib'):
clang.cindex.Config.set_library_file('/Library/Developer/CommandLineTools/usr/lib/libclang.dylib')
if sys.platform == "linux2":
if os.path.exists('/usr/lib/x86_64-linux-gnu/libclang-3.8.so.1'):
clang.cindex.Config.set_library_file('/usr/lib/x86_64-linux-gnu/libclang-3.8.so.1')
structs = [] structs = []
extrastructs = [] extrastructs = []
@@ -41,15 +49,15 @@ def build_struct(cursor, anonymousUnion=False):
elif c.kind == clang.cindex.CursorKind.FIELD_DECL: elif c.kind == clang.cindex.CursorKind.FIELD_DECL:
copy_decl(c, c.spelling) copy_decl(c, c.spelling)
if not anonymousUnion: if not anonymousUnion:
print("}\n") print("}\n")
def build(cursor): def build(cursor):
result = [] result = []
for c in cursor.get_children(): for c in cursor.get_children():
if c.kind == clang.cindex.CursorKind.STRUCT_DECL: if c.location.file.name == sys.argv[1]:
build_struct(c) if c.kind == clang.cindex.CursorKind.STRUCT_DECL:
build_struct(c)
for c, spelling in extrastructs: for c, spelling in extrastructs:
print("template <class A, class B>\nvoid copy%s(A * dest, B * src)\n{" % spelling) print("template <class A, class B>\nvoid copy%s(A * dest, B * src)\n{" % spelling)
build_struct(c, True) build_struct(c, True)
@@ -67,7 +75,7 @@ def copy_decl(c, spelling):
print(" }") print(" }")
else: else:
print(" memcpy(dest->%s, src->%s, sizeof(dest->%s));" % (spelling, spelling, spelling)) print(" memcpy(dest->%s, src->%s, sizeof(dest->%s));" % (spelling, spelling, spelling))
elif c.type.kind == clang.cindex.TypeKind.UNEXPOSED and len(childs)==1 and childs[0].kind == clang.cindex.CursorKind.STRUCT_DECL: elif len(childs)==1 and childs[0].kind == clang.cindex.CursorKind.STRUCT_DECL and not childs[0].spelling:
# inline declared structs # inline declared structs
if c.semantic_parent.spelling: if c.semantic_parent.spelling:
spellingFunc = c.semantic_parent.spelling + "_" + spelling spellingFunc = c.semantic_parent.spelling + "_" + spelling