mirror of
https://github.com/Doodle3D/doodle3d-firmware.git
synced 2024-12-22 11:03:48 +01:00
check if file is opened
This commit is contained in:
parent
6729af7064
commit
9571af19ac
@ -64,8 +64,8 @@ function M.progress(request, response)
|
|||||||
|
|
||||||
|
|
||||||
response:addData('id', argId)
|
response:addData('id', argId)
|
||||||
if printid ~= nil then
|
if printId ~= nil then
|
||||||
response:addData('current_print', printid)
|
response:addData('current_print', printId)
|
||||||
end
|
end
|
||||||
if currentLine then
|
if currentLine then
|
||||||
response:setSuccess()
|
response:setSuccess()
|
||||||
@ -172,6 +172,8 @@ function M.stop_POST(request, response)
|
|||||||
local rv,msg = printer:stopPrint(argGcode)
|
local rv,msg = printer:stopPrint(argGcode)
|
||||||
|
|
||||||
io.popen("killall print-fetch")
|
io.popen("killall print-fetch")
|
||||||
|
io.popen("rm /tmp/current-print /tmp/startcode /tmp/endcode")
|
||||||
|
|
||||||
|
|
||||||
response:addData('id', argId)
|
response:addData('id', argId)
|
||||||
if rv then
|
if rv then
|
||||||
@ -238,13 +240,24 @@ function M.fetch_POST(request, response)
|
|||||||
local startCode = request:get("start_code")
|
local startCode = request:get("start_code")
|
||||||
if startCode ~= nil then
|
if startCode ~= nil then
|
||||||
gcodeFiles = gcodeFiles .. '/tmp/startcode '
|
gcodeFiles = gcodeFiles .. '/tmp/startcode '
|
||||||
io.open('/tmp/startcode', 'w+').write(startCode)
|
local startCodeFile = io.open('/tmp/startcode', 'w+')
|
||||||
|
if startCodeFile == nil then
|
||||||
|
response:setError("could not open startCode file for writing")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
startCodeFile:write(startCode)
|
||||||
end
|
end
|
||||||
|
|
||||||
local endCode = request:get("end_code")
|
local endCode = request:get("end_code")
|
||||||
if endCode ~= nil then
|
if endCode ~= nil then
|
||||||
gcodeFiles = gcodeFiles .. '/tmp/endcode '
|
gcodeFiles = gcodeFiles .. '/tmp/endcode '
|
||||||
io.open('/tmp/endcode', 'w+').write(endCode)
|
local endCodeFile = io.open('/tmp/endcode', 'w+')
|
||||||
|
if endCodeFile == nil then
|
||||||
|
response:setError("could not open endcode file for writing")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
endCodeFile:write(endCode)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local socket = printer:getId()
|
local socket = printer:getId()
|
||||||
@ -262,9 +275,16 @@ function M.fetch_POST(request, response)
|
|||||||
response:setError("no id supplied")
|
response:setError("no id supplied")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
local cpfile = io.open("/tmp/current-print", 'w+')
|
||||||
|
if cpfile == nil then
|
||||||
|
response:setError("could not save id")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
cpfile:write(id)
|
||||||
|
cpfile:close()
|
||||||
|
|
||||||
io.popen("print-fetch " .. socket .. " " .. gcodeServer .. " " .. id .. gcodeFiles)
|
io.popen("print-fetch " .. socket .. " " .. gcodeServer .. " " .. id .. gcodeFiles)
|
||||||
|
|
||||||
io.open("/tmp/current-print", 'w+').write(id)
|
|
||||||
response:setSuccess()
|
response:setSuccess()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user