我正在尝试通过 Python3 脚本控制 Nextion Display。
使用 Windows 终端我可以控制它。
例如,要更改控件的文本,我发送以下内容:
t0.txt="test"通过“发送十六进制”跟随 3 次 0xFF
我使用 PySerial 的 Python3 脚本如下:
import serial
s = serial.Serial(port='COM5',baudrate=9600)
escape='\xff'.encode('iso-8859-1')
test=b't0.txt="test"'
s.write(test)
s.write(escape)
s.write(escape)
s.write(escape)
s.close()
但它不起作用。
有什么想法吗?
非常感谢
最佳答案
从 gpiopins 上的树莓派 pi3 上的 nextion EEPROM 读取字节。
#import time
import serial
ser = serial.Serial(
port='/dev/ttyS0',
baudrate =9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1)
commandToSend = b'rept 0,32\xff\xff\xff' #read 32 bytes of hex data from EEPROM to UART, start address is 0
while True:
ser.write(commandToSend)
#time.sleep(0.5)
x=ser.readline()
print (x)
关于python3 发送串行数据到 Nextion Display,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35454378/