From a3468b85ce4e4fd9a5ad3250dcb596321f7b9637 Mon Sep 17 00:00:00 2001 From: Simon Voordouw Date: Tue, 11 Apr 2017 12:00:34 +0200 Subject: [PATCH 01/19] add fetch-from-server api endpoint --- Makefile | 2 ++ src/rest/api/api_printer.lua | 8 ++++++ src/script/print-fetch.lua | 56 ++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100755 src/script/print-fetch.lua diff --git a/Makefile b/Makefile index c89fe98..98ef1fb 100644 --- a/Makefile +++ b/Makefile @@ -126,6 +126,8 @@ define Package/wifibox/install $(INSTALL_BIN) $(WIFIBOX_BASE_DIR)/script/signin.sh $(1)/$(TGT_LUA_DIR_SUFFIX)/script $(CP) $(WIFIBOX_BASE_DIR)/script/logrotate-wifibox.conf $(1)/etc/logrotate.d/wifibox.conf + $(LN) -s /$(TGT_LUA_DIR_SUFFIX)/script/print-fetch.lua $(1)/bin/print-fetch + $(CP) $(WIFIBOX_BASE_DIR)/script/wifibox.uci.config $(1)/etc/config/wifibox # copy base configuration to uci config dir $(CP) $(WIFIBOX_BASE_DIR)/FIRMWARE-VERSION $(1)/etc/wifibox-version diff --git a/src/rest/api/api_printer.lua b/src/rest/api/api_printer.lua index 194ad82..2048dd8 100644 --- a/src/rest/api/api_printer.lua +++ b/src/rest/api/api_printer.lua @@ -185,6 +185,14 @@ local function addSequenceNumbering(printer, response) end end +function M.fetch_POST(request, response) + local printer,msg = printerUtils.createPrinterOrFail(argId, response) + if not printer or not printer:hasSocket() then return end + + local socket = printer:getId() + io.popen("print-fetch.lua " .. socket) +end + --requires: gcode(string) (the gcode to be appended) --accepts: id(string) (the printer ID to append to) --accepts: clear(bool) (chunks will be concatenated but output file will be cleared first if this argument is true) diff --git a/src/script/print-fetch.lua b/src/script/print-fetch.lua new file mode 100755 index 0000000..577639e --- /dev/null +++ b/src/script/print-fetch.lua @@ -0,0 +1,56 @@ +#!/usr/bin/lua +package.cpath = package.cpath .. '/usr/lib/lua/?.so' +JSON = (loadfile "/usr/share/lua/wifibox/util/JSON.lua")() + +local p3d = require("print3d") + +local printer = p3d.getPrinter(arg[1]) + +local remote = "10.0.0.212:8080" + +local finished = false + +local info = JSON:decode(io.popen("wget -qO - " .. remote .. "/info/"):read("*a")) + +local current_line = 0 +local total_lines = tonumber(info["lines"]) +local started = false + +while(not finished) +do + local f = io.popen("wget -qO - " .. remote .. "/fetch/" .. current_line) + local line = f:read() + while line ~= nil do + printer:appendGcode(line) + current_line = current_line + 1 + line = f:read() + end + if current_line > total_lines then + finished = true + break + end + + if not started then + started = true + print("send print start command") + printer:startPrint() + end + + local accepts_new_gcode = false + + while (not accepts_new_gcode) + do + local current,buffer,total,bufferSize,maxBufferSize = printer:getProgress() + + print("current: " .. current .. " total:" .. total .. " buffer: " .. buffer .. " bufferSize: " .. bufferSize .. " maxBufferSize: " .. maxBufferSize) + local percentageBufferSize = bufferSize / maxBufferSize + + if percentageBufferSize < 0.8 then + print("buffer below 80% capacity, sending new gcode") + accepts_new_gcode = true + else + print("buffer above 80% capacity") + os.execute("sleep 10") + end + end +end From fe5b2ec30608bfc98e6a9002af06f62ce0a00830 Mon Sep 17 00:00:00 2001 From: Simon Voordouw Date: Tue, 11 Apr 2017 12:50:49 +0200 Subject: [PATCH 02/19] get gcode-server url from config --- src/rest/api/api_printer.lua | 3 ++- src/script/print-fetch.lua | 2 +- src/script/wifibox.uci.config | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rest/api/api_printer.lua b/src/rest/api/api_printer.lua index 2048dd8..1f3b8c0 100644 --- a/src/rest/api/api_printer.lua +++ b/src/rest/api/api_printer.lua @@ -190,7 +190,8 @@ function M.fetch_POST(request, response) if not printer or not printer:hasSocket() then return end local socket = printer:getId() - io.popen("print-fetch.lua " .. socket) + local remote = settings.get('gcode_server') + io.popen("print-fetch.lua " .. socket .. " " .. remote) end --requires: gcode(string) (the gcode to be appended) diff --git a/src/script/print-fetch.lua b/src/script/print-fetch.lua index 577639e..bba863a 100755 --- a/src/script/print-fetch.lua +++ b/src/script/print-fetch.lua @@ -6,7 +6,7 @@ local p3d = require("print3d") local printer = p3d.getPrinter(arg[1]) -local remote = "10.0.0.212:8080" +local remote = arg[2] local finished = false diff --git a/src/script/wifibox.uci.config b/src/script/wifibox.uci.config index dd8146e..e2f8fe1 100644 --- a/src/script/wifibox.uci.config +++ b/src/script/wifibox.uci.config @@ -10,3 +10,4 @@ config settings 'system' config settings 'general' option printer_type 'ultimaker' + option gcode_server 'tranquil-meadow-94621.herokuapp.com' From 25aba526b4796906ff4fc564068b302968f3c37c Mon Sep 17 00:00:00 2001 From: Simon Voordouw Date: Tue, 11 Apr 2017 17:04:57 +0200 Subject: [PATCH 03/19] fetch specific file id from server --- src/rest/api/api_printer.lua | 3 ++- src/script/print-fetch.lua | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/rest/api/api_printer.lua b/src/rest/api/api_printer.lua index 1f3b8c0..b879eae 100644 --- a/src/rest/api/api_printer.lua +++ b/src/rest/api/api_printer.lua @@ -191,7 +191,8 @@ function M.fetch_POST(request, response) local socket = printer:getId() local remote = settings.get('gcode_server') - io.popen("print-fetch.lua " .. socket .. " " .. remote) + local id = request:get("id") + io.popen("print-fetch.lua " .. socket .. " " .. remote .. " " .. id) end --requires: gcode(string) (the gcode to be appended) diff --git a/src/script/print-fetch.lua b/src/script/print-fetch.lua index bba863a..12e1c48 100755 --- a/src/script/print-fetch.lua +++ b/src/script/print-fetch.lua @@ -10,7 +10,9 @@ local remote = arg[2] local finished = false -local info = JSON:decode(io.popen("wget -qO - " .. remote .. "/info/"):read("*a")) +local id = arg[3] + +local info = JSON:decode(io.popen("wget -qO - " .. remote .. "/info/" .. id):read("*a")) local current_line = 0 local total_lines = tonumber(info["lines"]) @@ -18,7 +20,7 @@ local started = false while(not finished) do - local f = io.popen("wget -qO - " .. remote .. "/fetch/" .. current_line) + local f = io.popen("wget -qO - " .. remote .. "/fetch/" .. id .. "/" .. current_line) local line = f:read() while line ~= nil do printer:appendGcode(line) From 02b198d7730f06b06f949fcff83f684309ed22ce Mon Sep 17 00:00:00 2001 From: Simon Voordouw Date: Thu, 18 May 2017 15:01:27 +0200 Subject: [PATCH 04/19] return success response --- src/rest/api/api_printer.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rest/api/api_printer.lua b/src/rest/api/api_printer.lua index b879eae..4a5a396 100644 --- a/src/rest/api/api_printer.lua +++ b/src/rest/api/api_printer.lua @@ -193,6 +193,7 @@ function M.fetch_POST(request, response) local remote = settings.get('gcode_server') local id = request:get("id") io.popen("print-fetch.lua " .. socket .. " " .. remote .. " " .. id) + response:setSuccess() end --requires: gcode(string) (the gcode to be appended) From 82d4179bc3ccdbe93913d85698656c2a788c5c55 Mon Sep 17 00:00:00 2001 From: Simon Voordouw Date: Mon, 12 Jun 2017 12:05:57 +0200 Subject: [PATCH 05/19] add logging, parameter checking to print-fetch script --- src/script/print-fetch.lua | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/script/print-fetch.lua b/src/script/print-fetch.lua index 12e1c48..4f2b0c6 100755 --- a/src/script/print-fetch.lua +++ b/src/script/print-fetch.lua @@ -1,4 +1,17 @@ #!/usr/bin/lua + +local function log(message) + os.execute("logger" .. message) + print(message) +end + +if (table.getn(arg) == 0) then + print("Usage: ./print-fetch {printerSocket} {remoteURL} {id}") + return +end + +log("starting gcode fetch program") + package.cpath = package.cpath .. '/usr/lib/lua/?.so' JSON = (loadfile "/usr/share/lua/wifibox/util/JSON.lua")() @@ -12,18 +25,22 @@ local finished = false local id = arg[3] +log("gcode file id: " .. id) + local info = JSON:decode(io.popen("wget -qO - " .. remote .. "/info/" .. id):read("*a")) local current_line = 0 local total_lines = tonumber(info["lines"]) local started = false +log("total lines: " .. total_lines) + while(not finished) do local f = io.popen("wget -qO - " .. remote .. "/fetch/" .. id .. "/" .. current_line) local line = f:read() while line ~= nil do - printer:appendGcode(line) + printer:appendGcode(line, total_lines) current_line = current_line + 1 line = f:read() end From 2f91065ff7476bb8395d03be15f595e6207a092a Mon Sep 17 00:00:00 2001 From: Simon Voordouw Date: Mon, 12 Jun 2017 12:06:27 +0200 Subject: [PATCH 06/19] add check for control and clear gcode on print fetch start --- src/rest/api/api_printer.lua | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/rest/api/api_printer.lua b/src/rest/api/api_printer.lua index 4a5a396..3b895ba 100644 --- a/src/rest/api/api_printer.lua +++ b/src/rest/api/api_printer.lua @@ -189,10 +189,37 @@ function M.fetch_POST(request, response) local printer,msg = printerUtils.createPrinterOrFail(argId, response) if not printer or not printer:hasSocket() then return end + local controllerIP = accessManager.getController() + local hasControl = false + if controllerIP == "" then + accessManager.setController(request.remoteAddress) + hasControl = true + elseif controllerIP == request.remoteAddress then + hasControl = true + end + + if not hasControl then + response:setFail("No control access") + return + end + + + log:verbose(MOD_ABBR, " clearing all gcode for " .. printer:getId()) + response:addData('gcode_clear',true) + local rv,msg = printer:clearGcode() + + if rv == false then + response:addData('status', msg) + response:setFail("could not clear gcode (" .. msg .. ")") + elseif rv == nil then + response:setError(msg) + return + end + local socket = printer:getId() local remote = settings.get('gcode_server') local id = request:get("id") - io.popen("print-fetch.lua " .. socket .. " " .. remote .. " " .. id) + io.popen("print-fetch " .. socket .. " " .. remote .. " " .. id) response:setSuccess() end From 9c6bd6cdeaa7c8ba2ede6e159e92a8b6e99efbd9 Mon Sep 17 00:00:00 2001 From: Simon Voordouw Date: Mon, 12 Jun 2017 15:37:43 +0200 Subject: [PATCH 07/19] gcode file is done when current_line is higher or equal than total_lines --- src/script/print-fetch.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/script/print-fetch.lua b/src/script/print-fetch.lua index 4f2b0c6..3fd0eaa 100755 --- a/src/script/print-fetch.lua +++ b/src/script/print-fetch.lua @@ -44,7 +44,7 @@ do current_line = current_line + 1 line = f:read() end - if current_line > total_lines then + if current_line >= total_lines then finished = true break end @@ -60,8 +60,6 @@ do while (not accepts_new_gcode) do local current,buffer,total,bufferSize,maxBufferSize = printer:getProgress() - - print("current: " .. current .. " total:" .. total .. " buffer: " .. buffer .. " bufferSize: " .. bufferSize .. " maxBufferSize: " .. maxBufferSize) local percentageBufferSize = bufferSize / maxBufferSize if percentageBufferSize < 0.8 then From b2590e41427ecba19bc143a206c54675de6f09ca Mon Sep 17 00:00:00 2001 From: Simon Voordouw Date: Mon, 12 Jun 2017 17:20:29 +0200 Subject: [PATCH 08/19] add options to pass start and end-gcode to print-fetch --- src/script/print-fetch.lua | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/script/print-fetch.lua b/src/script/print-fetch.lua index 3fd0eaa..5d4d7d3 100755 --- a/src/script/print-fetch.lua +++ b/src/script/print-fetch.lua @@ -6,7 +6,7 @@ local function log(message) end if (table.getn(arg) == 0) then - print("Usage: ./print-fetch {printerSocket} {remoteURL} {id}") + print("Usage: ./print-fetch {printerSocket} {remoteURL} {id} [startGcode] [endGCode]") return end @@ -35,6 +35,26 @@ local started = false log("total lines: " .. total_lines) +local startCode = '' +local endCode = '' + +function countlines(file) + return tonumber(io.popen("wc -l < " .. file):read('*a')) +end + +function readGCodeArg(argi) + local gcodeFile = arg[argi] + total_lines = total_lines + countlines(gcodeFile) + return io.open(gcodeFile):read('*a') +end + +if table.getn(arg) >= 5 then + startCode = readGCodeArg(4) + endCode = readGCodeArg(5) +end + +printer:appendGcode(startCode) + while(not finished) do local f = io.popen("wget -qO - " .. remote .. "/fetch/" .. id .. "/" .. current_line) @@ -45,6 +65,7 @@ do line = f:read() end if current_line >= total_lines then + printer:appendGcode(endCode) finished = true break end From 5607ab96adec77965f6581680556c328a01e4dda Mon Sep 17 00:00:00 2001 From: Simon Voordouw Date: Mon, 12 Jun 2017 17:21:09 +0200 Subject: [PATCH 09/19] 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 From fbb536f4ad37e18327b0a547ad35ec1771b96a98 Mon Sep 17 00:00:00 2001 From: Simon Voordouw Date: Tue, 13 Jun 2017 11:10:50 +0200 Subject: [PATCH 10/19] use correct lua not equal --- src/rest/api/api_printer.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rest/api/api_printer.lua b/src/rest/api/api_printer.lua index 1463ab9..f328dd1 100644 --- a/src/rest/api/api_printer.lua +++ b/src/rest/api/api_printer.lua @@ -218,13 +218,13 @@ function M.fetch_POST(request, response) local gcodeFiles = " " local startCode = request:get("start_code") - if startCode != nil then + if not startCode then gcodeFiles = gcodeFiles .. '/tmp/startcode ' io.open('/tmp/startcode', 'w+').write(startCode) end local endCode = request:get("end_code") - if endCode != nil then + if not endCode then gcodeFiles = gcodeFiles .. '/tmp/endcode ' io.open('/tmp/endcode', 'w+').write(endCode) end From 211c2f1abbc396062578d543978a04c20189c0c8 Mon Sep 17 00:00:00 2001 From: Simon Voordouw Date: Tue, 13 Jun 2017 11:47:16 +0200 Subject: [PATCH 11/19] copy print-fetch script to install dir --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 98ef1fb..d13b89a 100644 --- a/Makefile +++ b/Makefile @@ -126,6 +126,8 @@ define Package/wifibox/install $(INSTALL_BIN) $(WIFIBOX_BASE_DIR)/script/signin.sh $(1)/$(TGT_LUA_DIR_SUFFIX)/script $(CP) $(WIFIBOX_BASE_DIR)/script/logrotate-wifibox.conf $(1)/etc/logrotate.d/wifibox.conf + + $(INSTALL_BIN) $(WIFIBOX_BASE_DIR)/script/print-fetch.lua $(1)/$(TGT_LUA_DIR_SUFFIX)/script $(LN) -s /$(TGT_LUA_DIR_SUFFIX)/script/print-fetch.lua $(1)/bin/print-fetch $(CP) $(WIFIBOX_BASE_DIR)/script/wifibox.uci.config $(1)/etc/config/wifibox # copy base configuration to uci config dir From 533988a40962d58393c0194e3a91171296578a07 Mon Sep 17 00:00:00 2001 From: Simon Voordouw Date: Tue, 13 Jun 2017 12:30:47 +0200 Subject: [PATCH 12/19] add gcode_server to default settings --- src/conf_defaults.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/conf_defaults.lua b/src/conf_defaults.lua index b439ad9..b95a4d0 100644 --- a/src/conf_defaults.lua +++ b/src/conf_defaults.lua @@ -418,4 +418,10 @@ M.doodle3d_update_baseUrl = { description = '' } +M.doodle3d_gcode_server = { + default = 'https://tranquil-meadow-94621.herokuapp.com/', + type = 'string', + description ='' +} + return M From 97fb6609ea9f21c2624aee213789036ff39efb19 Mon Sep 17 00:00:00 2001 From: Simon Voordouw Date: Tue, 13 Jun 2017 13:04:09 +0200 Subject: [PATCH 13/19] call print start before finishing fetch loop --- src/script/print-fetch.lua | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/script/print-fetch.lua b/src/script/print-fetch.lua index 5d4d7d3..7d422cf 100755 --- a/src/script/print-fetch.lua +++ b/src/script/print-fetch.lua @@ -1,7 +1,7 @@ #!/usr/bin/lua local function log(message) - os.execute("logger" .. message) + os.execute("logger " .. message) print(message) end @@ -35,8 +35,8 @@ local started = false log("total lines: " .. total_lines) -local startCode = '' -local endCode = '' +local startCode = nil +local endCode = nil function countlines(file) return tonumber(io.popen("wc -l < " .. file):read('*a')) @@ -53,7 +53,10 @@ if table.getn(arg) >= 5 then endCode = readGCodeArg(5) end -printer:appendGcode(startCode) +if startCode ~= nil then + log("appending start gcode") + printer:appendGcode(startCode) +end while(not finished) do @@ -64,11 +67,6 @@ do current_line = current_line + 1 line = f:read() end - if current_line >= total_lines then - printer:appendGcode(endCode) - finished = true - break - end if not started then started = true @@ -76,6 +74,17 @@ do printer:startPrint() end + if current_line >= total_lines then + log("finished fetching gcode") + if endCode ~= nil then + log("appending end gcode") + printer:appendGcode(endCode) + end + finished = true + break + end + + local accepts_new_gcode = false while (not accepts_new_gcode) From 0d955b48eab7957e1af336cf69ef516cb0694806 Mon Sep 17 00:00:00 2001 From: Simon Voordouw Date: Tue, 13 Jun 2017 13:06:32 +0200 Subject: [PATCH 14/19] WiFi-box can't handle https --- src/conf_defaults.lua | 4 ++-- src/rest/api/api_printer.lua | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/conf_defaults.lua b/src/conf_defaults.lua index b95a4d0..c28d50a 100644 --- a/src/conf_defaults.lua +++ b/src/conf_defaults.lua @@ -418,8 +418,8 @@ M.doodle3d_update_baseUrl = { description = '' } -M.doodle3d_gcode_server = { - default = 'https://tranquil-meadow-94621.herokuapp.com/', +M.gcode_server = { + default = 'http://tranquil-meadow-94621.herokuapp.com/', type = 'string', description ='' } diff --git a/src/rest/api/api_printer.lua b/src/rest/api/api_printer.lua index f328dd1..b70bfb3 100644 --- a/src/rest/api/api_printer.lua +++ b/src/rest/api/api_printer.lua @@ -230,7 +230,7 @@ function M.fetch_POST(request, response) end local socket = printer:getId() - local remote = settings.get('gcode_server') + local remote = settings.get('gcode.server') local id = request:get("id") io.popen("print-fetch " .. socket .. " " .. remote .. " " .. id .. gcodeFiles) response:setSuccess() From aec8343bc02274f04b33b73971273dfb1f4ee598 Mon Sep 17 00:00:00 2001 From: Simon Voordouw Date: Tue, 13 Jun 2017 13:21:22 +0200 Subject: [PATCH 15/19] add more error handling --- src/rest/api/api_printer.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/rest/api/api_printer.lua b/src/rest/api/api_printer.lua index b70bfb3..5bf04bc 100644 --- a/src/rest/api/api_printer.lua +++ b/src/rest/api/api_printer.lua @@ -218,20 +218,32 @@ function M.fetch_POST(request, response) local gcodeFiles = " " local startCode = request:get("start_code") - if not startCode then + if startCode ~= nil then gcodeFiles = gcodeFiles .. '/tmp/startcode ' io.open('/tmp/startcode', 'w+').write(startCode) end local endCode = request:get("end_code") - if not endCode then + if endCode ~= nil then gcodeFiles = gcodeFiles .. '/tmp/endcode ' io.open('/tmp/endcode', 'w+').write(endCode) end local socket = printer:getId() + if socket == nil then + response:setError("no socket found") + return + end local remote = settings.get('gcode.server') + if remote == nil then + response:setError("no gcode server configured") + return + end local id = request:get("id") + if id == nil then + response:setError("no id supplied") + return + end io.popen("print-fetch " .. socket .. " " .. remote .. " " .. id .. gcodeFiles) response:setSuccess() end From 6b4e4e934cd2673f1b54ba225c2c4cb6dbf6ddde Mon Sep 17 00:00:00 2001 From: Simon Voordouw Date: Tue, 13 Jun 2017 14:40:20 +0200 Subject: [PATCH 16/19] remove total lines --- src/script/print-fetch.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/script/print-fetch.lua b/src/script/print-fetch.lua index 7d422cf..33f3d46 100755 --- a/src/script/print-fetch.lua +++ b/src/script/print-fetch.lua @@ -18,6 +18,10 @@ JSON = (loadfile "/usr/share/lua/wifibox/util/JSON.lua")() local p3d = require("print3d") local printer = p3d.getPrinter(arg[1]) +if printer == nil then + log("error connecting to printer") + return +end local remote = arg[2] @@ -26,6 +30,7 @@ local finished = false local id = arg[3] log("gcode file id: " .. id) +log("gcode server: " .. remote) local info = JSON:decode(io.popen("wget -qO - " .. remote .. "/info/" .. id):read("*a")) @@ -63,7 +68,7 @@ do local f = io.popen("wget -qO - " .. remote .. "/fetch/" .. id .. "/" .. current_line) local line = f:read() while line ~= nil do - printer:appendGcode(line, total_lines) + printer:appendGcode(line) current_line = current_line + 1 line = f:read() end From f2e77d95294c19bd6c9332140ad278351cb69e7b Mon Sep 17 00:00:00 2001 From: Simon Voordouw Date: Mon, 19 Jun 2017 11:28:39 +0200 Subject: [PATCH 17/19] submit total lines when fetching print --- src/script/print-fetch.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/print-fetch.lua b/src/script/print-fetch.lua index 33f3d46..00dde39 100755 --- a/src/script/print-fetch.lua +++ b/src/script/print-fetch.lua @@ -68,7 +68,7 @@ do local f = io.popen("wget -qO - " .. remote .. "/fetch/" .. id .. "/" .. current_line) local line = f:read() while line ~= nil do - printer:appendGcode(line) + printer:appendGcode(line, total_lines, { seq_number = -1, seq_total = -1, source = remote }) current_line = current_line + 1 line = f:read() end From 1676ca57036e1f0cbc3d03f73a4c2e8e6a202308 Mon Sep 17 00:00:00 2001 From: Simon Voordouw Date: Mon, 19 Jun 2017 13:20:13 +0200 Subject: [PATCH 18/19] use gcode id as source --- src/script/print-fetch.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/print-fetch.lua b/src/script/print-fetch.lua index 00dde39..5ca7329 100755 --- a/src/script/print-fetch.lua +++ b/src/script/print-fetch.lua @@ -68,7 +68,7 @@ do local f = io.popen("wget -qO - " .. remote .. "/fetch/" .. id .. "/" .. current_line) local line = f:read() while line ~= nil do - printer:appendGcode(line, total_lines, { seq_number = -1, seq_total = -1, source = remote }) + printer:appendGcode(line, total_lines, { seq_number = -1, seq_total = -1, source = id }) current_line = current_line + 1 line = f:read() end From 3fe6ff3bfec5eac409aaceaeb0089c9f5a6e628c Mon Sep 17 00:00:00 2001 From: Simon Voordouw Date: Mon, 19 Jun 2017 14:17:19 +0200 Subject: [PATCH 19/19] change default gcode server to gcodeserver.doodle3d.com --- src/conf_defaults.lua | 2 +- src/script/wifibox.uci.config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/conf_defaults.lua b/src/conf_defaults.lua index c28d50a..0214fae 100644 --- a/src/conf_defaults.lua +++ b/src/conf_defaults.lua @@ -419,7 +419,7 @@ M.doodle3d_update_baseUrl = { } M.gcode_server = { - default = 'http://tranquil-meadow-94621.herokuapp.com/', + default = 'http://gcodeserver.doodle3d.com', type = 'string', description ='' } diff --git a/src/script/wifibox.uci.config b/src/script/wifibox.uci.config index e2f8fe1..98e444d 100644 --- a/src/script/wifibox.uci.config +++ b/src/script/wifibox.uci.config @@ -10,4 +10,4 @@ config settings 'system' config settings 'general' option printer_type 'ultimaker' - option gcode_server 'tranquil-meadow-94621.herokuapp.com' + option gcode_server 'http://gcodeserver.doodle3d.com'