代码拉取完成,页面将自动刷新
PROJECT = "uartdemo"
VERSION = "1.0.0"
-- 一定要添加sys.lua !!!!
local sys = require "sys"
local uartid = 1
sys.taskInit(
function()
local result =
uart.setup(
uartid,
--串口id
115200,
--波特率
8,
--数据位
1
--停止位
)
log.info("uart-setup", result)
uart.write(uartid, "hello esp32\n")
uart.on(
uartid,
"receive",
function(id, len)
local s = ""
s = uart.read(id, len)
log.info("uart", id, len)
if #s > 0 then -- #s 是取字符串的长度
log.info("uart", "receive", id, #s, s)
end
end
)
end
)
-- 用户代码已结束---------------------------------------------
-- 结尾总是这一句
sys.run()
-- sys.run()之后后面不要加任何语句!!!!!
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。