connect SBC to Duet via Network and run gcode/macro with DSF
-
Hi all,
I am new to the Duet. I would like to connect my SBC to the Duet via Network and then send commands with python to duet to run macros and eventually receive feedback from the duet.
I have found 2 python code examples on github:def subscribe():
subscribe_connection = SubscribeConnection(SubscriptionMode.PATCH)
subscribe_connection.connect()try: # Get the complete model once object_model = subscribe_connection.get_object_model() print(object_model) # Get multiple incremental updates, due to SubscriptionMode.PATCH, only a # subset of the object model will be updated for _ in range(0, 3): update = subscribe_connection.get_object_model_patch() print(update) finally: subscribe_connection.close()
and
def send_simple_code():
command_connection = CommandConnection(debug=True)
command_connection.connect()try: # Perform a simple command and wait for its output res = command_connection.perform_simple_code("M115") print("M115 is telling us:", res) finally: command_connection.close()
but I don't undesrtand here where should I insert the argument to connect to the board and what does this argument look like?
Also what is the DSF UNIX socket?
I would really appreciate your help.
-
@job123 DSF is designed to connect to the Duet via an SPI bus, not a network connection. If you need to use a network connection then you need to use the HTTP API:
-
@T3P3Tony thanks for the reply.
Do I have to install the RepRap firmware first? Also are there any python example codes on how to send commands from the SBC and receive feedback using this HTTP API? -
@job123 RepRapFirmware needs to be running on the Duet for you to do anything with it of course, including connect to its API over HTTP. On the SBC you do not need any specific software form us.
The API documentation is as linked before:
https://github.com/Duet3D/RepRapFirmware/wiki/HTTP-requestsThis thread may be of interest to you:
https://forum.duet3d.com/topic/31198/reprapfirmware-python-apiThis project may also be of intrest.
https://github.com/AndyEveritt/DuetWebAPI