|
本帖最后由 zncs520 于 2013-8-13 16:25 编辑
写了一个WEB控制端。不知道 请教 大灯开关的lua 如何写?
这是我的原LUA 我用USBTTL线所以是io.output("/dev/ttyUSB0")
- #!/usr/bin/lua
- io.output("/dev/ttyUSB0")
- action = {
- ["C0"] = function (x) io.write(string.char(0xff,0x00,x,0x00,0xff)) end,
- ["C1"] = function (x) io.write(string.char(0xff,0x01,0x01,x,0xff)) end,
- ["C2"] = function (x) io.write(string.char(0xff,0x01,0x02,x,0xff)) end,
- ["C3"] = function (x) io.write(string.char(0xff,0x01,0x03,x,0xff)) end,
- ["C4"] = function (x) io.write(string.char(0xff,0x01,0x04,x,0xff)) end,
- ["C5"] = function (x) io.write(string.char(0xff,0x01,0x05,x,0xff)) end,
- ["C6"] = function (x) io.write(string.char(0xff,0x01,0x06,x,0xff)) end,
- ["C7"] = function (x) io.write(string.char(0xff,0x01,0x07,x,0xff)) end,
- ["C8"] = function (x) io.write(string.char(0xff,0x01,0x08,x,0xff)) end,
- }
- action[string.sub(os.getenv("QUERY_STRING"),1,2)](string.sub(os.getenv("QUERY_STRING"),3,5))
复制代码
|
|