fix: Internal PXX exclusive S.PORT (#3822)
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
#include "opentx.h"
|
||||
#include "hal/module_port.h"
|
||||
|
||||
#include "telemetry.h"
|
||||
#include "io/multi_protolist.h"
|
||||
@@ -83,6 +84,11 @@ MultiModuleStatus &getMultiModuleStatus(uint8_t module)
|
||||
return multiModuleStatus[module];
|
||||
}
|
||||
|
||||
static uint8_t _getMultiStatusModuleIdx(const MultiModuleStatus* p)
|
||||
{
|
||||
return p - multiModuleStatus;
|
||||
}
|
||||
|
||||
uint8_t getMultiBindStatus(uint8_t module)
|
||||
{
|
||||
return multiBindStatus[module];
|
||||
@@ -116,6 +122,11 @@ MultiModuleStatus& getMultiModuleStatus(uint8_t)
|
||||
return multiModuleStatus;
|
||||
}
|
||||
|
||||
static uint8_t _getMultiStatusModuleIdx(const MultiModuleStatus*)
|
||||
{
|
||||
return EXTERNAL_MODULE;
|
||||
}
|
||||
|
||||
uint8_t getMultiBindStatus(uint8_t)
|
||||
{
|
||||
return multiBindStatus;
|
||||
@@ -497,14 +508,11 @@ static void processMultiTelemetryPaket(const uint8_t * packet, uint8_t module)
|
||||
void MultiModuleStatus::getStatusString(char * statusText) const
|
||||
{
|
||||
if (!isValid()) {
|
||||
#if defined(PCBFRSKY)
|
||||
#if !defined(INTERNAL_MODULE_MULTI)
|
||||
if (isSportLineUsedByInternalModule())
|
||||
if (!modulePortIsPortUsedByModule(getModuleIndex(), ETX_MOD_PORT_SPORT)) {
|
||||
strcpy(statusText, STR_DISABLE_INTERNAL);
|
||||
else
|
||||
#endif
|
||||
#endif
|
||||
strcpy(statusText, STR_MODULE_NO_TELEMETRY);
|
||||
} else {
|
||||
strcpy(statusText, STR_MODULE_NO_TELEMETRY);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!protocolValid()) {
|
||||
@@ -556,6 +564,10 @@ void MultiModuleStatus::getStatusString(char * statusText) const
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t MultiModuleStatus::getModuleIndex() const {
|
||||
return _getMultiStatusModuleIdx(this);
|
||||
}
|
||||
|
||||
static void processMultiTelemetryByte(const uint8_t data, uint8_t module)
|
||||
{
|
||||
uint8_t * rxBuffer = getTelemetryRxBuffer(module);
|
||||
|
||||
@@ -120,6 +120,8 @@ struct MultiModuleStatus {
|
||||
|
||||
void getStatusString(char * statusText) const;
|
||||
|
||||
uint8_t getModuleIndex() const;
|
||||
|
||||
inline bool isValid() const { return (bool)(get_tmr10ms() - lastUpdate < 200); }
|
||||
inline bool isBufferFull() const { return (bool) (flags & 0x80); }
|
||||
inline bool supportsDisableMapping() const { return (bool) (flags & 0x40); }
|
||||
|
||||
@@ -68,8 +68,6 @@ uint8_t telemetryState = TELEMETRY_INIT;
|
||||
|
||||
TelemetryData telemetryData;
|
||||
|
||||
uint8_t telemetryProtocol = 255;
|
||||
|
||||
#if defined(INTERNAL_MODULE_SERIAL_TELEMETRY)
|
||||
static uint8_t intTelemetryRxBuffer[TELEMETRY_RX_PACKET_SIZE];
|
||||
static uint8_t intTelemetryRxBufferCount;
|
||||
@@ -418,60 +416,9 @@ void telemetryReset()
|
||||
}
|
||||
|
||||
telemetryStreaming = 0; // reset counter only if valid telemetry packets are being detected
|
||||
|
||||
telemetryState = TELEMETRY_INIT;
|
||||
}
|
||||
|
||||
// we don't reset the telemetry here as we would also reset the consumption after model load
|
||||
void telemetryInit(uint8_t protocol)
|
||||
{
|
||||
telemetryProtocol = protocol;
|
||||
|
||||
// if (protocol == PROTOCOL_TELEMETRY_FRSKY_D) {
|
||||
// telemetryPortInit(FRSKY_D_BAUDRATE, TELEMETRY_SERIAL_DEFAULT);
|
||||
// }
|
||||
// #if defined(MULTIMODULE)
|
||||
// else if (protocol == PROTOCOL_TELEMETRY_MULTIMODULE) {
|
||||
// // The DIY Multi module always speaks 100000 baud regardless of the
|
||||
// // telemetry protocol in use
|
||||
// telemetryPortInit(MULTIMODULE_BAUDRATE, TELEMETRY_SERIAL_8E2);
|
||||
// #if defined(LUA)
|
||||
// outputTelemetryBuffer.reset();
|
||||
// #endif
|
||||
// telemetryPortSetDirectionInput();
|
||||
// } else if (protocol == PROTOCOL_TELEMETRY_SPEKTRUM) {
|
||||
// // Spektrum's own small race RX (SPM4648) uses 125000 8N1, use the same
|
||||
// // since there is no real standard
|
||||
// telemetryPortInit(125000, TELEMETRY_SERIAL_DEFAULT);
|
||||
// }
|
||||
// #endif
|
||||
|
||||
// #if defined(GHOST)
|
||||
// else if (protocol == PROTOCOL_TELEMETRY_GHOST) {
|
||||
// telemetryPortInit(GHOST_BAUDRATE, TELEMETRY_SERIAL_DEFAULT);
|
||||
// #if defined(LUA)
|
||||
// outputTelemetryBuffer.reset();
|
||||
// #endif
|
||||
// telemetryPortSetDirectionOutput();
|
||||
// }
|
||||
// #endif
|
||||
|
||||
// #if defined(AUX_SERIAL)
|
||||
// else if (protocol == PROTOCOL_TELEMETRY_FRSKY_D_SECONDARY) {
|
||||
// telemetryPortInit(0, TELEMETRY_SERIAL_DEFAULT);
|
||||
// }
|
||||
// #endif
|
||||
// else if (protocol == PROTOCOL_TELEMETRY_DSMP) {
|
||||
// // soft serial
|
||||
// telemetryPortInvertedInit(115200);
|
||||
// } else {
|
||||
// telemetryPortInit(FRSKY_SPORT_BAUDRATE, TELEMETRY_SERIAL_WITHOUT_DMA);
|
||||
// #if defined(LUA)
|
||||
// outputTelemetryBuffer.reset();
|
||||
// #endif
|
||||
// }
|
||||
}
|
||||
|
||||
#if defined(LOG_TELEMETRY) && !defined(SIMU)
|
||||
extern FIL g_telemetryFile;
|
||||
void logTelemetryWriteStart()
|
||||
|
||||
@@ -133,60 +133,6 @@ typedef struct {
|
||||
|
||||
rxStatStruct *getRxStatLabels();
|
||||
|
||||
// TODO: this should handle only the external S.PORT line
|
||||
// - and go away in the end: one proto per module, not global!
|
||||
//
|
||||
inline uint8_t modelTelemetryProtocol()
|
||||
{
|
||||
#if defined(HARDWARE_EXTERNAL_MODULE)
|
||||
bool sportUsed = isSportLineUsedByInternalModule();
|
||||
|
||||
#if defined(CROSSFIRE)
|
||||
if (isModuleCrossfire(EXTERNAL_MODULE)) {
|
||||
return PROTOCOL_TELEMETRY_CROSSFIRE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(GHOST)
|
||||
if (isModuleGhost(EXTERNAL_MODULE)) {
|
||||
return PROTOCOL_TELEMETRY_GHOST;
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO: PPM driver should support setting up a telemetry parser callback
|
||||
if (!sportUsed && isModulePPM(EXTERNAL_MODULE)) {
|
||||
return g_model.telemetryProtocol;
|
||||
}
|
||||
|
||||
#if defined(MULTIMODULE)
|
||||
if (!sportUsed && isModuleMultimodule(EXTERNAL_MODULE)) {
|
||||
return PROTOCOL_TELEMETRY_MULTIMODULE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(AFHDS3)
|
||||
if (isModuleAFHDS3(EXTERNAL_MODULE)) {
|
||||
return PROTOCOL_TELEMETRY_AFHDS3;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (isModuleDSMP(EXTERNAL_MODULE)) {
|
||||
return PROTOCOL_TELEMETRY_DSMP;
|
||||
}
|
||||
|
||||
#endif // HARDWARE_EXTERNAL_MODULE
|
||||
|
||||
// TODO: Check if that is really necessary...
|
||||
#if defined(AFHDS2) && defined(HARDWARE_INTERNAL_MODULE)
|
||||
if (isModuleAFHDS2A(INTERNAL_MODULE)) {
|
||||
return PROTOCOL_TELEMETRY_FLYSKY_NV14;
|
||||
}
|
||||
#endif
|
||||
|
||||
// default choice
|
||||
return PROTOCOL_TELEMETRY_FRSKY_SPORT;
|
||||
}
|
||||
|
||||
#include "telemetry_sensors.h"
|
||||
|
||||
#if defined(LOG_TELEMETRY) && !defined(SIMU)
|
||||
|
||||
Reference in New Issue
Block a user