From 5b710dbbcc241c4ad668f9a57b86a0ff51977199 Mon Sep 17 00:00:00 2001 From: Wouter R Date: Sat, 12 Oct 2013 23:18:47 +0200 Subject: [PATCH] Changes for extra fields in getProgress and rejecting too large chunks of gcode. --- src/rest/api/api_printer.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/rest/api/api_printer.lua b/src/rest/api/api_printer.lua index b4d085f..b1d7e24 100644 --- a/src/rest/api/api_printer.lua +++ b/src/rest/api/api_printer.lua @@ -44,7 +44,7 @@ function M.progress(request, response) if not printer then return false end -- NOTE: despite their names, `currentLine` is still the error indicator and `bufferedLines` the message in such case. - local currentLine,bufferedLines,totalLines = printer:getProgress() + local currentLine,bufferedLines,totalLines,bufferSize,bufferSizeMax = printer:getProgress() response:addData('id', argId) if currentLine then @@ -52,6 +52,8 @@ function M.progress(request, response) response:addData('current_line', currentLine) response:addData('buffered_lines', bufferedLines) response:addData('total_lines', totalLines) + response:addData('buffer_size', bufferSize) + response:addData('buffer_size_max', bufferSizeMax) else response:setError(bufferedLines) return false @@ -176,7 +178,10 @@ function M.print_POST(request, response) if rv then --NOTE: this does not report the number of lines, but only the block which has just been added response:addData('gcode_append',argGcode:len()) - else + elseif rv == false then + response:setFail("could not add gcode - not enough buffer space") + return + else -- this is an actual nil response:setError("could not add gcode") response:addData('msg', msg) return