-
-
Notifications
You must be signed in to change notification settings - Fork 359
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
Add crsf-telemetry filtered queues #5773
base: main
Are you sure you want to change the base?
Conversation
Attached is a lua widget to test |
8afa2c6
to
2e0483e
Compare
2e0483e
to
57e0ef2
Compare
What happened with the reversion of #5788 in the last commit? Are you happy with how this is working now? |
The last revision 57e0ef2 reverts an eeroneously included change of the DEBUG_BAUDRATE. A change of the DEBUG-BAUDRATE to the standard baudrate of 460800 (for TX16s) was recently add by @3djc via a different PR. I would like to get some feedback to the change of the LUA Well, I would be happy if some people would at least test that this PR does not change the behaviour of |
I'm lost, at what speed do you want it ? You asked for it to be changed: https://github.com/EdgeTX/edgetx/pull/5788/files, and now you want it back to 400k ? |
I just did not want to include a totally unrelated thing in this PR!
Your change to 460800 is that what I wanted ;-)
3djc ***@***.***> schrieb am Mo., 3. Feb. 2025, 08:43:
… I'm lost, at what speed do you want it ? You asked for it to be changed:
https://github.com/EdgeTX/edgetx/pull/5788/files, and now you want it
back to 400k ?
—
Reply to this email directly, view it on GitHub
<#5773 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACCLD74OYU7ERUUIXMGA4O32N4MYTAVCNFSM6AAAAABU67PSYGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMZQGE4DSMRQHE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I'll do a rebase of this PR to make the things clear.
Wilhelm Meier ***@***.***> schrieb am Mo., 3. Feb.
2025, 09:07:
… I just did not want to include a totally unrelated thing in this PR!
Your change to 460800 is that what I wanted ;-)
3djc ***@***.***> schrieb am Mo., 3. Feb. 2025, 08:43:
> I'm lost, at what speed do you want it ? You asked for it to be changed:
> https://github.com/EdgeTX/edgetx/pull/5788/files, and now you want it
> back to 400k ?
>
> —
> Reply to this email directly, view it on GitHub
> <#5773 (comment)>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ACCLD74OYU7ERUUIXMGA4O32N4MYTAVCNFSM6AAAAABU67PSYGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMZQGE4DSMRQHE>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>
|
57e0ef2
to
441eef6
Compare
Added new test widget version: https://github.com/wimalopaan/LUA/tree/main/WIDGETS/CrsfQueue |
Rebased |
Any comments on this? I'm still unsure ... My ideal solution would be, that the widget code does not have to pass this |
This seems overly complicated to me. Looking at the changes, this is limited to Color radios and Lua widgets.
This way:
This should also be extended to the sportTelemetryPop and ghostTelemetryPop functions for consistency. |
Thank you for your input! And yes, the filtering scheme maybe unneccessary. The idea was to offload the filtering fro LUA code to native code ... but I think, I'll drop that then.
That was my problem: how does |
Ah, yes I see the problem now. There is hack in the code for the lcd.exitFullScreen() function where a pointer to the current LuaWidget object is saved in the 'runningFS' variable.
To fix these properly will likely need a more robust solution that the current 'runningFS' variable - I need to think about this some more. I will be away for a few days though. |
I think this would be too errorprone!
I'm awaiting your input ;-) |
@wimalopaan is that designed like a subscribe/notify model? I'm still wondering how requests/replies are related to each other. It seems they aren't, right? So basically you can send some request, and you subscribe the reply type (your filters). Does that reflect the design idea? Bonus question: I guess this new API does not solve the multiple module issue (internal & external CRSF working at the same time), right? |
return 0; | ||
} | ||
|
||
static int luaCrossfireTelemetryCreatePrivateQueue(lua_State * const L) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should actually return a LUA object. luaCrossfireTelemetryRemovePrivateQueue
should probably be declared as __gc
for that object table, which would be called when the object is garbage collected.
After reading the code, I also have the feeling we could have something similar with less complexity and less templates. Templates classes are not cheap in terms of compiled code size and compile time. Also, I'm not sure how this is really required here. To me this looks like a simple subscribe/notify model, where actually LUA scripts should own the buffers, and the telemetry receiver would basically check for subscribers for specific message types, and push the payload to each of these subscribers. I don't really understand why you need the
No requirement for multiple subscribers for a given type of message? Is it assumed that filters for each widgets are disjoint? Or is that a mere copy and the same message could be posted to multiple queues? I would use a simple array with a max of X subscribers, or a vector if you insist (thus using dynamic re-allocation), however this could all be hidden from the headers, thus avoiding all these template classes in headers, which are actually just private implementation. And yes, I do second @philmoz that this should be a generic facility that could actually be used by any protocol, and not just CRSF. Each protocol will obviously interpret subscriptions ("filters") their own way, that should be it. PS: deeply sorry for not reviewing earlier! |
Yes.
dependant on the filter: if the filter matches, the message is put into the private queue for that widget (subscriber).
Each widget has to use it's own queue, and the
The code ensures that two filters are disjoint: if a widget wants to install a filter that "overlaps" with an already installed filter, it gets an error. I totally agree now, that this was too complicated (the basic idea was to offload the filtering into native code). And I now agree to your and @philmoz idea, just to provide a private copy of the messages into a private queue for each widget. The widget itself has then to decide if she wants to further process that message. So, all we need is (replace
My actual problem in doing so is: how does a Sorry, for this badly designed PR ... but obviously I need your help to fix that. |
I think I have a solution to better allow the Lua API functions to access the current script context (widget, or stand alone script). Need to do some more testing. I also need to think about whether custom mixer scripts and special / global function scripts could also be affected - do they need to call the crossfireTelemetryPop() function? |
From a practical point of view I would say: no (never needed that in the past). From an architectural point of view I would say: yes (why impose a restriction on that?). |
This PR tries to implement #5757
It introduces the following new lua functions:
crossfireTelemetryCreatePrivateQueue()
crossfireTelemetryPopPrivate()
crossfireTelemetryRemovePrivateQueue()
and it changes (non-breaking) the interface of
create()
of lua widgets.
For lua widgets that use
crossfireTelemetryPop()
nothing changes.The
create(zone, options)
function gets a third parametercreate(zone, options, widget_id)
. Thewidget_id
is a unique widget-identifier, that will be used in the other three new lua functions.crossfireTelemetryCreatePrivateQueue(widget_id, filter_table)
inserts a new filter for the widget with the id
widget_id
.filter_table
can contain up to 8 bytes that are compared against the first 8 bytes (startung with thelength
byt eof the frame) of an incomingcrsf
packet.0
values serve as wild-cards. If acrsf
-packet matches it is sorted out into the according private queue.This function returns error codes:
-1
if an equivalent filter already exists,-2
if no more private filter queues are possible (up to 8 filter queues are possible)crossfireTelemetryPopPrivate(widget_id)
extract a
crsf
message out of the privatecrsf
message queue for widget withwidget_id
. Return values are the same as forcrossfireTelemetryPop()
.crossfireTelemetryRemovePrivateQueue(widget_id)
removes a private
crsf
message queue (this also happens automatically if the widget is terminated).