--if not _REQUIREDNAME then -- error('Don\'t load directly, use require "rs232"', 2) -- end -- Get libname. local libname = os.getenv "LUA_SOPATH" if libname then if not string.find(libname, '/$') then libname = libname .. "/" end else libname = "/usr/local/lib/lua/5.1/" end libname = libname.."rs232.so" local funcname = "luaopen_rs232" local f, err = package.loadlib(libname, funcname) if not f then error("loadlib('" .. libname .. "', '" .. funcname .. "') failed: " .. err, 2) end local function ret(s, ...) if s then return unpack(arg) end error("rs232" .. "'s " .. funcname .. " failed: " .. arg[1], 3) end return ret(pcall(f))