问题描述
我遇到了与此问题中发布的相同的问题,除了 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(预期的数字,没有)
解决方法
问题已解决,奇偶校验区分大小写,所以应该是:
install.packages("utf8")