我遇到了与这个问题相同的问题,只是定义了uart.STOPBITS_1,而没有定义parity_NONE:
nodemcu uart undefined constants?
>
uart=require("uart")
>
=uart
table: 0x4028d530
>
=print(uart.parity_NONE)
nil
>
=uart.STOPBITS_1
1
> 当前固件
NodeMCU 3.0.0.0 built on nodemcu-build.com provided by frightanic.com
branch: release
commit: 136e09739b835d6dcdf04034141d70ab755468c6
release: 3.0.0-release_20210201
release DTS: 202102010145
SSL: true
build type: float
LFS: 0x0 bytes total capacity
modules: adc,bit,file,gpio,net,node,tmr,uart,wifi,tls
build 2021-03-17 08:20 powered by Lua 5.1.4 on SDK 3.0.1-dev(fce080e)测试代码:
uart=require("uart")
print(uart.STOPBITS_1)
print(uart.parity_NONE)
uart.setup(0, 19200, 8, uart.parity_NONE, uart.STOPBITS_1, 0)错误: stdin:1:'setup‘的参数#4不正确(需要编号,但得到的值为空)
发布于 2021-03-22 16:27:33
问题解决了,奇偶校验区分大小写,所以应该是:
uart.PARITY_NONE
https://stackoverflow.com/questions/66740772
复制相似问题