Skip to content
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

Command interface #54

Closed
dnadlinger opened this issue Nov 18, 2019 · 9 comments
Closed

Command interface #54

dnadlinger opened this issue Nov 18, 2019 · 9 comments
Labels
enhancement New feature or request

Comments

@dnadlinger
Copy link
Contributor

As we add more features to the firmware, we will need quite a few more commands, e.g. to commit settings to flash storage (#29), to configure high-bandwidth streaming, etc.

We could add more and more TCP ports that just directly parse lines into a given serde'd JSON type, but that seems like it would quickly become unwieldy. Another simple option would be to stick with a JSON object per request, but have a set command type/payload structure.

Any set ideas/preferences?

@cjbe
Copy link
Contributor

cjbe commented Nov 18, 2019

IMHO a JSON command/payload structure that passes the (JSON) payload on to various handler functions sounds like it will do everything we need, and give a good reward/effort ratio.

@jordens
Copy link
Member

jordens commented Nov 20, 2019

My suggestion and preference is to go to MQTT (or something else if there are good alternatives) as soon as possible. To me this seems much better for a bunch of reasons and it was the plan (#3) all along. There is the beginning of a no-std mqtt parser and some potentially reusable server code that may help. ffi-ing the paho bindings is probably not worth it. It doesn't look too hard to implement the rest. @astro seemed interested and I know @gkasprow has used mqtt for several of his projects. It would be great if we could get a student to lead this. no-std MQTT is a key building block for embedded Rust and I am pretty sure it would receive wide usage (certainly much wider than another cutsom json req-resp).

@jordens jordens added the enhancement New feature or request label Nov 20, 2019
@gkasprow
Copy link

I used MQTT from Arduino libs. It is also STM32duino so porting should be trivial. But it is not RUST...

@jordens
Copy link
Member

jordens commented Jan 6, 2020

Or CoAP: Several implementations in Rust and no_std.

@jordens
Copy link
Member

jordens commented Mar 27, 2020

And now there is embedded-mqtt, thanks to @ryan-summers for pointing it out.

@dnadlinger
Copy link
Contributor Author

Do you have any examples for what you would consider a well-designed interface using MQTT?

I am primarily interested in two interfaces for Stabilizer:

  • A way to set system parameters such as IIR coefficients, reset error indicators, etc., easily extensible for different hardware variants (e.g. via an RPC-like interface), and
  • high-rate real-time streaming of data (at least one 16 bit channel at the full 1 MS/s rate continuously).

MQTT's pub-sub messaging model doesn't seem to be a good match for either, because of the obvious impedance mismatch in the first case, and the data rate in the second (particularly considering the limited on-device computing power).

@dtcallcock dtcallcock mentioned this issue Apr 1, 2020
@jordens
Copy link
Member

jordens commented Apr 1, 2020

Mqtt is perfectly fine for the first use case (IIR configuration, streaming configuration, flag management, enable/disable, commands, request-response) and also for status monitoring at ~Hz rate.
What do you mean by impedance mismatch? Compared to the requirements this device has a massive amount of unused computing power. It can easily saturate the Ethernet link and could also overwhelm any MQTT broker.

For full/high rate streaming data I see few other options than custom binary (using one of the many serialization options in rust). But streaming is not really within the scope of this issue. And JSON for streaming full-rate data is a terrible idea.

@jordens
Copy link
Member

jordens commented Apr 1, 2020

E.g. look at the AWS IoT Core mqtt topic design guide.

Example:

  • application is sinara or artiq
  • context is e.g. opticlock
  • thing-name is the name of a Stabilizer/Booster/Thermostat, e.g. clk-fiber

And then you could have the following MQTT topics (PUBLISH/SUBSCRIBE from device perspecitve):

  • publish ADC/DAC telemetry: dt/sinara/opticlock/clk-fiber/analog
  • publish filter error flags, digital state, counters dt/sinara/opticlock/clk-fiber/state
  • subscribe IIR coefficients and filter configuration: dt/sinara/opticlock/clk-fiber/iir1
  • subscribe to streaming configuration (target IPs, rate, etc): dt/sinara/opticlock/clk-fiber/stream
  • subscribe to save-settings or reset commands: cmd/sinara/opticlock/clk-fiber/req
  • publish to the command results to cmd/sinara/opticlock/clk-fiber/res

Payloads TBD but could well be some JSON for e.g. straight telegraf/influxdb ingest or AWS IoT core compat.

@jordens
Copy link
Member

jordens commented Oct 13, 2020

Forked into individual issues (see above).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants