from machine import Pin, I2C, UART
import utime
from ustruct import unpack
import time
checkCardCmd = bytes([0xff,0x00,0x01,0x83,0x84])
getFirmwareVersionCmd = bytes([0xff,0x00,0x01,0x81,0x82])
uart = UART(1, baudrate=19200, bits=8, parity=None, stop=1)
while True:
# Check if card is present
uart.write(checkCardCmd)
val = uart.read()
print(val)
utime.sleep_ms(250)
当卡片出现在 NFC 读卡器上时,我会从val
b'\xff\x00\x06\x83\x02\x01#Eg['
这是对 的回复checkCardCmd
。我不知道为什么它以#Eg[
未找到卡的回复结束,因为b'\xff\x00\x02\x83N\xd3'
请注意N
第 4 个字节上的字符,应该是x83
.
波特率是正确的,并且在 NodeJS 中使用类似的代码,我可以从 UART 获得正确的响应,而无需额外N
或#Eg]
我在这里想念什么?