mirror of
https://github.com/opentx/opentx.git
synced 2025-07-14 20:10:08 +03:00
generate_datacopy.py fixes (#6015)
* fix generate_datacopy on osx * more datacopy fixes * added support for linux & llvm-3.8 (default on debian stretch)
This commit is contained in:
parent
d253c3163b
commit
4880497db5
4 changed files with 55 additions and 55 deletions
|
@ -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"
|
||||||
|
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
#define ARM_FIELD(x) x;
|
#define ARM_FIELD(x) x;
|
||||||
|
@ -266,10 +269,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;
|
||||||
});
|
});
|
||||||
|
@ -591,11 +594,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
|
||||||
|
@ -608,27 +611,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(
|
||||||
|
|
|
@ -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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue