mirror of
https://github.com/opentx/opentx.git
synced 2025-07-20 14:55:13 +03:00
Range test fix (it sent only the upper or lower channels, but not both) (#7143)
This commit is contained in:
parent
f8c732b014
commit
a40716f396
2 changed files with 31 additions and 23 deletions
|
@ -22,7 +22,7 @@
|
||||||
#include "pulses/pxx1.h"
|
#include "pulses/pxx1.h"
|
||||||
|
|
||||||
template <class PxxTransport>
|
template <class PxxTransport>
|
||||||
uint8_t Pxx1Pulses<PxxTransport>::addFlag1(uint8_t module)
|
void Pxx1Pulses<PxxTransport>::addFlag1(uint8_t module, uint8_t sendFailsafe)
|
||||||
{
|
{
|
||||||
uint8_t flag1 = (g_model.moduleData[module].subType << 6);
|
uint8_t flag1 = (g_model.moduleData[module].subType << 6);
|
||||||
if (moduleState[module].mode == MODULE_MODE_BIND) {
|
if (moduleState[module].mode == MODULE_MODE_BIND) {
|
||||||
|
@ -31,21 +31,10 @@ uint8_t Pxx1Pulses<PxxTransport>::addFlag1(uint8_t module)
|
||||||
else if (moduleState[module].mode == MODULE_MODE_RANGECHECK) {
|
else if (moduleState[module].mode == MODULE_MODE_RANGECHECK) {
|
||||||
flag1 |= PXX_SEND_RANGECHECK;
|
flag1 |= PXX_SEND_RANGECHECK;
|
||||||
}
|
}
|
||||||
else {
|
else if (sendFailsafe && g_model.moduleData[module].failsafeMode != FAILSAFE_NOT_SET && g_model.moduleData[module].failsafeMode != FAILSAFE_RECEIVER) {
|
||||||
bool failsafeNeeded = g_model.moduleData[module].failsafeMode != FAILSAFE_NOT_SET && g_model.moduleData[module].failsafeMode != FAILSAFE_RECEIVER;
|
|
||||||
if (moduleState[module].counter-- == 0) {
|
|
||||||
// counter is also used for knowing if the frame is odd / even
|
|
||||||
moduleState[module].counter = 1000;
|
|
||||||
if (failsafeNeeded) {
|
|
||||||
flag1 |= PXX_SEND_FAILSAFE;
|
flag1 |= PXX_SEND_FAILSAFE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (failsafeNeeded && moduleState[module].counter == 0 && g_model.moduleData[module].channelsCount > 0) {
|
|
||||||
flag1 |= PXX_SEND_FAILSAFE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PxxTransport::addByte(flag1);
|
PxxTransport::addByte(flag1);
|
||||||
return flag1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class PxxTransport>
|
template <class PxxTransport>
|
||||||
|
@ -72,6 +61,7 @@ void Pxx1Pulses<PxxTransport>::addExtraFlags(uint8_t module)
|
||||||
if (module == EXTERNAL_MODULE && isSportLineUsedByInternalModule()) {
|
if (module == EXTERNAL_MODULE && isSportLineUsedByInternalModule()) {
|
||||||
extraFlags |= (1 << 5);
|
extraFlags |= (1 << 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
PxxTransport::addByte(extraFlags);
|
PxxTransport::addByte(extraFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +136,7 @@ void Pxx1Pulses<PxxTransport>::addChannels(uint8_t port, uint8_t sendFailsafe, u
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class PxxTransport>
|
template <class PxxTransport>
|
||||||
void Pxx1Pulses<PxxTransport>::add8ChannelsFrame(uint8_t module, uint8_t sendUpperChannels)
|
void Pxx1Pulses<PxxTransport>::add8ChannelsFrame(uint8_t module, uint8_t sendUpperChannels, uint8_t sendFailsafe)
|
||||||
{
|
{
|
||||||
PxxTransport::initCrc();
|
PxxTransport::initCrc();
|
||||||
|
|
||||||
|
@ -157,13 +147,13 @@ void Pxx1Pulses<PxxTransport>::add8ChannelsFrame(uint8_t module, uint8_t sendUpp
|
||||||
PxxTransport::addByte(g_model.header.modelId[module]);
|
PxxTransport::addByte(g_model.header.modelId[module]);
|
||||||
|
|
||||||
// Flag1
|
// Flag1
|
||||||
uint8_t flag1 = addFlag1(module);
|
addFlag1(module, sendFailsafe);
|
||||||
|
|
||||||
// Flag2
|
// Flag2
|
||||||
PxxTransport::addByte(0);
|
PxxTransport::addByte(0);
|
||||||
|
|
||||||
// Channels
|
// Channels
|
||||||
addChannels(module, flag1 & PXX_SEND_FAILSAFE, sendUpperChannels);
|
addChannels(module, sendFailsafe, sendUpperChannels);
|
||||||
|
|
||||||
// Extra flags
|
// Extra flags
|
||||||
addExtraFlags(module);
|
addExtraFlags(module);
|
||||||
|
@ -181,24 +171,42 @@ void Pxx1Pulses<PxxTransport>::add8ChannelsFrame(uint8_t module, uint8_t sendUpp
|
||||||
template <class PxxTransport>
|
template <class PxxTransport>
|
||||||
void Pxx1Pulses<PxxTransport>::setupFrame(uint8_t module)
|
void Pxx1Pulses<PxxTransport>::setupFrame(uint8_t module)
|
||||||
{
|
{
|
||||||
|
uint8_t sendUpperChannels = 0;
|
||||||
|
uint8_t sendFailsafe = 0;
|
||||||
|
|
||||||
PxxTransport::initFrame(PXX_PULSES_PERIOD);
|
PxxTransport::initFrame(PXX_PULSES_PERIOD);
|
||||||
|
|
||||||
#if defined(PXX_FREQUENCY_HIGH)
|
#if defined(PXX_FREQUENCY_HIGH)
|
||||||
if (moduleState[module].protocol == PROTOCOL_CHANNELS_PXX1_SERIAL) {
|
if (moduleState[module].protocol == PROTOCOL_CHANNELS_PXX1_SERIAL) {
|
||||||
add8ChannelsFrame(module, 0);
|
if (moduleState[module].counter-- == 0) {
|
||||||
|
sendFailsafe = 1;
|
||||||
|
moduleState[module].counter = 1000;
|
||||||
|
}
|
||||||
|
add8ChannelsFrame(module, 0, sendFailsafe);
|
||||||
if (sentModuleChannels(module) > 8) {
|
if (sentModuleChannels(module) > 8) {
|
||||||
add8ChannelsFrame(module, 8);
|
add8ChannelsFrame(module, 8, sendFailsafe);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t sendUpperChannels = 0;
|
|
||||||
if (moduleState[module].counter & 0x01) {
|
if (moduleState[module].counter & 0x01) {
|
||||||
sendUpperChannels = g_model.moduleData[module].channelsCount;
|
sendUpperChannels = g_model.moduleData[module].channelsCount;
|
||||||
|
if (sendUpperChannels && moduleState[module].counter == 1) {
|
||||||
|
sendFailsafe = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (moduleState[module].counter == 0) {
|
||||||
|
sendFailsafe = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add8ChannelsFrame(module, sendUpperChannels);
|
add8ChannelsFrame(module, sendUpperChannels, sendFailsafe);
|
||||||
|
|
||||||
|
if (moduleState[module].counter-- == 0) {
|
||||||
|
moduleState[module].counter = 1000;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template class Pxx1Pulses<StandardPxx1Transport<PwmPxxBitTransport> >;
|
template class Pxx1Pulses<StandardPxx1Transport<PwmPxxBitTransport> >;
|
||||||
|
|
|
@ -163,10 +163,10 @@ class Pxx1Pulses: public PxxTransport
|
||||||
PxxTransport::addByteWithoutCrc(Pxx1CrcMixin::crc);
|
PxxTransport::addByteWithoutCrc(Pxx1CrcMixin::crc);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t addFlag1(uint8_t port);
|
void addFlag1(uint8_t port, uint8_t sendFailsafe);
|
||||||
void addExtraFlags(uint8_t port);
|
void addExtraFlags(uint8_t port);
|
||||||
void addChannels(uint8_t port, uint8_t sendFailsafe, uint8_t sendUpperChannels);
|
void addChannels(uint8_t port, uint8_t sendFailsafe, uint8_t sendUpperChannels);
|
||||||
void add8ChannelsFrame(uint8_t port, uint8_t sendUpperChannels);
|
void add8ChannelsFrame(uint8_t port, uint8_t sendUpperChannels, uint8_t sendFailsafe);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef Pxx1Pulses<UartPxx1Transport> UartPxx1Pulses;
|
typedef Pxx1Pulses<UartPxx1Transport> UartPxx1Pulses;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue