What's the correct way to send gcode to SBC
-
Hi -
I'm working on a project (DuetLapse3.py) and trying to get it working with SBC (which I do not have but others are testing).
Specifically - I am having problems sending gcodes and it may simply be that the wrong method / syntax is being used.
with a NON SBC (Duet2Wifi) the following python code (where command is a string with the gcode command) works fine (as expected):
URL=('http://'+duet+'/rr_gcode?gcode='+command) r = requests.get(URL, timeout=5)
on SBC I've tried three approaches: this one returns http code 200 - but apparently does nothing at the Duet end
URL=('http://'+duet+'/machine/status?gcode='+command) r = requests.get(URL, timeout=5)
this (using post) gives a 405 Method not allowed error:
URL=('http://'+duet+'/machine/status') r = requests.post(URL, data=command)
and this gives a 404 (not found) error:
URL=('http://'+duet+'/rr_gcode?gcode='+command) r = requests.get(URL, timeout=5)
Any and all help appreciated.
-
@stuartofmt have you seen this?
Might help
https://github.com/Duet3D/DuetSoftwareFramework#rest-api -
No - and thanks! Seems that the correct form is
URL=('http://'+duet+'/machine/code') r = requests.post(URL, data=command)
i.e. /machine/code (as opposed to machine/status) in the post command. Definitely looks like my brain seeing something different than my eyes ....
I'll submit a revised test to the "testers"
-
Folks - we are still experiencing problems with this and need some help.
The issue is that we cannot seem to send Gcode commands to SBC Duet. Other commands (like getting status) work fine. So the ip address is correct (variable duet in the code below).
Here is the relevant python3 code. For testing command = 'M117 Test of SBC':
URL=('http://'+duet+'/machine/code/') r = requests.post(URL, data=command) logger.info('URL was: '+r.url) if (r.ok): return logger.info('sendDuetGCode failed with code: '+str(r.status_code)+'and reason: '+str(r.reason)) return
This returns no http error i.e. from an http perspective the post works. This has also been tried with /machine/code (i.e. no trailing /). Same results.
DWC is being used to monitor for the correct resonse. No message is ever displayed in DWC to the M117 command.
on a non SBC the following works correctly.
URL=('http://'+duet+'/rr_gcode?gcode='+command) r = requests.get(URL, timeout=5)
Help !
-
This is now resolved. It seems that DWS endpoints are not completely consistent.
Sending a gcode of 'M117 Test of SBC' works in one situation bit not the other.
Sending 'M117 "Test of SBC"' works in both situations. -
Something for @chrishamm ?
-
FWIW (and I should have known better) - I prefer the stricter approach with the string being quoted. Exactly why I did not do that in the test ..... having said that we would not have discovered this discrepancy.
I note that the gcode documentation for M117 here:
https://duet3d.dozuki.com/Wiki/Gcode
shows both forms as examples. -
@PCR @stuartofmt I can confirm this bug and I've got a fix ready. Nevertheless I agree it's cleaner to quote strings everywhere.