0
0
mirror of https://github.com/Doodle3D/doodle3d-firmware.git synced 2024-12-22 19:13:49 +01:00

add options to pass start and end-gcode to print-fetch

This commit is contained in:
Simon Voordouw 2017-06-12 17:20:29 +02:00
parent 9c6bd6cdea
commit b2590e4142

View File

@ -6,7 +6,7 @@ local function log(message)
end end
if (table.getn(arg) == 0) then if (table.getn(arg) == 0) then
print("Usage: ./print-fetch {printerSocket} {remoteURL} {id}") print("Usage: ./print-fetch {printerSocket} {remoteURL} {id} [startGcode] [endGCode]")
return return
end end
@ -35,6 +35,26 @@ local started = false
log("total lines: " .. total_lines) 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) while(not finished)
do do
local f = io.popen("wget -qO - " .. remote .. "/fetch/" .. id .. "/" .. current_line) local f = io.popen("wget -qO - " .. remote .. "/fetch/" .. id .. "/" .. current_line)
@ -45,6 +65,7 @@ do
line = f:read() line = f:read()
end end
if current_line >= total_lines then if current_line >= total_lines then
printer:appendGcode(endCode)
finished = true finished = true
break break
end end