From 84aeed89141862a6b4f423118bece4fe23dd3193 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Wed, 21 Aug 2019 09:54:11 +0200 Subject: [PATCH 1/7] stub for companion storage tests --- companion/src/CMakeLists.txt | 4 + companion/src/tests/CMakeLists.txt | 33 ++++++ companion/src/tests/conversions.cpp | 13 +++ companion/src/tests/eeprom_22_x9d+.bin | Bin 0 -> 32768 bytes companion/src/tests/gtests.cpp | 149 +++++++++++++++++++++++++ companion/src/tests/gtests.h | 96 ++++++++++++++++ companion/src/tests/location.h.in | 1 + 7 files changed, 296 insertions(+) create mode 100644 companion/src/tests/CMakeLists.txt create mode 100644 companion/src/tests/conversions.cpp create mode 100644 companion/src/tests/eeprom_22_x9d+.bin create mode 100644 companion/src/tests/gtests.cpp create mode 100644 companion/src/tests/gtests.h create mode 100644 companion/src/tests/location.h.in diff --git a/companion/src/CMakeLists.txt b/companion/src/CMakeLists.txt index d5fd9976d..58ae89720 100644 --- a/companion/src/CMakeLists.txt +++ b/companion/src/CMakeLists.txt @@ -326,6 +326,10 @@ set(simu_SRCS simulator.cpp ) add_executable(${SIMULATOR_NAME} MACOSX_BUNDLE ${WIN_EXECUTABLE_TYPE} ${simu_SRCS} ${icon_RC}) target_link_libraries(${SIMULATOR_NAME} PRIVATE ${CPN_COMMON_LIB}) +if(NOT MSVC) + add_subdirectory(tests) +endif() + ############# Install #################### # Generate list of simulator plugins, used by all platforms diff --git a/companion/src/tests/CMakeLists.txt b/companion/src/tests/CMakeLists.txt new file mode 100644 index 000000000..12511e8b6 --- /dev/null +++ b/companion/src/tests/CMakeLists.txt @@ -0,0 +1,33 @@ +set(GTEST_ROOT /usr CACHE STRING "Base path to Google Test headers and source.") + +find_path(GTEST_INCDIR gtest/gtest.h HINTS "${GTEST_ROOT}/include" DOC "Path to Google Test header files folder ('gtest/gtest.h').") +find_path(GTEST_SRCDIR src/gtest-all.cc HINTS "${GTEST_ROOT}" "${GTEST_ROOT}/src/gtest" DOC "Path of Google Test 'src' folder.") + +if(GTEST_INCDIR AND GTEST_SRCDIR AND Qt5Widgets_FOUND) + add_library(gtests-cpn-lib STATIC EXCLUDE_FROM_ALL ${GTEST_SRCDIR}/src/gtest-all.cc ) + target_include_directories(gtests-cpn-lib PUBLIC ${GTEST_INCDIR} ${GTEST_INCDIR}/gtest ${GTEST_SRCDIR}) + add_definitions(-DGTESTS) + set(TESTS_PATH ${COMPANION_SRC_DIRECTORY}/tests) + configure_file(${TESTS_PATH}/location.h.in ${CMAKE_CURRENT_BINARY_DIR}/location.h @ONLY) + + include_directories(${CMAKE_CURRENT_BINARY_DIR}) + + if(WIN32) + target_include_directories(gtests-cpn-lib PUBLIC ${WIN_INCLUDE_DIRS}) + target_link_libraries(gtests-cpn-lib PRIVATE ${WIN_LINK_LIBRARIES}) + endif(WIN32) + + file(GLOB TEST_SRC_FILES ${TESTS_PATH}/*.cpp) + + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 ${WARNING_FLAGS}") + + use_cxx11() # ensure gnu++11 in CXX_FLAGS with CMake < 3.1 + + add_executable(gtests-cpn EXCLUDE_FROM_ALL ${TEST_SRC_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/location.h) + add_dependencies(gtests-cpn gtests-cpn-lib) + target_link_libraries(gtests-cpn gtests-cpn-lib pthread Qt5::Core Qt5::Widgets ${CPN_COMMON_LIB}) + message(STATUS "Added optional gtests-cpn target") +else() + message(WARNING "WARNING: gtests target will not be available (check that GTEST_INCDIR, GTEST_SRCDIR, and Qt5Widgets are configured).") +endif() diff --git a/companion/src/tests/conversions.cpp b/companion/src/tests/conversions.cpp new file mode 100644 index 000000000..23354f973 --- /dev/null +++ b/companion/src/tests/conversions.cpp @@ -0,0 +1,13 @@ +#include "gtests.h" +#include "location.h" +#include "storage/storage.h" + +TEST(Conversions, test_conversion) +{ + QString error; + RadioData simuData; + Storage store = Storage(TESTS_PATH "/eeprom_22_x9d+.bin"); + + EXPECT_EQ(true, store.load(simuData)); + qDebug() << store.error(); +} diff --git a/companion/src/tests/eeprom_22_x9d+.bin b/companion/src/tests/eeprom_22_x9d+.bin new file mode 100644 index 0000000000000000000000000000000000000000..cfd4140499ca688c633813dc54bc2c3500b970de GIT binary patch literal 32768 zcmd_ybyQS&7>DtDXFw4PySux)8&R>l6}vl7$L<=j8@m;|6}tnwyIZl{b!TKb%ewCS zu0DV6$QkdM=ldBB_lM``@u;g|x)?u-Rs|8{qL`Z z|GWQ5?P9ux^&$7Pm1(iN*#g5ko&s(;zKl-Rm>-_|neT)BT!TORMSt?e*3)#K=pJ(a zqdC9+M!)_|YyG$L3v!&^5Z7;~7ijS^zyAomy%C+Cznr28+v-qi*KjrypT@M zW{YIl8d^La{?gewPbqTP`}fm#-^Gmbm;VLrVnz-1Z=C1h={&kRW_Y`szw_j5oIjc36x{wF4<*e2?>OvmG zm9tvosS9}!U(RYxpf2P=LOH87k-CrviRG-;B2Fw)tDiw0q>!^(Q>qJj zkV?*KO|35EK^i%$HLbdk2kGRj*7WK^9%PWSS~IE(d5}rYYR#-JOvkAkh59~stb8gNX}|4 ztS;n15jm^1sJf5`#pJBk;_5;kl#sJpOR5Wbp#1Sh#*SKAUC4tna#pLSx{wED<*ZgO zbs-PR$yu%C)rCB$AZN9Ds|$HhQO;_uq%Pz^WjU+0in@>oRpqSKYU)BBRF|__Yp4r( zP*cuot)(vHL2Ws!wT`-w2X*DF)_Uqf9@Lk!S{tYfdC*YKYHg%0XSKFe7xJK$oYmS|UC4tra#m|wbs-Ph$yu%K)rCChAZN99 zR2TA~lbqGsSzXA3E^=0DS9Ku|y2)9s-PMIW=pkpd_EZ=0pqHH0+FM=717A6-wU4@x z2YuzN)_&?j9ytC296kCYZ5RWf9|-**=m$eT1p1-S4}*R<^dq1j3H>POM?*gb`mxZD zgMK{pcIYQS?+5)v=qEux8Tu*EPlbLO^wXiA0sTzqXF)$3`Z>_gh29_fdC<>?egX6g zp1H_!(|{}%dp(7%WN1N0xE{{;PK=)XY! z8}z?J{}p<}WN%-b82TpAH-+8@`ex8KhrR{$Eun7( zeQW63K;IVncF?znz610fq3;BJXXv{?-xd09(07Nv2lPFm?*)Bt=zXE@1ASlU`$2Dm zzCZK>pdSeRAm|4}KLq-r&<}%tIP@c+9|`>^=to082KuqkkAr?Z^mgbcK<@|rMCd0$ zKN6}q2CAne&`QCe-QdZ&>x2W2=qsxKL-7A=ubd@68clnpN2jN`ZLg +#include +#include +#include +#include +#include "gtests.h" + +#include "storage.h" +#include "opentxinterface.h" +#include "customdebug.h" + + +using ::testing::TestEventListener; +using ::testing::EmptyTestEventListener; +using ::testing::Test; +using ::testing::TestCase; +using ::testing::TestEventListeners; +using ::testing::TestInfo; +using ::testing::TestPartResult; +using ::testing::UnitTest; +using ::testing::InitGoogleTest; + +namespace { + +void printColorCode(int color) +{ +#if !GTEST_OS_WINDOWS + if (isatty(fileno(stdout))) + fprintf(stdout, "\033[0;%dm", color); +#endif +} + +/** + * Replaces gtest's PrettyUnitTestResultPrinter with something less verbose. + * Uses the default printer if/when the messages might be interesting, + * e.g. for full error info or tests summary. +*/ +class TersePrinter : public EmptyTestEventListener { + public: + explicit TersePrinter(TestEventListener * prettyPrinter) + : prettyPrinter(prettyPrinter), currentTestInfo(NULL) + { + } + void OnTestProgramStart(const UnitTest & unit_test) + { + prettyPrinter->OnTestProgramStart(unit_test); + } + void OnTestIterationStart(const UnitTest & unit_test, int iteration) + { + printColorCode(36); + fprintf(stdout, "############ "); + fprintf(stdout, "Running %d test(s) from %d test case(s), iteration: %d.\n", unit_test.test_to_run_count(), unit_test.test_case_to_run_count(), iteration + 1); + printColorCode(0); + fflush(stdout); + } + void OnTestCaseStart(const TestCase & test_case) + { + prettyPrinter->OnTestCaseStart(test_case); + } + void OnTestStart(const TestInfo & test_info) + { + currentTestInfo = &test_info; + } + void OnTestPartResult(const TestPartResult & test_part_result) + { + if (test_part_result.failed()) { + prettyPrinter->OnTestStart(*currentTestInfo); + prettyPrinter->OnTestPartResult(test_part_result); + } + } + void OnTestEnd(const TestInfo & test_info) + { + currentTestInfo = NULL; + if (test_info.result()->Failed()) { + prettyPrinter->OnTestEnd(test_info); + } + else { + printColorCode(32); + fprintf(stdout, "+"); + printColorCode(0); + fflush(stdout); + } + } + void OnTestCaseEnd(const TestCase & test_case) + { + fprintf(stdout, "\n"); + fflush(stdout); + } + void OnTestIterationEnd(const UnitTest & unit_test, int iteration) + { + prettyPrinter->OnTestIterationEnd(unit_test, iteration); + } + void OnTestProgramEnd(const UnitTest & unit_test) + { + prettyPrinter->OnTestProgramEnd(unit_test); + } + + private: + // gtest's default unit test result printer. + std::unique_ptr prettyPrinter; + // The currently running TestInfo, if any. + const TestInfo * currentTestInfo; +}; + +} // anonymous namespace + +int main(int argc, char **argv) +{ + QCoreApplication app(argc, argv); + + CustomDebug::setFilterRules(); + registerStorageFactories(); + registerOpenTxFirmwares(); + + InitGoogleTest(&argc, argv); + + // use --verbose option to revert to gtest's default output format + bool verbose = false; + if (argc > 1 && !strcmp(argv[1], "--verbose")) + verbose = true; + + if (!verbose) { + TestEventListeners & listeners = UnitTest::GetInstance()->listeners(); + TestEventListener * defaultPrinter = listeners.Release(listeners.default_result_printer()); + listeners.Append(new TersePrinter(defaultPrinter)); + } + + return RUN_ALL_TESTS(); +} diff --git a/companion/src/tests/gtests.h b/companion/src/tests/gtests.h new file mode 100644 index 000000000..cd22e2624 --- /dev/null +++ b/companion/src/tests/gtests.h @@ -0,0 +1,96 @@ +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef _GTESTS_H_ +#define _GTESTS_H_ + +#include +#include +#include + +// #if defined(PCBTARANIS) || defined(PCBHORUS) +// #define RADIO_RESET() \ +// g_eeGeneral.switchConfig = 0x00007bff +// #else +// #define RADIO_RESET() +// #endif + +// inline void SYSTEM_RESET() +// { +// #if defined(EEPROM) +// memset(modelHeaders, 0, sizeof(modelHeaders)); +// #endif +// generalDefault(); +// g_eeGeneral.templateSetup = 0; +// for (int i=0; i Date: Thu, 22 Aug 2019 22:16:46 +0200 Subject: [PATCH 2/7] use test files from radio & X7 tests ... and removed warnings dialog temporarily. --- companion/src/firmwares/eeprominterface.cpp | 18 +++-- companion/src/firmwares/eeprominterface.h | 2 +- companion/src/firmwares/rawsource.h | 4 +- companion/src/firmwares/rawswitch.h | 4 +- companion/src/storage/bineeprom.cpp | 3 +- companion/src/tests/CMakeLists.txt | 1 + companion/src/tests/conversions.cpp | 69 ++++++++++++++++++-- companion/src/tests/eeprom_22_x9d+.bin | Bin 32768 -> 0 bytes companion/src/tests/gtests.h | 55 ---------------- companion/src/tests/location.h.in | 3 +- 10 files changed, 81 insertions(+), 78 deletions(-) delete mode 100644 companion/src/tests/eeprom_22_x9d+.bin diff --git a/companion/src/firmwares/eeprominterface.cpp b/companion/src/firmwares/eeprominterface.cpp index c1aee1b7b..d4121a8a4 100644 --- a/companion/src/firmwares/eeprominterface.cpp +++ b/companion/src/firmwares/eeprominterface.cpp @@ -103,20 +103,18 @@ void EEPROMInterface::showEepromErrors(QWidget *parent, const QString &title, co #endif // TODO: No GUI here, e.g. return string list instead -void EEPROMInterface::showEepromWarnings(QWidget *parent, const QString &title, unsigned long errorsFound) +QString EEPROMInterface::getEepromWarnings(unsigned long errorsFound) { std::bitset errors((unsigned long long)errorsFound); QStringList warningsList; - if (errors.test(WARNING_WRONG_FIRMWARE)) { warningsList << tr("- Your radio probably uses a wrong firmware,\n eeprom size is 4096 but only the first 2048 are used"); } - if (errors.test(OLD_VERSION)) { warningsList << tr("- Your eeprom is from an old version of OpenTX, upgrading!\n To keep your original file as a backup, please choose File -> Save As specifying a different name."); } + if (errors.test(WARNING_WRONG_FIRMWARE)) { + warningsList << tr("- Your radio probably uses a wrong firmware,\n eeprom size is 4096 but only the first 2048 are used"); + } + if (errors.test(OLD_VERSION)) { + warningsList << tr("- Your eeprom is from an old version of OpenTX, upgrading!\n To keep your original file as a backup, please choose File -> Save As specifying a different name."); + } - QMessageBox msgBox(parent); - msgBox.setWindowTitle(title); - msgBox.setIcon(QMessageBox::Warning); - msgBox.setText(tr("Warnings!")); - msgBox.setInformativeText(warningsList.join("\n")); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.exec(); + return warningsList.join("\n"); } diff --git a/companion/src/firmwares/eeprominterface.h b/companion/src/firmwares/eeprominterface.h index b562f50e9..7b6447d9d 100644 --- a/companion/src/firmwares/eeprominterface.h +++ b/companion/src/firmwares/eeprominterface.h @@ -178,7 +178,7 @@ class EEPROMInterface virtual int getSize(const GeneralSettings &) = 0; //static void showEepromErrors(QWidget *parent, const QString &title, const QString &mainMessage, unsigned long errorsFound); - static void showEepromWarnings(QWidget *parent, const QString &title, unsigned long errorsFound); + static QString getEepromWarnings(unsigned long errorsFound); protected: diff --git a/companion/src/firmwares/rawsource.h b/companion/src/firmwares/rawsource.h index 267d6af43..e9273d399 100644 --- a/companion/src/firmwares/rawsource.h +++ b/companion/src/firmwares/rawsource.h @@ -259,11 +259,11 @@ class RawSource { bool isTimeBased(Board::Type board = Board::BOARD_UNKNOWN) const; bool isAvailable(const ModelData * const model = NULL, const GeneralSettings * const gs = NULL, Board::Type board = Board::BOARD_UNKNOWN) const; - bool operator == ( const RawSource & other) { + bool operator == ( const RawSource & other) const { return (this->type == other.type) && (this->index == other.index); } - bool operator != ( const RawSource & other) { + bool operator != ( const RawSource & other) const { return (this->type != other.type) || (this->index != other.index); } diff --git a/companion/src/firmwares/rawswitch.h b/companion/src/firmwares/rawswitch.h index 598e25f01..6d0c93700 100644 --- a/companion/src/firmwares/rawswitch.h +++ b/companion/src/firmwares/rawswitch.h @@ -91,11 +91,11 @@ class RawSwitch { QString toString(Board::Type board = Board::BOARD_UNKNOWN, const GeneralSettings * const generalSettings = NULL, const ModelData * const modelData = NULL) const; bool isAvailable(const ModelData * const model = NULL, const GeneralSettings * const gs = NULL, Board::Type board = Board::BOARD_UNKNOWN) const; - bool operator== ( const RawSwitch& other) { + bool operator== ( const RawSwitch& other) const { return (this->type == other.type) && (this->index == other.index); } - bool operator!= ( const RawSwitch& other) { + bool operator!= ( const RawSwitch& other) const { return (this->type != other.type) || (this->index != other.index); } diff --git a/companion/src/storage/bineeprom.cpp b/companion/src/storage/bineeprom.cpp index b896b2a01..5da50652c 100644 --- a/companion/src/storage/bineeprom.cpp +++ b/companion/src/storage/bineeprom.cpp @@ -43,6 +43,7 @@ bool BinEepromFormat::load(RadioData & radioData) return false; } + //TODO: show warnings if any return extract(radioData, eeprom); } @@ -94,7 +95,7 @@ bool BinEepromFormat::extract(RadioData & radioData, const QByteArray & eeprom) std::bitset result((unsigned long long)eepromInterface->load(radioData, (uint8_t *)eeprom.data(), eeprom.size())); if (result.test(ALL_OK)) { if (errors.test(HAS_WARNINGS)) { - EEPROMInterface::showEepromWarnings(NULL, CPN_STR_TTL_WARNING, errors.to_ulong()); + setWarning(EEPROMInterface::getEepromWarnings(errors.to_ulong())); } board = eepromInterface->getBoard(); return true; diff --git a/companion/src/tests/CMakeLists.txt b/companion/src/tests/CMakeLists.txt index 12511e8b6..2be8973fc 100644 --- a/companion/src/tests/CMakeLists.txt +++ b/companion/src/tests/CMakeLists.txt @@ -8,6 +8,7 @@ if(GTEST_INCDIR AND GTEST_SRCDIR AND Qt5Widgets_FOUND) target_include_directories(gtests-cpn-lib PUBLIC ${GTEST_INCDIR} ${GTEST_INCDIR}/gtest ${GTEST_SRCDIR}) add_definitions(-DGTESTS) set(TESTS_PATH ${COMPANION_SRC_DIRECTORY}/tests) + set(RADIO_TESTS_PATH ${RADIO_SRC_DIRECTORY}/tests) configure_file(${TESTS_PATH}/location.h.in ${CMAKE_CURRENT_BINARY_DIR}/location.h @ONLY) include_directories(${CMAKE_CURRENT_BINARY_DIR}) diff --git a/companion/src/tests/conversions.cpp b/companion/src/tests/conversions.cpp index 23354f973..190a90f19 100644 --- a/companion/src/tests/conversions.cpp +++ b/companion/src/tests/conversions.cpp @@ -2,12 +2,69 @@ #include "location.h" #include "storage/storage.h" -TEST(Conversions, test_conversion) +TEST(Conversions, ConversionX9DPFrom22) { - QString error; - RadioData simuData; - Storage store = Storage(TESTS_PATH "/eeprom_22_x9d+.bin"); + RadioData radioData; + Storage store = Storage(RADIO_TESTS_PATH "/eeprom_22_x9d+.bin"); - EXPECT_EQ(true, store.load(simuData)); - qDebug() << store.error(); + EXPECT_EQ(true, store.load(radioData)); + + const ModelData& model = radioData.models[0]; + EXPECT_STREQ("Test", model.name); + EXPECT_EQ(RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_SA0), model.timers[0].mode); + EXPECT_EQ(80, model.mixData[0].weight); + EXPECT_EQ(900, model.limitData[0].max); // -100 + EXPECT_EQ(80, model.expoData[0].weight); + EXPECT_EQ(HELI_SWASH_TYPE_120X, model.swashRingData.type); + EXPECT_EQ(10, model.flightModeData[0].gvars[0]); + EXPECT_STREQ("Tes", model.gvarData[0].name); + EXPECT_EQ(PULSES_PXX_XJT_X16, model.moduleData[0].protocol); + EXPECT_EQ(0, model.moduleData[0].subType); + EXPECT_EQ(PULSES_PXX_R9M, model.moduleData[1].protocol); + EXPECT_EQ(MODULE_SUBTYPE_R9M_FCC, model.moduleData[1].subType); + EXPECT_STREQ("Thr", model.inputNames[0]); + EXPECT_STREQ("Tes", model.sensorData[0].label); + EXPECT_EQ(10, model.sensorData[0].id); + EXPECT_EQ(9, model.sensorData[0].instance); + EXPECT_EQ(RawSource(SOURCE_TYPE_TELEMETRY,0).toValue(), model.logicalSw[0].val1); +} + +TEST(Conversions, ConversionX7From22) +{ + RadioData radioData; + Storage store = Storage(RADIO_TESTS_PATH "/eeprom_22_x7.bin"); + + EXPECT_EQ(true, store.load(radioData)); + + const ModelData& model = radioData.models[0]; + EXPECT_STREQ("Test", model.name); + EXPECT_EQ(PULSES_PXX_R9M, model.moduleData[1].protocol); + EXPECT_EQ(MODULE_SUBTYPE_R9M_EU, model.moduleData[1].subType); + + EXPECT_EQ(80, model.mixData[0].weight); + EXPECT_EQ(80, model.expoData[0].weight); + + EXPECT_EQ(RawSource(SOURCE_TYPE_PPM,0), model.mixData[4].srcRaw); + EXPECT_EQ(RawSwitch(SWITCH_TYPE_TELEMETRY,1), model.mixData[4].swtch); + EXPECT_EQ(HELI_SWASH_TYPE_120X, model.swashRingData.type); + EXPECT_STREQ("Thr", model.inputNames[0]); + + EXPECT_STREQ("Tes", model.sensorData[0].label); + EXPECT_EQ(10, model.sensorData[0].id); + EXPECT_EQ(9, model.sensorData[0].instance); + EXPECT_EQ(900, model.limitData[0].max); // -100 + + EXPECT_EQ(10, model.flightModeData[0].gvars[0]); + EXPECT_STREQ("FMtest", model.flightModeData[1].name); + EXPECT_EQ(RawSwitch(SWITCH_TYPE_VIRTUAL,1), model.flightModeData[1].swtch); + EXPECT_STREQ("Tes", model.gvarData[0].name); + + EXPECT_EQ(LS_FN_VPOS, model.logicalSw[0].func); + EXPECT_EQ(RawSource(SOURCE_TYPE_PPM,0).toValue(), model.logicalSw[0].val1); + EXPECT_EQ(0, model.logicalSw[0].val2); + + const FrSkyScreenData& screen = model.frsky.screens[0]; + EXPECT_EQ(TELEMETRY_SCREEN_NUMBERS, screen.type); + EXPECT_EQ(RawSource(SOURCE_TYPE_PPM,0), screen.body.lines[0].source[0]); + EXPECT_EQ(RawSource(SOURCE_TYPE_SPECIAL,4), screen.body.lines[0].source[1]); } diff --git a/companion/src/tests/eeprom_22_x9d+.bin b/companion/src/tests/eeprom_22_x9d+.bin deleted file mode 100644 index cfd4140499ca688c633813dc54bc2c3500b970de..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32768 zcmd_ybyQS&7>DtDXFw4PySux)8&R>l6}vl7$L<=j8@m;|6}tnwyIZl{b!TKb%ewCS zu0DV6$QkdM=ldBB_lM``@u;g|x)?u-Rs|8{qL`Z z|GWQ5?P9ux^&$7Pm1(iN*#g5ko&s(;zKl-Rm>-_|neT)BT!TORMSt?e*3)#K=pJ(a zqdC9+M!)_|YyG$L3v!&^5Z7;~7ijS^zyAomy%C+Cznr28+v-qi*KjrypT@M zW{YIl8d^La{?gewPbqTP`}fm#-^Gmbm;VLrVnz-1Z=C1h={&kRW_Y`szw_j5oIjc36x{wF4<*e2?>OvmG zm9tvosS9}!U(RYxpf2P=LOH87k-CrviRG-;B2Fw)tDiw0q>!^(Q>qJj zkV?*KO|35EK^i%$HLbdk2kGRj*7WK^9%PWSS~IE(d5}rYYR#-JOvkAkh59~stb8gNX}|4 ztS;n15jm^1sJf5`#pJBk;_5;kl#sJpOR5Wbp#1Sh#*SKAUC4tna#pLSx{wED<*ZgO zbs-PR$yu%C)rCB$AZN9Ds|$HhQO;_uq%Pz^WjU+0in@>oRpqSKYU)BBRF|__Yp4r( zP*cuot)(vHL2Ws!wT`-w2X*DF)_Uqf9@Lk!S{tYfdC*YKYHg%0XSKFe7xJK$oYmS|UC4tra#m|wbs-Ph$yu%K)rCChAZN99 zR2TA~lbqGsSzXA3E^=0DS9Ku|y2)9s-PMIW=pkpd_EZ=0pqHH0+FM=717A6-wU4@x z2YuzN)_&?j9ytC296kCYZ5RWf9|-**=m$eT1p1-S4}*R<^dq1j3H>POM?*gb`mxZD zgMK{pcIYQS?+5)v=qEux8Tu*EPlbLO^wXiA0sTzqXF)$3`Z>_gh29_fdC<>?egX6g zp1H_!(|{}%dp(7%WN1N0xE{{;PK=)XY! z8}z?J{}p<}WN%-b82TpAH-+8@`ex8KhrR{$Eun7( zeQW63K;IVncF?znz610fq3;BJXXv{?-xd09(07Nv2lPFm?*)Bt=zXE@1ASlU`$2Dm zzCZK>pdSeRAm|4}KLq-r&<}%tIP@c+9|`>^=to082KuqkkAr?Z^mgbcK<@|rMCd0$ zKN6}q2CAne&`QCe-QdZ&>x2W2=qsxKL-7A=ubd@68clnpN2jN`ZLg #include -// #if defined(PCBTARANIS) || defined(PCBHORUS) -// #define RADIO_RESET() \ -// g_eeGeneral.switchConfig = 0x00007bff -// #else -// #define RADIO_RESET() -// #endif - -// inline void SYSTEM_RESET() -// { -// #if defined(EEPROM) -// memset(modelHeaders, 0, sizeof(modelHeaders)); -// #endif -// generalDefault(); -// g_eeGeneral.templateSetup = 0; -// for (int i=0; i Date: Fri, 23 Aug 2019 08:30:24 +0200 Subject: [PATCH 3/7] fixed module protocol ID conversion --- companion/src/firmwares/opentx/opentxeeprom.cpp | 6 +++--- companion/src/firmwares/opentx/opentxeeprom.h | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 1c8a0f994..15573053a 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -2112,7 +2112,7 @@ class ModuleUnionField: public UnionField { }; public: - ModuleUnionField(DataField * parent, ModuleData & module): + ModuleUnionField(DataField * parent, ModuleData & module, Board::Type board, unsigned int version): UnionField(parent, module.protocol) { Append(new AccessField(parent, module)); @@ -2129,7 +2129,7 @@ class ModuleField: public TransformedField { TransformedField(parent, internalField), internalField(this, "Module"), module(module), - protocolsConversionTable(board) + protocolsConversionTable(board, version) { internalField.Append(new ConversionField >(this, module.protocol, &protocolsConversionTable, "Protocol", DataField::tr("OpenTX doesn't accept this radio protocol"))); internalField.Append(new SignedField<4>(this, module.rfProtocol)); @@ -2144,7 +2144,7 @@ class ModuleField: public TransformedField { } } - internalField.Append(new ModuleUnionField(parent, module)); + internalField.Append(new ModuleUnionField(parent, module, board, version)); } virtual void beforeExport() diff --git a/companion/src/firmwares/opentx/opentxeeprom.h b/companion/src/firmwares/opentx/opentxeeprom.h index 9785c5f7b..95f75ce19 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.h +++ b/companion/src/firmwares/opentx/opentxeeprom.h @@ -73,7 +73,7 @@ class OpenTxGeneralData: public TransformedField { class ProtocolsConversionTable: public ConversionTable { public: - ProtocolsConversionTable(Board::Type board) + ProtocolsConversionTable(Board::Type board, int version) { int val = 0; addConversion(PULSES_OFF, val++); @@ -83,8 +83,10 @@ class ProtocolsConversionTable: public ConversionTable addConversion(PULSES_PXX_XJT_D8, val); addConversion(PULSES_PXX_XJT_LR12, val++); - addConversion(PULSES_ACCESS_ISRM, val); - addConversion(PULSES_ACCST_ISRM_D16, val++); + if (version >= 219) { + addConversion(PULSES_ACCESS_ISRM, val); + addConversion(PULSES_ACCST_ISRM_D16, val++); + } addConversion(PULSES_LP45, val); addConversion(PULSES_DSM2, val); From b036d2a3f74ae8f7da5ca127705f228961d2ec64 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Fri, 23 Aug 2019 08:31:50 +0200 Subject: [PATCH 4/7] fixed module union import for pre-219 eeproms --- companion/src/firmwares/opentx/opentxeeprom.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 15573053a..35d2734ea 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -2115,7 +2115,8 @@ class ModuleUnionField: public UnionField { ModuleUnionField(DataField * parent, ModuleData & module, Board::Type board, unsigned int version): UnionField(parent, module.protocol) { - Append(new AccessField(parent, module)); + if (version >= 219) + Append(new AccessField(parent, module)); Append(new PxxField(parent, module)); Append(new MultiField(parent, module)); Append(new PPMField(parent, module.ppm)); From 49184bfac1baad0080c6b60cd8fefe52c8c57573 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Fri, 23 Aug 2019 08:32:03 +0200 Subject: [PATCH 5/7] sensor instance -1 --- companion/src/firmwares/opentx/opentxeeprom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 35d2734ea..3feb72851 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -1892,7 +1892,7 @@ class SensorField: public TransformedField { if (sensor.type == SensorData::TELEM_TYPE_CUSTOM) { sensor.id = _id; sensor.subid = _subid; - sensor.instance = _instance & 0x1F; // 5 bits instance + sensor.instance = (_instance & 0x1F) + (version <= 218 ? -1 : 0); // 5 bits instance sensor.rxIdx = (_instance >> 5) & 0x03; // 2 bits Rx idx sensor.moduleIdx = (_instance >> 7) & 0x1; // 1 bit module idx sensor.ratio = _ratio; From b3f6f769fced4af846a7844b025693709fb30d56 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Fri, 23 Aug 2019 08:32:28 +0200 Subject: [PATCH 6/7] fixed X7 switch conversion table --- companion/src/firmwares/opentx/opentxeeprom.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 3feb72851..fdb1088f6 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -71,7 +71,15 @@ inline int MAX_SWITCH_SLOTS(Board::Type board, int version) return 8; } -#define MAX_SWITCHES_POSITION(board, version) (Boards::getCapability(board, Board::SwitchPositions)) +inline int MAX_SWITCHES_POSITION(Board::Type board, int version) +{ + if (version < 219 && IS_TARANIS_X7(board)) + return Boards::getCapability(board, Board::SwitchPositions) - 2*3; + + return Boards::getCapability(board, Board::SwitchPositions); +} + +//#define MAX_SWITCHES_POSITION(board, version) (Boards::getCapability(board, Board::SwitchPositions)) #define MAX_ROTARY_ENCODERS(board) (IS_SKY9X(board) ? 1 : 0) #define MAX_FLIGHT_MODES(board, version) 9 #define MAX_TIMERS(board, version) 3 From cb375962852c62bc97135bbe42822de35dbf9dd4 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Fri, 23 Aug 2019 08:47:39 +0200 Subject: [PATCH 7/7] re-enabled conversion warning box --- companion/src/mdichild.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/companion/src/mdichild.cpp b/companion/src/mdichild.cpp index f3001e615..4d0d7dcb8 100644 --- a/companion/src/mdichild.cpp +++ b/companion/src/mdichild.cpp @@ -1334,7 +1334,7 @@ bool MdiChild::loadFile(const QString & filename, bool resetCurrentFile) QString warning = storage.warning(); if (!warning.isEmpty()) { - // TODO EEPROMInterface::showEepromWarnings(this, CPN_STR_TTL_WARNING, warning); + QMessageBox::warning(this, CPN_STR_TTL_WARNING, warning); } if (resetCurrentFile) {