Skip to content

Commit

Permalink
fix: xjt lite telem binding (#5468)
Browse files Browse the repository at this point in the history
  • Loading branch information
3djc authored and pfeerick committed Aug 28, 2024
1 parent f6cfec5 commit 01c7497
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion radio/src/pulses/modules_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ inline bool isTelemAllowedOnBind(uint8_t moduleIndex)
if (moduleIndex == INTERNAL_MODULE)
return true;

if (!modulePortIsPortUsedByModule(moduleIndex, ETX_MOD_PORT_SPORT))
if (modulePortIsPortUsedByModule(INTERNAL_MODULE, ETX_MOD_PORT_SPORT))
return false;
#endif

Expand Down
38 changes: 38 additions & 0 deletions radio/src/tests/module_ports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,42 @@ TEST(ports, boot_pxx1_multi)
_deinitModuleDrv(EXTERNAL_MODULE);
EXPECT_FALSE(modulePortIsPortUsed(ETX_MOD_PORT_SPORT));
}

TEST(ports, isTelemAllowedOnBind)
{
modulePortInit();

void* int_ctx = Pxx1Driver.init(INTERNAL_MODULE);
EXPECT_TRUE(int_ctx != nullptr);
if (!int_ctx) return;
_setModuleDrv(INTERNAL_MODULE, &Pxx1Driver, int_ctx);

// Telem always has priority on internal
EXPECT_TRUE(isTelemAllowedOnBind(INTERNAL_MODULE));

// When internal uses SPORT, you cannot bind FRSKY with telem on external module
EXPECT_FALSE(isTelemAllowedOnBind(EXTERNAL_MODULE));

// but you can when internal is disabled
_deinitModuleDrv(INTERNAL_MODULE);
EXPECT_TRUE(isTelemAllowedOnBind(EXTERNAL_MODULE));
}
#elif !defined(PCBFLYSKY) //defined(INTERNAL_MODULE_PXX1) && defined(HARDWARE_EXTERNAL_MODULE)
TEST(ports, isTelemAllowedOnBind)
{
modulePortInit();

const etx_serial_init serialCfg = {
.baudrate = 921000,
.encoding = ETX_Encoding_8N1,
.direction = ETX_Dir_TX_RX,
.polarity = ETX_Pol_Normal,
};

auto mod_st = modulePortInitSerial(INTERNAL_MODULE, ETX_MOD_PORT_UART, &serialCfg, false);
EXPECT_TRUE(mod_st != nullptr);

// Since internal module doesn't use SPORT, you should be able to bind FrSky with telem
EXPECT_TRUE(isTelemAllowedOnBind(EXTERNAL_MODULE));
}
#endif

0 comments on commit 01c7497

Please sign in to comment.