C++ API for Duet 3 Mainboard 6HC
-
@T3P3Tony Thanks a lot ! This is clear for me !
-
@T3P3Tony I have a new question regarding a command
How does the M291 command (to display a message) works ?
If this command is in a G-Code being executed, how can I retrieve the message ? How will the REST API will notify me of this please ? -
Concerning the REST API, can I access a statut Response like the one proposed by RepRapFirmware please ? https://github.com/Duet3D/RepRapFirmware/wiki/JSON-responses
I can't find any info on this. -
That's one for @chrishamm, however there is some documentation here https://github.com/Duet3D/DuetSoftwareFramework/blob/master/README.md.
-
@dc42 Thank you for your answer ! My question is regarding this request : https://github.com/Duet3D/DuetSoftwareFramework/blob/master/README.md#get-machinestatus
Do you know where I can find the status response that I will receive when using this request please ? -
@ElevenJune: When getting status information I think you may benefit from understanding the JSON Machine Model, as most of the information returned via status requests will be either the full Machine Model, a subset, or a patch - depending on the api and commands you use. There is a Machine Model plugin for DWC which is a great way of navigating the model to find where keys/values are.
For example you mentioned a M291 msg: When triggered, an M291 command will populate the Machine Model keys:
state.messageBox.title
state.messageBox.message
So the command : M291 P"This Is A Test Msg" R"My Msg"
Would result in:state.messageBox.title : "My Msg"
state.messageBox.message : "This Is A Test Msg"
The values will auto clear once the msg has been acknowledged or timed-out.
(Note: There are other keys set by M291 but I have excluded them for brevity)(I actually use these keys specifically in my NodeDSF project to trigger events. I would normally point you at my code to give you an idea, but its node.js/javascript so I'm not sure it would be much help.)
Hope this helps!
-
@MintyTrebor Thanks for your reply ! Unfortunately I will be programming in C++ so I cannot use this Machine Model. Do you know how I can access this type of information with the REST API to later use it in C++ please ?
-
@ElevenJune If your using the rest api to query the status then you will have to use the machine model. The HTTP GET /machine/status request you can send returns a JSON object which is the Machine Model. If you go the websocket route, it will still be JSON and the machine model. I don't think there is any way around it with the rest api.
-
@MintyTrebor Thanks for your reply.
Is MachineModel a Json structure that will be returned with the request ? Or is it a something like a JavaScript class ? I don't understand. -
Is MachineModel a Json structure that will be returned with the request ?
Yes.
The easiest way of seeing it is by entering:http://[your sbc/dsf ip address]/machine/status
into your browser.
It should just return the full JSON Machine Model as text (if using firefox it will automatically parse for you).
For the avoidance of confusion - the returned data is just text with an enforced structural pattern (JSON)
-
@MintyTrebor Thanks for your reply and your patience, I got a bit confused while reading the last messages !
This is what I am looking for. I don't have received my Duet card yet so I can't try the request, would you have a link showing the content of the Machine Model or an example of it please ? -
https://duet3d.dozuki.com/Wiki/Object_Model_of_RepRapFirmware
will get you started.
-
@MintyTrebor This is what I needed ! Thank you
If this the structure to use when I want to retrieve info during printing (like position, % of completion, speed, etc) or is there a other one ?