Closed dannyrz closed 8 years ago
lua-periphery throws a table object on an error, which can be formatted into a string with tostring()
. Unfortunately, Lua 5.1 does not do this automatically (but LuaJIT, Lua 5.2, Lua 5.3 all do).
Try:
local serial, err = pcall(Serial, "/dev/ttyUSB0", 9600)
if not serial then
print(err)
os.exit()
end
Also see issue #4.
I'll add this to the documentation since it's come up a few times now.
local Serial = require('periphery').Serial if Serial==nil then print("load sdk periphery faild."); os.exit(); end local serial = Serial("/dev/ttyUSB0", 9600)
[Finished in 0.0s with exit code 1]/usr/local/bin/lua: (error object is not a string)