Skip to content

Commit

Permalink
fix: MPM module status
Browse files Browse the repository at this point in the history
We should only consider if the MPM has a working telemetry link or not.
  • Loading branch information
raphaelcoeffic committed Oct 14, 2023
1 parent ede1d00 commit 6bb0c5e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions radio/src/hal/module_port.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,11 @@ int8_t modulePortGetModuleForPort(uint8_t port)

return -1;
}

bool modulePortHasRx(uint8_t module)
{
auto mod_st = modulePortGetState(module);
if (!mod_st) return false;

return mod_st && mod_st->rx.port;
}
2 changes: 2 additions & 0 deletions radio/src/hal/module_port.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,5 @@ bool modulePortIsPortUsedByModule(uint8_t module, uint8_t port);
bool modulePortIsPortUsed(uint8_t port);

int8_t modulePortGetModuleForPort(uint8_t port);

bool modulePortHasRx(uint8_t module);
2 changes: 1 addition & 1 deletion radio/src/pulses/multi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ static void setupPulsesMulti(uint8_t*& p_buf, uint8_t module)
}

// Invert telemetry if needed
uint8_t disableTelemetry = modulePortIsPortUsedByModule(module, ETX_MOD_PORT_SPORT) ? 0 : 1;
uint8_t disableTelemetry = modulePortHasRx(module) ? 0 : 1;
if (invert[module] & 0x80 && !disableTelemetry) {
if (getMultiModuleStatus(module).isValid()) {
invert[module] &= 0x08; // Telemetry received, stop searching
Expand Down
2 changes: 1 addition & 1 deletion radio/src/telemetry/multi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ static void processMultiTelemetryPaket(const uint8_t * packet, uint8_t module)
void MultiModuleStatus::getStatusString(char * statusText) const
{
if (!isValid()) {
if (!modulePortIsPortUsedByModule(getModuleIndex(), ETX_MOD_PORT_SPORT)) {
if (!modulePortHasRx(getModuleIndex())) {
strcpy(statusText, STR_DISABLE_INTERNAL);
} else {
strcpy(statusText, STR_MODULE_NO_TELEMETRY);
Expand Down

0 comments on commit 6bb0c5e

Please sign in to comment.