直接使用nvm库即可
无线模块设计了一个计数器,用于记录启动次数,放在 count.dat 文件中。
count.dat ASCII编码的纯文本文件,默认值一个字节:0
Air202/Air720SL-NP 读取:
startCountor = file:read("*n") --读取返回 nil
startCountor = tonumber(file:read("*l")) --读取正常
Air202写入:
file:write(startCountor) --写入正常
Air720SL-NP写入:
file:write(startCountor) --有写入错误,提示:desc=Exception - Branch to 0x0 detected
file:write(tostring(startCountor)) --无错误提示,但写不成功,内容没变
--2G Air202 模块启动次数计数 local startCountor = 0 local function StartCount() local file = io.open("/ldata/count.dat", "r") --startCountor = file:read("*n") --file:read("n") 2G模块读取返回 nil startCountor = tonumber(file:read("*l")) --这样读取就没问题了 file:close() if startCountor == nil then startCountor = 0 end if startCountor >= 2147483647 then --最大的32位有符号整形数字:2147483647 = 0x7FFF FFFF startCountor = 0 end file = io.open("/ldata/count.dat", "w") startCountor = startCountor + 1 file:write(startCountor) file:close() end
--4G Air720SL-NP 模块启动次数计数 local startCountor = 0 local function StartCount() local file = io.open("/lua/count.dat", "r") --startCountor = file:read("*n") --file:read("n") 4G模块读取返回 nil startCountor = tonumber(file:read("*l")) --这样读取就没问题了 file:close() if startCountor == nil then startCountor = 0 end if startCountor >= 2147483647 then --最大的32位有符号整形数字:2147483647 = 0x7FFF FFFF startCountor = 0 end file = io.open("/lua/count.dat", "w") startCountor = startCountor + 1 --file:write(startCountor) --file:write(startCountor) 4G 模块写错误提示:desc=Exception - Branch to 0x0 detected file:write(tostring(startCountor)) --无错误提示,但写不成功,内容没变 file:close() end