can I send multi-line gcode commands via API

See example:
G91
G0 X0.1
G90
M117 .1 mm Right


#!/bin/bash

FILE="$1"
PRE=$(urlencode "{\"cmd\":\"")

COMMANDS=$(urlencode $(cat $FILE))

POST=$(urlencode "\"}")
PAYLOAD="${PRE}${COMMANDS}${POST}"
echo "$PAYLOAD"



This my attempt so far.  Single commands seem to work fine like this:
curl "http://len01.local:3344/printer/api/MPCNC?apikey=6bd3ec92-9acf-4cf4-b8b3-410f1ca6a298&a=send&data={"cmd":"G0 X10"}"

What am I missing?

Comments

  • My gcode comes from this file in this case.  I'm trying to use my existing pendant. This is for use with CNC rather than 3dprinter. 

    cat jog+x.1.gcode


  • You can send multiple g-codes in one command as long as every line is separated with newline (\n) and is a new complete command. It is not possible to have a G1 move at one line and further lines only having coordinates like some g-code variants support assuming latest G commands.

    How does your payload look like? Newline is %0a urlencoded, so are they included or did the newlines get stripped in bash handling?
Sign In or Register to comment.