当前位置:网站首页>[luat-air105] 4.1 file system FS
[luat-air105] 4.1 file system FS
2022-07-05 03:27:00 【Birds hate fish】
1 Preface
Try to air105 Create files under the root directory of and read and write
2 Code
t4_fs_info.lua
function get_fs_info()
log.info("fsize", fs.fsize("/luadb/main.luac"))
log.info("fsstat", fs.fsstat(""))
log.info("fsstat", fs.fsstat("/luadb/")) -- Be careful not to use "/luadb", To add a slash
end
-- Record startup times
function fs_test()
f = io.open("/boot_time", "rb")
c = 0
if f then
data = f:read("*a")
log.info("fs", "data", data, data:toHex())
c = tonumber(data)
f:close()
end
log.info("fs", "boot count", c)
c = c + 1
f = io.open("/boot_time", "wb")
--if f ~= nil then
log.info("fs", "write c to file", c, tostring(c))
f:write(tostring(c))
f:close()
--end
if fs then
log.info("fsstat", fs.fsstat(""))
end
end
function t4_fs_root_write()
print("init")
-- f = io.mkfs("youkai")
f = io.open("/youkai", "wb")
print(type(f))
--if f ~= nil then
c = "hi,langzhao"
log.info("fs", "write c to file", c)
f:write(tostring(c))
f:close()
f = io.open("/youkai", "r")
if f then
data = f:read("*a") -- *a Said file ,l Said line
-- https://gitee.com/openLuat/LuatOS/blob/master/lua/src/loslib.c g_read()
print("file data : ",data)
f:close()
end
-- air 105 root directory "" You can create files and read and write
end
-- LuaTools need PROJECT and VERSION These two messages
PROJECT = "fsdemo"
VERSION = "1.0.0"
log.info("main", PROJECT, VERSION)
-- sys The library is standard
_G.sys = require("sys")
require("t4_fs_info")
-- Add a hard dog to prevent the program from getting stuck
wdt.init(15000)-- initialization watchdog Set to 15s
sys.timerLoopStart(wdt.feed, 10000)--10s Feed the dog once
get_fs_info()
sys.taskInit(function()
-- Every time you turn it on , Record the value +1
fs_test()
t4_fs_root_write()
while 1 do
sys.wait(500)
end
end)
-- User code ended ---------------------------------------------
-- The end is always this sentence
sys.run()
-- sys.run() Don't add any statements after !!!!!
3 result
边栏推荐
- Yyds dry goods inventory intelligent fan based on CC2530 design
- Sqoop安装
- Sqoop命令
- Linux安装Redis
- Delphi read / write JSON format
- This + closure + scope interview question
- Azkaban概述
- Azkaban安装部署
- The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
- About MySQL database connection exceptions
猜你喜欢
The latest blind box mall, which has been repaired very popular these days, has complete open source operation source code
Three line by line explanations of the source code of anchor free series network yolox (a total of ten articles, which are guaranteed to be explained line by line. After reading it, you can change the
qrcode:将文本生成二维码
Easy processing of ten-year futures and stock market data -- Application of tdengine in Tongxinyuan fund
Asemi rectifier bridge 2w10 parameters, 2w10 specifications, 2w10 characteristics
Why do some programmers change careers before they are 30?
Linux安装Redis
Flume配置4——自定义MYSQLSource
[system security] ten thousand words summary system virtualization container bottom layer principle experiment
College Students' innovation project management system
随机推荐
Watch the online press conference of tdengine community heroes and listen to TD hero talk about the legend of developers
Kubernetes -- cluster expansion principle
Three line by line explanations of the source code of anchor free series network yolox (a total of ten articles, which are guaranteed to be explained line by line. After reading it, you can change the
FBO and RBO disappeared in webgpu
[Yu Yue education] National Open University autumn 2018 8109-22t (1) monetary and banking reference questions
Share the newly released web application development framework based on blazor Technology
Pat class a 1162 postfix expression
Simple use of devtools
腾讯云,实现图片上传
Tiny series rendering tutorial
Qrcode: generate QR code from text
[groovy] string (string splicing | multi line string)
040. (2.9) relieved
Design and implementation of community hospital information system
SPI and IIC communication protocol
Ubantu disk expansion (VMware)
Zabbix
Usage scenarios and solutions of ledger sharing
Devtools的简单使用
GFS distributed file system