Skip to content

Commit 01c7497

Browse files
3djcpfeerick
authored andcommitted
fix: xjt lite telem binding (#5468)
1 parent f6cfec5 commit 01c7497

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

radio/src/pulses/modules_helpers.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ inline bool isTelemAllowedOnBind(uint8_t moduleIndex)
669669
if (moduleIndex == INTERNAL_MODULE)
670670
return true;
671671

672-
if (!modulePortIsPortUsedByModule(moduleIndex, ETX_MOD_PORT_SPORT))
672+
if (modulePortIsPortUsedByModule(INTERNAL_MODULE, ETX_MOD_PORT_SPORT))
673673
return false;
674674
#endif
675675

radio/src/tests/module_ports.cpp

+38
Original file line numberDiff line numberDiff line change
@@ -238,4 +238,42 @@ TEST(ports, boot_pxx1_multi)
238238
_deinitModuleDrv(EXTERNAL_MODULE);
239239
EXPECT_FALSE(modulePortIsPortUsed(ETX_MOD_PORT_SPORT));
240240
}
241+
242+
TEST(ports, isTelemAllowedOnBind)
243+
{
244+
modulePortInit();
245+
246+
void* int_ctx = Pxx1Driver.init(INTERNAL_MODULE);
247+
EXPECT_TRUE(int_ctx != nullptr);
248+
if (!int_ctx) return;
249+
_setModuleDrv(INTERNAL_MODULE, &Pxx1Driver, int_ctx);
250+
251+
// Telem always has priority on internal
252+
EXPECT_TRUE(isTelemAllowedOnBind(INTERNAL_MODULE));
253+
254+
// When internal uses SPORT, you cannot bind FRSKY with telem on external module
255+
EXPECT_FALSE(isTelemAllowedOnBind(EXTERNAL_MODULE));
256+
257+
// but you can when internal is disabled
258+
_deinitModuleDrv(INTERNAL_MODULE);
259+
EXPECT_TRUE(isTelemAllowedOnBind(EXTERNAL_MODULE));
260+
}
261+
#elif !defined(PCBFLYSKY) //defined(INTERNAL_MODULE_PXX1) && defined(HARDWARE_EXTERNAL_MODULE)
262+
TEST(ports, isTelemAllowedOnBind)
263+
{
264+
modulePortInit();
265+
266+
const etx_serial_init serialCfg = {
267+
.baudrate = 921000,
268+
.encoding = ETX_Encoding_8N1,
269+
.direction = ETX_Dir_TX_RX,
270+
.polarity = ETX_Pol_Normal,
271+
};
272+
273+
auto mod_st = modulePortInitSerial(INTERNAL_MODULE, ETX_MOD_PORT_UART, &serialCfg, false);
274+
EXPECT_TRUE(mod_st != nullptr);
275+
276+
// Since internal module doesn't use SPORT, you should be able to bind FrSky with telem
277+
EXPECT_TRUE(isTelemAllowedOnBind(EXTERNAL_MODULE));
278+
}
241279
#endif

0 commit comments

Comments
 (0)