0
0
mirror of https://github.com/Doodle3D/doodle3d-firmware.git synced 2024-06-29 04:31:22 +02:00

Update info/logfiles API call to collect print3d logs instead of ultifi logs. Change printer/getProgress to return current, buffered and total gcode lines. Remove unused constants from printer api.

This commit is contained in:
Wouter R 2013-10-10 17:00:16 +02:00
parent 7060f864aa
commit 0e8a08594a
2 changed files with 41 additions and 49 deletions

View File

@ -11,9 +11,10 @@ local LOG_COLLECT_DIRNAME = 'wifibox-logs'
local LOG_COLLECT_DIR = TMP_DIR .. '/' .. LOG_COLLECT_DIRNAME
local WIFIBOX_LOG_FILENAME = 'wifibox.log'
local WIFIBOX_LOG_FILE = TMP_DIR .. '/' .. WIFIBOX_LOG_FILENAME
local ULTIFI_PATH = '/tmp/UltiFi'
local SYSLOG_FILENAME = 'syslog'
local ULTIFI_LOG_FILENAME = 'server.log'
local PRINT3D_BASEPATH = '/tmp'
local PRINT3D_LOG_FILENAME_PREFIX = 'print3d-'
local PRINT3D_LOG_FILENAME_SUFFIX = '.log'
local LOG_COLLECT_ARCHIVE_FILENAME = LOG_COLLECT_DIRNAME .. '.tgz'
local LOG_COLLECT_ARCHIVE_FILE = TMP_DIR .. '/' .. LOG_COLLECT_ARCHIVE_FILENAME
@ -43,8 +44,6 @@ function M.logfiles(request, response)
local rv,msg = lfs.mkdir(LOG_COLLECT_DIR)
local rv,msg = lfs.chdir(TMP_DIR)
local ultip,msg = lfs.attributes(ULTIFI_PATH, 'mode')
--[[ create temporary files ]]--
@ -52,13 +51,11 @@ function M.logfiles(request, response)
local rv,sig,code = os.execute('logread > ' .. LOG_COLLECT_DIR .. '/' .. SYSLOG_FILENAME)
if ultip and ultip == 'directory' then
for file in lfs.dir(ULTIFI_PATH) do
if file ~= '.' and file ~= '..' then
local srcLogFile = ULTIFI_PATH .. '/' .. file .. '/' .. ULTIFI_LOG_FILENAME
local tgtLogFile = LOG_COLLECT_DIR .. '/' .. file .. '-' .. ULTIFI_LOG_FILENAME
local rv,sig,code = redirectedExecute('cp ' .. srcLogFile .. ' ' .. tgtLogFile)
end
for file in lfs.dir(PRINT3D_BASEPATH) do
if file:find(PRINT3D_LOG_FILENAME_PREFIX) == 1 and file:find(PRINT3D_LOG_FILENAME_SUFFIX) ~= nil then
local srcLogFile = PRINT3D_BASEPATH .. '/' .. file
local tgtLogFile = LOG_COLLECT_DIR .. '/' .. file
local rv,sig,code = redirectedExecute('cp ' .. srcLogFile .. ' ' .. tgtLogFile)
end
end

View File

@ -11,12 +11,6 @@ local M = {
}
local ULTIFI_BASE_PATH = '/tmp/UltiFi'
local TEMPERATURE_FILE = 'temp.out'
local PROGRESS_FILE = 'progress2.out'
local COMMAND_FILE = 'command.in'
local GCODE_TMP_FILE = 'combined.gc'
function M._global(request, response)
-- TODO: list all printers (based on /dev/ttyACM* and /dev/ttyUSB*)
response:setSuccess()
@ -48,16 +42,17 @@ function M.progress(request, response)
local printer,msg = printerUtils.createPrinterOrFail(argId, response)
if not printer then return end
-- NOTE: despite their names, `currentLine` is still the error indicator and `numLines` the message in such case.
local currentLine,numLines = printer:getProgress()
-- NOTE: despite their names, `currentLine` is still the error indicator and `bufferedLines` the message in such case.
local currentLine,bufferedLines,totalLines = printer:getProgress()
response:addData('id', argId)
if currentLine then
response:setSuccess()
response:addData('current_line', currentLine)
response:addData('num_lines', numLines)
response:addData('buffered_lines', bufferedLines)
response:addData('total_lines', totalLines)
else
response:setError(numLines)
response:setError(bufferedLines)
end
end