0
0
mirror of https://github.com/Doodle3D/doodle3d-firmware.git synced 2024-12-22 11:03:48 +01:00

Merge branch 'master' into printerdriver

Conflicts:
	src/conf_defaults.lua
This commit is contained in:
Wouter R 2013-09-25 12:06:28 +02:00
commit ba47733dad
7 changed files with 220 additions and 104 deletions

View File

@ -14,12 +14,13 @@
WIFIBOX_IP=192.168.5.1
#WIFIBOX_IP=192.168.10.1
API_BASE=$WIFIBOX_IP/d3dapi
#API_BASE=$WIFIBOX_IP/d3dapi
API_BASE=$WIFIBOX_IP/cgi-bin/d3dapi
WGET=wget
#REQUEST_PATH=network/status
REQUEST_PATH=printer/print
#POST_PARMS=--post-data=xyzzy
POST_PARMS=--post-file=lorem.txt
POST_PARMS=--post-file=200k.gcode
RETRIES=1

View File

@ -29,9 +29,9 @@ M.API_INCLUDE_ENDPOINT_INFO = false
M.API_BASE_URL_PATH = 'doodle3d.com' -- includes any base path if necessary (e.g. 'localhost/~user')
M.network_ap_ssid = {
default = 'd3d-ap-%%MAC_ADDR_TAIL%%',
default = 'Doodle3D-%%MAC_ADDR_TAIL%%',
type = 'string',
description = 'Access Point mode SSID',
description = 'Access Point mode SSID (name)',
min = 1,
max = 32
}
@ -124,10 +124,10 @@ M.printer_firstLayerSlow = {
description = 'Print the first layer slowly to get a more stable start'
}
M.printer_autoWarmUp = {
default = true,
type = 'bool',
description = '',
M.printer_heatupTemperature = {
default = 180,
type = 'int',
description = ''
}
M.printer_retraction_enabled = {
@ -157,31 +157,43 @@ M.printer_retraction_amount = {
min = 0
}
M.printer_heatupTemperature = {
default = 180,
type = 'int',
M.printer_enableTraveling = {
default = false,
type = 'bool',
description = ''
}
M.printer_autoWarmUpCommand = {
default = 'M104 S180',
type = 'string',
description = ''
}
M.printer_startgcode = {
default = ';Generated with Doodle3D\nG21 ;metric values\nG91 ;relative positioning\nM107 ;start with the fan off\nG28 X0 Y0 ;move X/Y to min endstops\nG28 Z0 ;move Z to min endstops\nG1 Z15 F9000 ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E10 ;extrude 10mm of feed stock\nG92 E0 ;zero the extruded length again\nG92 X-100 Y-100 E0 ;zero the extruded length again and make center the start position\nG1 F9000\nG90 ;absolute positioning\nM117 Printing Doodle... ;display message (20 characters to clear whole screen)',
default = ';Generated with Doodle3D\nG21 ;metric values\nG91 ;relative positioning\nM107 ;start with the fan off\nG28 X0 Y0 ;move X/Y to min endstops\nG28 Z0 ;move Z to min endstops\nG1 Z15 F9000 ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E10 ;extrude 10mm of feed stock\nG92 E0 ;zero the extruded length again\nG92 E0 ;zero the extruded length again\nG1 F9000\nG90 ;absolute positioning\nM117 Printing Doodle... ;display message (20 characters to clear whole screen)',
type = 'string',
description = ''
}
M.printer_endgcode = {
default = 'M107 ;fan off\nG91 ;relative positioning\nG1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 Z+0.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more\nG28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way\nM84 ;disable axes / steppers\nG90 ;absolute positioning\nM117 Done ;display message (20 characters to clear whole screen)',
default = 'M107 ;fan off\nG91 ;relative positioning\nG1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 Z+0.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more\nG28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way\nM84 ;disable axes / steppers\nG90 ;absolute positioning\nM104 S180\nM117 Done ;display message (20 characters to clear whole screen)',
type = 'string',
description = ''
}
M.doodle3d_objectHeight = {
default = 20,
M.printer_maxObjectHeight = {
default = 150,
type = 'int',
description = 'Maximum height that will be printed',
min = 0
}
M.printer_screenToMillimeterScale = {
default = 0.3,
type = 'float',
description = '',
}
M.doodle3d_simplify_minDistance = {
default = 3,
type = 'int',

View File

@ -23,7 +23,7 @@ M.resolutionError = nil --non-nil means function could not be resolved
local function kvTableFromUrlEncodedString(encodedText)
local args = {}
if (encodedText ~= nil) then
urlcode.parsequery(encodedText, args)
urlcode.parsequeryNoRegex(encodedText, args)
end
return args

70
src/test/test_urlcode.lua Normal file
View File

@ -0,0 +1,70 @@
-- TODO: also test malformed query strings
local urlcode = require("util.urlcode")
local M = {
_is_test = true,
_skip = {},
_wifibox_only = {}
}
-- NOTE: the previous approach using #t1 and #t2 was too naive and only worked for tables with contiguous ranges of numeric keys.
local function compareTables(t1, t2)
local len = 0
for k1,v1 in pairs(t1) do
len = len + 1
if t2[k1] ~= v1 then return false end
end
for _ in pairs(t2) do len = len - 1 end
return len == 0 and true or false
end
local queryTexts = {
[1] = "k1=v1&k2=v2x&k3yy=v3",
[2] = "k1=v1&k2=v2x&k3yy=v3&",
[3] = "k1=v1&k2=v2x&k3yy=v3&=",
[4] = "k1=v1&k2=v2x&k3yy=v3& =",
[5] = ""
}
local queryTables = {
[1] = { ["k1"] = "v1", ["k2"] = "v2x", ["k3yy"] = "v3" },
[2] = { ["k1"] = "v1", ["k2"] = "v2x", ["k3yy"] = "v3" },
[3] = { ["k1"] = "v1", ["k2"] = "v2x", ["k3yy"] = "v3" },
[4] = { ["k1"] = "v1", ["k2"] = "v2x", ["k3yy"] = "v3", [" "] = "" },
[5] = {}
}
function M:_setup()
local longValue = ""
for i=1,5000 do
longValue = longValue .. i .. ": abcdefghijklmnopqrstuvwxyz\n"
end
table.insert(queryTexts, "shortkey=&longkey=" .. longValue)
table.insert(queryTables, { ["shortkey"] = "", ["longkey"] = longValue })
end
function M:_teardown()
end
function M:test_parsequery()
for i=1,#queryTexts do
local args = {}
urlcode.parsequery(queryTexts[i], args)
assert(compareTables(queryTables[i], args))
end
end
function M:test_parsequeryNoRegex()
for i=1,#queryTexts do
local args = {}
urlcode.parsequeryNoRegex(queryTexts[i], args)
assert(compareTables(queryTables[i], args))
end
end
return M

View File

@ -87,6 +87,39 @@ end)
end
end
----------------------------------------------------------------------------
-- Parse url-encoded request data without using regular expressions
-- (the query part of the script URL or url-encoded post data)
--
-- Each decoded (name=value) pair is inserted into table [[args]]
-- @param query String to be parsed.
-- @param args Table where to store the pairs.
----------------------------------------------------------------------------
function _M.parsequeryNoRegex (query, args)
if type(query) == "string" then
local insertfield, unescape = _M.insertfield, _M.unescape
local k = 1
while true do
local v = query:find('=', k+1, true) -- look for '=', assuming a key of at least 1 character and do not perform pattern matching
if not v then break end -- no k/v pairs left
local key = query:sub(k, v-1)
v = v + 1
local ampersand = query:find('&', v, true)
if not ampersand then ampersand = 0 end -- 0 will become -1 in the substring call below...meaning end of string
local value = query:sub(v, ampersand - 1)
insertfield (args, unescape(key), unescape(value))
if ampersand == 0 then break end -- we couldn't find any ampersands anymore so this was the last k/v
k = ampersand + 1
end
end
end
----------------------------------------------------------------------------
-- URL-encode the elements of a table creating a string to be used in a
-- URL for passing data/parameters to another script

@ -1 +1 @@
Subproject commit a57a36f420bb6ed4e1ded56a2b65ac2cb6385c87
Subproject commit 1842ec01b2d455142b8f654323ec92a4e2395753