Openvario / variod

Daemon for autonomous e-vario
4 stars 8 forks source link

Volume and Polar #35

Open hpmax opened 3 years ago

hpmax commented 3 years ago

Looking at the code, it appears that volume always starts up at 50% and XCSoar cannot command a particular volume, only up/down 10%. There is no way to override this in the config file. It seems like this should be configurable in the variod.conf file but isn't.

It also seems like XCSoar should push a specific value (not just up/down) on boot up or whenever the volume is changed. I'm not sure if XCSoar has a different volume level for the vario versus everything else. Similarly, should XCSoar be pushing the polar information into variod on startup?

kedder commented 3 years ago

Maybe it should simply remember the last-set volume? "Pushing on startup" is brittle, because you don't know if anything is actually listening for your "pushes" at that moment in time. Also, xcsoar has no idea when that "something" restarts and loses data it has "pushed".

hpmax commented 3 years ago

I agree with you about the "actually listening" problem. I feel like it would be nice to re-write the interface between variod and xcsoar to get an acknowledge as well as a few additional functions, but that's a bit beyond the scope of this at the moment.

Any thoughts on how to "remember" the last-set volume, but I don't want to write on every volume change. Maybe a write on shutdown, but that would rely on a signal which likely won't happen.

The main thing I was wondering is if there should be a variod.conf parameter, because there isn't one now.

kedder commented 3 years ago

I don't want to write on every volume change

Why not?

hpmax commented 3 years ago

Isn't that hard on the FLASH?

kedder commented 3 years ago

It shouldn't be. XCSoar does a write every second (or so). Also, OS typically buffers writes, so that they don't happen immediately on request.

bomilkar commented 3 years ago

This https://github.com/Openvario/variod/pull/19 addresses the issue for Polar (but not for Volume). It's counterpart on the XCSoar side is this: https://github.com/XCSoar/XCSoar/pull/378. I guess, there 2 functionalities need to be extended to cover Volume. Right?

Here is what happens between variod and XCSoar when variod starts after XCSoar is up and running: Variod sends "$POV,?,RPO*3B" XCSoar responds with the current Polar "$POV,RPO,..." which informs variod about the current Real Polar coefficients.

To address Volume setting: Variod would send "$POV,?,VOLxx" XCSoar would respond with "$POV,VO,75xx" to set volume level to 75% . (So far we have VU, VD, VM referring to https://www.openvario.org/doku.php?id=projects:series_00:software:nmea )

NB: Variod may send multiple request for information in one sentence. Example for Real Polar, McCready, Volume: "$POV,?,RPO,MC,VOL*xx"

hpmax commented 3 years ago

I'm good with that solution. What needs to be done to make that happen? Does something need to happen in XCSoar as well?

As a side note... And I didn't read through the entire ticket, I'd like to suggest the following:

Any control messages (in either direction) should be acknowledged. If an acknowledgement isn't received the sender should re-send periodically.

Secondly, there should be an "ping" command, as well as a: "I"ve just started up, configure me" command that variod should send to XCSoar. In this way, if variod crashes and is restarted during flight, XCSoar will know that it needs to be re-configured and can push the new configuration. It can also potentially check on variod and restart it if necessary, Only commands should be acknowledged though, otherwise it's just too much traffic.

bomilkar commented 3 years ago

I'm good with that solution. What needs to be done to make that happen? Does something need to happen in XCSoar as well?

both sides need some work. For XCSoar it starts in Device/Driver/OpenVario.cpp

As a side note... And I didn't read through the entire ticket, I'd like to suggest the following:

Any control messages (in either direction) should be acknowledged. If an acknowledgement isn't received the sender should re-send periodically.

Disagree! What would you gain?

Secondly, there should be an "ping" command, as well as a: "I"ve just started up, configure me" command that variod should send to XCSoar. In this way, if variod crashes and is restarted during flight, XCSoar will know that it needs to be re-configured and can push the new configuration. It can also potentially check on variod and restart it if necessary, Only commands should be acknowledged though, otherwise it's just too much traffic.

There is no need for a "ping". Your "I"ve just started up, configure me" is implemented: variod sends "$POV,?,RPO,MC,VOL" to ask for the 3 values (VOL to be implemented). When XCSoar starts it sends these values and whenever they change, too. What else do you need??

hpmax commented 3 years ago

A ping function would allow (optionally) for XCSoar to act as a watchdog for variod if variod went off the rails, allowing it to kill the job. Once killed, the OS should automatically re-spawn it, at which point it would ask for configuration info and get reconfigured by XCSoar.

As for why do we need "acknowledgements?" One obvious example would be if variod boots first and asks XCSoar to configure it, but XCSoar isn't ready to go, so it never sees the request. Again this just seems like good practice. Control messages should be pretty infrequent.

bomilkar commented 3 years ago

A ping function would allow (optionally) for XCSoar to act as a watchdog for variod if variod went off the rails, allowing it to kill the job. Once killed, the OS should automatically re-spawn it, at which point it would ask for configuration info and get reconfigured by XCSoar.

There are better ways to implement a watchdog timer.

As for why do we need "acknowledgements?" One obvious example would be if variod boots first and asks XCSoar to configure it, but XCSoar isn't ready to go, so it never sees the request. Again this just seems like good practice. Control messages should be pretty infrequent.

XCSoar sends polar, ballast, McReady, etc. when it starts and these values are already known. It sends these values every time they change. Why should XCSoar care if someone is listening??