Skip to content

Add support for dynamically adjusting source and target sysID - #2891

Closed
LupusTheCanine wants to merge 20 commits into
ExpressLRS:3.x.x-maintenancefrom
LupusTheCanine:mavlink-sysID
Closed

LupusTheCanine wants to merge 20 commits into
ExpressLRS:3.x.x-maintenancefrom
LupusTheCanine:mavlink-sysID

Conversation

@LupusTheCanine

Copy link
Copy Markdown
Contributor
  • 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

LupusTheCanine and others added 11 commits August 13, 2024 19:09
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
LupusTheCanine added a commit to LupusTheCanine/ExpressLRS-Docs that referenced this pull request Aug 18, 2024
DJI_... reported as SBUS (as it is SBUS with specified baud)
@wvarty
wvarty changed the base branch from master to 3.x.x-maintenance August 19, 2024 02:44
@wvarty

wvarty commented Aug 19, 2024

Copy link
Copy Markdown
Collaborator

Retargeting to 3.x.x-maintenance.
Needs conflicts resolved before this can be reviewed.

Comment thread src/lib/CONFIG/config.cpp Resolved
@Lifeless-Ditto

Copy link
Copy Markdown

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

@LupusTheCanine

Copy link
Copy Markdown
Contributor Author

Bump

Comment thread src/include/common.h
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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated change, please revert

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/lib/LUA/rx_devLUA.cpp
Comment on lines -538 to +543
#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*/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated change, please revert

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above.

explicit SerialAirPort(Stream &out, Stream &in) : SerialIO(&out, &in) {}
virtual ~SerialAirPort() {}

eSerialProtocolType getProtocol(){return SERIAL_PROTOCOL_AIRPORT;}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting, please follow other examples with the spacing

eSerialProtocolType getProtocol() { return SERIAL_PROTOCOL_AIRPORT; }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will do

virtual ~SerialCRSF() {}

uint32_t sendRCFrame(bool frameAvailable, bool frameMissed, uint32_t *channelData) override;
eSerialProtocolType getProtocol(){return SERIAL_PROTOCOL_CRSF;};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting


virtual ~SerialHoTT_TLM() {}

eSerialProtocolType getProtocol(){return SERIAL_PROTOCOL_HOTT_TLM;};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting

}
virtual ~SerialTramp() {}

eSerialProtocolType getProtocol(){return SERIAL_PROTOCOL_TRAMP;};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting

#include "SerialIO.h"
#include "CRSF.h"
#include "config.h"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave this blank line

Comment on lines +16 to +17
extern void setTargetSysId(uint8_t sysID);
extern void setThisSysId(uint8_t sysID);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be required as we can call the member functions by casting the pointer to the Mavlink type

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me.

Can I keep the notes or do we have another place for that?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@LupusTheCanine LupusTheCanine Sep 28, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will remove the code, I would keep the note there.

Comment on lines -24 to +29
private:
friend void setThisSysId(uint8_t sysID);
friend void setTargetSysId(uint8_t sysID);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The private should remain and the member function declaration should be in the public section and not friend functions.

Comment on lines +87 to +88
setTargetSysId(config.GetTargetSysId());
setThisSysId(config.GetSourceSysId());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());

@wvarty wvarty removed the V3.5 🍩 label Sep 29, 2024
@LupusTheCanine

Copy link
Copy Markdown
Contributor Author

Superseded by #2964

maybenikhil added a commit to ExpressLRS/Docs that referenced this pull request Oct 26, 2024
* Add SysId configuration, requires ExpressLRS/ExpressLRS#2891

* Update wordlist.txt

---------

Co-authored-by: Nikhil Parikh <[email protected]>
jurgelenas pushed a commit to ExpressLRS/Docs that referenced this pull request Oct 5, 2025
* Add SysId configuration, requires ExpressLRS/ExpressLRS#2891

* Update wordlist.txt

---------

Co-authored-by: Nikhil Parikh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants