yaapu / FrskyTelemetryScript

A LUA telemetry script and widget for the Horus X10(S),X12 and Taranis X9D+,X9E,QX7 and X-Lite radios using ArduPilot frsky passthru protocol
GNU General Public License v3.0
435 stars 141 forks source link

Sharing sportTelemetryPop() data with other scripts? #18

Closed KenLagoni closed 5 years ago

KenLagoni commented 5 years ago

I'm working on another project where I would like to transfer information to and from the receiver via the sportTelemetryPop and Push functions in my own Lua script. However I would also like to have the Yaapu script running and Thus I see a potential problem if two scripts are using the sportTelemetryPop() function, because then WHO is getting the data?

I think the easiest way is to add my decode code in the Yaapu processTelemetry() function and then store the results in a global variable somehow. Does anyone know if this is possible? Or is there a simpler way to somehow share or not fight over the telemetry pass-through data?

Thanks.

yaapu commented 5 years ago

Hi, I'm afraid the queue is shared so the data belongs to whoever pops it first. What radio are you targeting?

Memory on Taranis radios is very constrained, there's very little left ro run a second script. On the Horus you might be able to run an extra widget or two for memory is less constrained.

Anyway you would have to decode the data in the processTelemetry() and store it somewhere. Ideally you would dynamically unload part of yaapu script from memory, load and run your code and reload yaapu, some kind of interleave between 2 scripts of part of them.

I would design it as: proecessTelemetry() decodes all packets, extra yaapu packets if found are queued in a dedicated lua table, then periodically, at let's say 5Hz, you dynamically unload part of yaapu code, load yours, process the queue, send respondes and reload yaapu. This would impose quite an I/O load on the SD card but would work I guess. Another good design choice would be to code the external processTelemetry() as a callback to decouple it from the main script

KenLagoni commented 5 years ago

I have a Horus where I run a Lua scripts which shows google maps screenshots and plotting the position of the plane.

My script is working because the GPS coordinates are shared like a GPS sensor, and thus data is available in my script. But now I need some more data from the receiver and I’m trying doing it using my own 0x5xxx messages in pass-through, but using numbers which doesn't collide with our script. Since I don't need speed (only 2-5 times a minute), perhaps just writing data to the SD Card might be a good one to try, I just thought that I could make the data available using a couple of global variables.

Making proxessTelemetry() external was also in my consideration, but it may be overdoing it.

Thanks for the inputs!.

yaapu commented 5 years ago

Mhmm you could use sportTelemetryPush for uplink and custom frsky sensors downlink?

if you have custom hardware air side it should be quite easy to emulate an frsky sensor