Repository navigation
Add support for dynamically adjusting source and target sysID - #2891
LupusTheCanine wants to merge 20 commits into
Conversation
LupusTheCanine
commented
Aug 18, 2024
- Add support for changing source and target sysID live
- Add way of getting currently active serial protocol (SerialIO::getProtocol()) defaults to SERIAL_PROTOCOL_UNKNOWN
- Add getProtocol support to all protocols except SerialAirPort
Adds support for setting source and Target sysID using menu for mavlink enabled receivers. Options are only shown if currently selected serial protocol is MAVLink. Default values are maintained and correctly displayed in the menu. * 1 for target sysID * 255 for source sysID Limitations: * Setting either sysID requires reboot Additional changes: * set source compID to MAV_COMP_ID_TELEMETRY_RADIO as we are actiong as telemetry radio now * set target compID to MAV_COMP_ID_ALL as any device on the vehicle may be interested in receiving RC signal
Adds support for setting source and Target sysID using menu for mavlink enabled receivers. Options are only shown if currently selected serial protocol is MAVLink. Default values are maintained and correctly displayed in the menu. * 1 for target sysID * 255 for source sysID Limitations: * Setting either sysID requires reboot Additional changes: * set source compID to MAV_COMP_ID_TELEMETRY_RADIO as we are actiong as telemetry radio now * set target compID to MAV_COMP_ID_ALL as any device on the vehicle may be interested in receiving RC signal
* add whitespace to make code more readable as suggested * update comments to better describe sys and comp ID logic and choices
* replaced if with ternarry in UI logic for brevity * added comment explaining logic and referencing reason code
Add support for changing source and target sysID live Add way of getting currently active serial protocol (SerialIO::getProtocol()) defaults to SERIAL_PROTOCOL_UNKNOWN Add getProtocol to SerialMavlink
DJI_... reported as SBUS (as it is SBUS with specified baud)
|
Retargeting to |
|
Tested with RP4-TD and BetaFPV Gemini Module. All functions worked as expected. I am able to change SYSID live through the Lua script, and has flown a 20 minute flight with no issues |
|
Bump |
| PROTOCOL_SERIAL1_TRAMP, | ||
| PROTOCOL_SERIAL1_SMARTAUDIO, | ||
| }; | ||
| }; //if MAVLink is added to Serial 1 enable hasMavlink check in rx_devLUA.cpp and move setters from event0 to event |
There was a problem hiding this comment.
Unrelated change, please revert
There was a problem hiding this comment.
Yup, the change should have been in the main PR, I would rather add it here than make another PR unless you have a better place to put the notes.
| #if defined(PLATFORM_ESP32) | ||
|
|
||
| /*#if defined(PLATFORM_ESP32) //We do not support MAVLink on serial 1// protocol 1 | ||
| eSerial1Protocol prot1 = config.GetSerial1Protocol(); | ||
| hasMavlink = hasMavlink || (prot1 == PROTOCOL_MAVLINK); | ||
| #endif | ||
| #endif*/ | ||
|
|
There was a problem hiding this comment.
Unrelated change, please revert
| explicit SerialAirPort(Stream &out, Stream &in) : SerialIO(&out, &in) {} | ||
| virtual ~SerialAirPort() {} | ||
|
|
||
| eSerialProtocolType getProtocol(){return SERIAL_PROTOCOL_AIRPORT;} |
There was a problem hiding this comment.
Formatting, please follow other examples with the spacing
eSerialProtocolType getProtocol() { return SERIAL_PROTOCOL_AIRPORT; }There was a problem hiding this comment.
Sure, will do
| virtual ~SerialCRSF() {} | ||
|
|
||
| uint32_t sendRCFrame(bool frameAvailable, bool frameMissed, uint32_t *channelData) override; | ||
| eSerialProtocolType getProtocol(){return SERIAL_PROTOCOL_CRSF;}; |
|
|
||
| virtual ~SerialHoTT_TLM() {} | ||
|
|
||
| eSerialProtocolType getProtocol(){return SERIAL_PROTOCOL_HOTT_TLM;}; |
| } | ||
| virtual ~SerialTramp() {} | ||
|
|
||
| eSerialProtocolType getProtocol(){return SERIAL_PROTOCOL_TRAMP;}; |
| #include "SerialIO.h" | ||
| #include "CRSF.h" | ||
| #include "config.h" | ||
|
|
| extern void setTargetSysId(uint8_t sysID); | ||
| extern void setThisSysId(uint8_t sysID); |
There was a problem hiding this comment.
Should not be required as we can call the member functions by casting the pointer to the Mavlink type
There was a problem hiding this comment.
I can take a look, we don't have RTTI so I will have to manually check if serial is appropriate type.
I tried to do it that way (with proper casting) and compiler complained a lot about unsafe casting and I don't want to enable RTTI as it ridiculously expensive in resources ROM and RAM.
There was a problem hiding this comment.
I've thought about this whole PR some more, and I think it would be better to add a new method to the superclass called event which has a default empty implementation.
The Mavlink class can then do whatever it needs to do. Then all the other stuff and unsafe casts will not be needed.
There was a problem hiding this comment.
Sounds good to me.
Can I keep the notes or do we have another place for that?
There was a problem hiding this comment.
I just don't like adding commented out code. It feels wrong to me. We should either delete it or implement it properly. If implementing Mavlink on the other serial port then it should be a different PR.
There was a problem hiding this comment.
Ok, I will remove the code, I would keep the note there.
| private: | ||
| friend void setThisSysId(uint8_t sysID); | ||
| friend void setTargetSysId(uint8_t sysID); |
There was a problem hiding this comment.
The private should remain and the member function declaration should be in the public section and not friend functions.
| setTargetSysId(config.GetTargetSysId()); | ||
| setThisSysId(config.GetSourceSysId()); |
There was a problem hiding this comment.
To call these functions, assign the (*(serial0.io)) to a variable with a cast and access the member function that way.
auto mavlink =(SerialMavlink *)(*(serial0.io));
mavlink->setTargetSysId(config.GetTargetSysId());
mavlink->setThisSysId(config.GetSourceSysId());|
Superseded by #2964 |
* Add SysId configuration, requires ExpressLRS/ExpressLRS#2891 * Update wordlist.txt --------- Co-authored-by: Nikhil Parikh <[email protected]>
* Add SysId configuration, requires ExpressLRS/ExpressLRS#2891 * Update wordlist.txt --------- Co-authored-by: Nikhil Parikh <[email protected]>