MSP2 via CSFR/SmartPort telemetry#11093
Conversation
|
Awesome work. Will SmartPort also get the MSPv2 treatment? |
|
it should work, the changes for MSP2 are in msp_share file, so theoretically i don't see any reasson why it should not work. rob.thomson is going to test it, he has smarport capable gear. |
|
I did have a brief look. There may be some things that need changing in SmartPort regarding the packets. I believe there are examples of this in the BetaFlight or RotorFlight SmartPort.c file. Awesome work though 👍🏻 |
|
do you mean change regarding to skip few request after EEPROM_WRITE command? I will look at that closely :) |
|
Don’t listen to me, I was misremembering 🤣 The changes in msp_shared should hopefully get it work over SmartPort. |
|
:D, it seems you were right, still some issues with smartport, I'm waiting to rob.thomson for more info. And moreover I will have frsky gear for better smartport testing. However, CRSF works much better, I was able to fetch VERSION frame, PID frame, and save new values for PID frame. there were some insidious bugs :D |
|
Awesome 🤘🏻 Rob mentioned that FrSky are sending you some hardware to get this working. Which is great news. |
|
current status is that CRSF is fully functional. I tested all scenarios from "Testing:" section. Rob.thomson confirmed that CRSF is OK, Smartport is still in progress, Maybe what about to create for smartport new pullrequest? |
|
Tested by rob.thomson |
PR Compliance Guide 🔍(Compliance updated until commit 26382bf)Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label Previous compliance checksCompliance check up to commit 779fccf |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||
Correct MSP frame length calculation-4 is there becasue CRSF FRAME contains 4 bytes related to CRSF , rest is payload, do we need alocated extra one byte, just for sure? Refactor state management for chunked repliespersonaly I would keep static variables in each function for detection if header has been sent or not, seqnumber is used only in one function, and it should be last seq number. So no need to extract. Good suggestion from qodo but for beter debugging and keep it more readable I would keep it as it is. i think it does not have impact for performance. |
|
Yup. Tested crsf and sport from ethos. All good. Same work helped fix a sport issue with MSPv2 on betaflight and rotorflight. |
|
NOTE: in ERLS is bug and MSP2 does not work properly, it's fixed in ELRS 3.6.0, so for using MSP2 it's needed to update ELRS TX/RX |
User description
PR adds support for MSP2 inspired by implementation from betaflight. PR does not change manupulation with buffers and keep INAV style. In PR is fix for mspRequestOriginID originally made Pawel
<receiver address 8b><sender address 8b><csfr flags 8b><length 8b><cmd 8b><payload ....><receiver address 8b><sender address 8b><csfr flags 8b><MSP flags 8b><cmd 16b LE><length 16b LE><payload ... >example:
Tasks:
Testing:
CRSF (ready for test):
SmartPort:
MSP-test-lua.zip
PR Type
Enhancement, New Feature
Description
Add MSP2 protocol support over CRSF and SmartPort telemetry
Implement chunked frame handling for payloads exceeding 60 bytes
Fix MSP request origin ID tracking for proper response routing
Refactor MSP frame parsing with improved version detection and error handling
Diagram Walkthrough
File Walkthrough
crsf.c
Improve CRSF timing and MSP frame handlingsrc/main/rx/crsf.c
crsfFrameStartAttocrsfFrameStartAtUsfor claritymicros()tomicrosISR()for ISR contextfixed size
crsfScheduleMspResponse()parameter for request origin IDtracking
crsfRxIsTelemetryBufEmpty()function to check telemetry bufferstate
crsf.h
Add telemetry buffer status check functionsrc/main/rx/crsf.h
crsfRxIsTelemetryBufEmpty()function declarationcrsf.c
Implement MSP response chunking and origin ID trackingsrc/main/telemetry/crsf.c
crsfScheduleMspResponse()to accept and store request origin IDcrsfSendMspResponse()to accept dynamic payload size parameterprocessCrsf()to prevent frame collisioncrsf.h
Update MSP response scheduling signaturesrc/main/telemetry/crsf.h
crsfScheduleMspResponse()signature to includerequestOriginIDparameter
msp_shared.h
Update MSP callback and function signaturessrc/main/telemetry/msp_shared.h
mspResponseFnPtrcallback signature to include payload sizeparameter
handleMspFrame()parameter naming for claritysmartport.c
Add payload size handling to SmartPort MSP responsesrc/main/telemetry/smartport.c
smartPortSendMspResponse()to accept payload size parameterMIN()macro to safely copy data within SmartPort payload boundsmsp_shared.c
Add MSPv2 protocol support and chunked frame handlingsrc/main/telemetry/msp_shared.c
oversized requests