jfjlaros / arduino-simple-rpc

Python client for the Arduino simpleRPC protocol.
MIT License
24 stars 7 forks source link

Initialize interface from disk #18

Closed chrisflesher closed 3 years ago

chrisflesher commented 3 years ago

I'm trying to use simple_rpc interface over an RF link. It is a very slow procedure to load the interface definition (e.g. 2 min to load 29 function definitions). I was wondering if it might be possible to cache the interface definition to disk and re-use it (assuming it doesn't change).

jfjlaros commented 3 years ago

That should not be too hard to implement, but I wonder why this link is so slow. Are you working with LoRaWAN or something like that?

chrisflesher commented 3 years ago

Yes, using the RadioHead RF95 library (LoRaWAN).

chrisflesher commented 3 years ago

We would like to be able to load it straight from disk rather than loading it the long way the first time and caching it (to avoid watchdog timeout).

jfjlaros commented 3 years ago

That sounds interesting. I would be happy to lean about the actual use case.

I will draft a design and share it with you tomorrow, it is getting rather late here.

chrisflesher commented 3 years ago

Thanks! It is for an ice penetrating probe experiment. We have a cryochamber that simulates the surface of Europa (a moon of Jupiter). The chamber is about 1m diameter and filled with 2m of ice / 1m of vacuum. We putting a small probe in there (about 3cm diameter by 10cm tall copper slug with electronics inside) and drilling down.

We're using 900MHz RF LoRa link to communicate because it works well even when there is water (unlike 2.4GHz wifi). Once the probe enters the ice we expect particles to seal the entrance and we'll start to pressurize the cavity enough to make water, heat it up, and pump it. We'll see what happens!

chrisflesher commented 3 years ago

For comms we have a simple serial to RF95 Arduino on the surface. Then in the ice is an Arduino with RF95 wrapped by a Stream class so we can use the simple rpc interface. There were some issues getting this to work, we found we had to buffer characters coming over RF95 until no new data was seen for 200ms. This was needed for the simple rpc interface to get the full message.

chrisflesher commented 3 years ago

It is working great, it is slow (e.g. 3 seconds per RPC call) but that's fine since we're melting ice :)

jfjlaros commented 3 years ago

That sounds very exciting, I never thought I would be indirectly contributing to a space project.

What do you think about the following proposal?

In the Interface class, we add the following methods:

Perhaps we can also add an optional load parameter to the constructor for convenience.

In the CLI, we:

Regarding the file format. We could either use the raw response, or serialise it to something like JSON or YAML. I can imagine the latter can be convenient at times.

chrisflesher commented 3 years ago

That sounds great! I like the idea for serializing to JSON or YAML so you can edit it easily.

On Fri, May 28, 2021 at 3:19 AM Jeroen F.J. Laros @.***> wrote:

That sounds very exciting, I never thought I would be indirectly contributing to a space project.

What do you think about the following proposal?

In the Interface class, we add the following methods:

  • save for writing the interface definition to a file.
  • load for loading the interface definition from a file.

Perhaps we can also add an optional load parameter to the constructor for convenience.

In the CLI, we:

  • Add the option -s to the list subcommand to save the interface definition to a file.a file.
  • Add the option -l to the call subcommand to load the interface definition from a file. This also skips the regular initialisation procedure.

Regarding the file format. We could either use the raw response, or serialise it to something like JSON or YAML. I can imagine the latter can be convenient at times.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jfjlaros/arduino-simple-rpc/issues/18#issuecomment-850241702, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKFJ2UXVG7ZDVCBNUAVVE3TP5GYNANCNFSM45U6JOIA .

jfjlaros commented 3 years ago

I have something working in the files branch.

Tests and documentation are missing and I want to do a bit of refactoring, but I think it is good for testing purposes.

chrisflesher commented 3 years ago

Ok, thank you! I'll get a chance to test it either Monday or Wednesday of next week.

On Fri, May 28, 2021 at 1:51 PM Jeroen F.J. Laros @.***> wrote:

I have something working in the files https://github.com/jfjlaros/arduino-simple-rpc/tree/files branch.

Tests and documentation is missing and I want to do a bit of refactoring, but I think it is good for testing purposes.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jfjlaros/arduino-simple-rpc/issues/18#issuecomment-850604409, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKFJ2S35AUAC3TK2GSCDU3TP7Q4RANCNFSM45U6JOIA .

chrisflesher commented 3 years ago

I tried the files branch and it worked well. Thanks for writing this.

On Fri, May 28, 2021 at 2:05 PM Christopher Flesher @.***> wrote:

Ok, thank you! I'll get a chance to test it either Monday or Wednesday of next week.

On Fri, May 28, 2021 at 1:51 PM Jeroen F.J. Laros < @.***> wrote:

I have something working in the files https://github.com/jfjlaros/arduino-simple-rpc/tree/files branch.

Tests and documentation is missing and I want to do a bit of refactoring, but I think it is good for testing purposes.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jfjlaros/arduino-simple-rpc/issues/18#issuecomment-850604409, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKFJ2S35AUAC3TK2GSCDU3TP7Q4RANCNFSM45U6JOIA .

jfjlaros commented 3 years ago

I just merged the branch and released a new version.