Autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et dolore feugait.
local WebService = {}
function WebService.Run()
local client = os.getenv("REMOTE_ADDR")
local GET = os.getenv("QUERY_STRING")
local POST = nil
local POSTLength = tonumber(os.getenv("CONTENT_LENGTH")) or 0
if (POSTLength > 0) then
POST = io.read(POSTLength)
--POST = io.read("*a")
end
-- Fast-CGI+HTTP require HEADER
-- enable cache
--io.write("Content-type: text/html\n\n")
-- disable cache, especially for Internet Explorer
io.write("Content-type: text/html\nPragma: no-cache\n\n")
local reply = string.format("Client %s said: url: [%s], data: [%s]\n", client or '-', GET or '-', POST or '-')
io.write(reply)
end
return WebService
function WebService.uartWrite(msg)
local uartConfig = 'stty -F /dev/ttyS0 raw speed 9600\n'
os.execute(uartConfig)
local cmd = string.format("echo '%s' > /dev/ttyS0\n", msg or '')
os.execute(cmd)
end