From 5607ab96adec77965f6581680556c328a01e4dda Mon Sep 17 00:00:00 2001 From: Simon Voordouw Date: Mon, 12 Jun 2017 17:21:09 +0200 Subject: [PATCH] add end and start-gcode parameters to printer/fetch API --- src/rest/api/api_printer.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/rest/api/api_printer.lua b/src/rest/api/api_printer.lua index 3b895ba..1463ab9 100644 --- a/src/rest/api/api_printer.lua +++ b/src/rest/api/api_printer.lua @@ -216,10 +216,23 @@ function M.fetch_POST(request, response) return end + local gcodeFiles = " " + local startCode = request:get("start_code") + if startCode != nil then + gcodeFiles = gcodeFiles .. '/tmp/startcode ' + io.open('/tmp/startcode', 'w+').write(startCode) + end + + local endCode = request:get("end_code") + if endCode != nil then + gcodeFiles = gcodeFiles .. '/tmp/endcode ' + io.open('/tmp/endcode', 'w+').write(endCode) + end + local socket = printer:getId() local remote = settings.get('gcode_server') local id = request:get("id") - io.popen("print-fetch " .. socket .. " " .. remote .. " " .. id) + io.popen("print-fetch " .. socket .. " " .. remote .. " " .. id .. gcodeFiles) response:setSuccess() end