-
Notifications
You must be signed in to change notification settings - Fork 52
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
[Discussion] What to put in the status server ? #38
Comments
You may want to also think about direct streaming of subscribed variables, where you subscribe to a variable with delta variance and timeout. Delta variances means that if a variable changes beyond the delta, the server sends an update message. Timeout happens when subscribed variables haven't changed in a while but you want periodic update messages. This is a fairly common approach in the IoT space, eliminating high rate polling for dashboards. The simplest text protocol for streaming is stomp, then mqtt. If you really want to be cutting edge, look into gRPC, which has language agnostic serial data marshalling. Then there's always just REST, but then your back to hammering the server with polling. Let me know what you think. |
One more thing this evening. One reason grbl has been so successful is that's extremely simple (primarily limited by mega328p). I suggest you keep beagleg as similarly as simple as possible. Move webserver, websockets, rpc, dashboards etc away from beagleg but provide a high-speed interconnect between 2 components.I'm sure you already are going down this route. Since running on a single board computer, you might want to skip all this inter-process communication, marshalling, etc and just do shared memory, where beagleg would expose its variable table as a read-only memory block. I'll think about this a little more. Here's a really sample of C->py shm |
Yes, simplicity is the goal. Here, we should find all the relevant features that would be needed for such an interface (e.g. the idea of subscribing to changes that you described above).The actual implementation should not be part of the core (which rather then provides the programmatic interfaces needed), but the result of plug-ins or IPC-separated processes. Directly shared memory can be a problem with thread-safety, but some super-simple, low-overhead serialization is probably what I would go for, e.g. Protocol Buffers or even Cap'n Proto (gRPC is based on protocol buffers.) Anyway, what more features can you think of, paging @lromor @bigguiness |
Hi, We could provide all these servers as plugins easily loaded in the event server, and support different plugins for the different tastes (ie grpc, bare udp socket, tcp sockets, bare contacts, etc..) |
I think a catch all structure would be great coordinates of axises configured in config file (not just x,y, and z) these taken from grbl's parser state command, beagleg probably has different gcodes current selected tool soft limit status machine state (grbl states here Idle, Run, Hold, Jog, Alarm, Door, Check, Home, Sleep) anything I missed? I'm sure there is. I think setting a variable to broadcast timeout for this status in milliseconds. 100 would be 10 updates per seconds. Of course, this catch all status could be broken up into multiple status forms, each with its own timeout. So things like modes aren't sent at a high refresh rate. setting variable timeout to 0 disables broadcast. each status group has a single char request like your current 'p' char. I also agree, shared memory is not a good approach. leaning towards streaming protobuf or json, prefer json even with 2x-ish byte overhead because debugging simplicity. Hope this makes sense. |
here's rapidjson impl, status.cpp
root@bb[580]: g++ status.cpp -o status real 0m0.021s for json generation, using rapidjson or other json lib might be overkill where sprintf is simple. beagleg isn't accepting json just sending it. |
cout version is slower (doing some extra divides) root@bb[650]: cat status_cout.cpp
root@bb[651]: g++ status_cout.cpp -o status_cout real 0m0.026s |
I like the relatively simple structure of having everything in one rcord that is sent regularly. Thanks for your experiments. Looks like the overhead for cout is not soo much; if we can get some result with on-board means for relatively low overhead we should avoid external dependencies; so |
The 'only send something when values change'-mode would be in particular interesting for machine gcode variables - there are a couple of thousand of them so only sending changes is very useful :).
That subsection contains all variables that are set at first connect, but then only variables that changed since last time. We might send changes immediately when they occur, but rate-limit and don't send more than e.g. 10/second. |
Network stack: I am in favor of just a simple socket , but http or websockets might be more useful in certain context (BUT, we'd add more dependencies on external libraries). So maybe simple socket, but then people can add translation proxies as they wish ? |
onChange, rating limiting, variables, keyframes over simple socket, all this is great and couldn't be simpler. |
here's the last timing, printf
root@bb[535]: g++ status_printf.cpp -o status_printf real 0m0.019s |
In order to have a side-channel to communicate with the machine, a status server has been added recently, but at this point it is merely an experimental stub.
There can be multiple types of status services, one could be a fully fledged webserver that allows to interact with the machine, but having the simplicity of a very simple request/response socket service would allow for very easy interaction with some UI (which can be an LCD on the machine or something else).
Right now, the interaction is super simple: a single letter in, some JSON formatted variables back
The request should probably be some json request, to be able to convey parameters easily. Or we go with query parameters similar to HTTP GET requests (
?q=some_query
). Output as JSON is probably an ok output though somewhat harder to parse than a token-delimited format; it is supported by many languages out of the box and allows flexible extension of what we send.Anyway, let's discuss what we actually want and what should be provided, so that we then can design what would be a good request/response model. I think it should allow to have extensive support to read the current status of the machine. And limited ways to change parameters without messing with the current running GCode too much:
What else ? Hartley, you have added some functionality to your local status server, what did you add ?
The text was updated successfully, but these errors were encountered: