Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential fix to MSP over CRSF #10671

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/rx/crsf.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ STATIC_UNIT_TESTED void crsfDataReceive(uint16_t c, void *rxCallbackData)
case CRSF_FRAMETYPE_MSP_WRITE: {
uint8_t *frameStart = (uint8_t *)&crsfFrame.frame.payload + CRSF_FRAME_ORIGIN_DEST_SIZE;
if (bufferCrsfMspFrame(frameStart, CRSF_FRAME_RX_MSP_FRAME_SIZE)) {
crsfScheduleMspResponse();
crsfScheduleMspResponse(crsfFrame.frame.payload[1]);
}
break;
}
Expand Down
7 changes: 5 additions & 2 deletions src/main/telemetry/crsf.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,13 @@ static uint8_t crsfSchedule[CRSF_SCHEDULE_COUNT_MAX];
#if defined(USE_MSP_OVER_TELEMETRY)

static bool mspReplyPending;
//Id of the last receiver MSP frame over CRSF. Needed to send response with correct frame ID
static uint8_t mspRequestOriginID = 0;

void crsfScheduleMspResponse(void)
void crsfScheduleMspResponse(uint8_t requestOriginID)
{
mspReplyPending = true;
mspRequestOriginID = requestOriginID;
}

void crsfSendMspResponse(uint8_t *payload)
Expand All @@ -438,7 +441,7 @@ void crsfSendMspResponse(uint8_t *payload)
crsfInitializeFrame(dst);
sbufWriteU8(dst, CRSF_FRAME_TX_MSP_FRAME_SIZE + CRSF_FRAME_LENGTH_EXT_TYPE_CRC);
crsfSerialize8(dst, CRSF_FRAMETYPE_MSP_RESP);
crsfSerialize8(dst, CRSF_ADDRESS_RADIO_TRANSMITTER);
crsfSerialize8(dst, mspRequestOriginID);
crsfSerialize8(dst, CRSF_ADDRESS_FLIGHT_CONTROLLER);
crsfSerializeData(dst, (const uint8_t*)payload, CRSF_FRAME_TX_MSP_FRAME_SIZE);
crsfFinalize(dst);
Expand Down
2 changes: 1 addition & 1 deletion src/main/telemetry/crsf.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void initCrsfTelemetry(void);
bool checkCrsfTelemetryState(void);
void handleCrsfTelemetry(timeUs_t currentTimeUs);
void crsfScheduleDeviceInfoResponse(void);
void crsfScheduleMspResponse(void);
void crsfScheduleMspResponse(uint8_t requestOriginID);
int getCrsfFrame(uint8_t *frame, crsfFrameType_e frameType);
#if defined(USE_MSP_OVER_TELEMETRY)
void initCrsfMspBuffer(void);
Expand Down
Loading