python3 发送串行数据到 Nextion Display

标签 python python-3.x serial-port pyserial

我正在尝试通过 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/

相关文章:

python - 默认情况下 __eq__() 方法里面有什么

java - ASCII 中的六个不同的 '?' 字符?

python - PyQt - 从 URL 设置 QLabel 图像

Python:将列表项替换为字符串的有效方法

python - 在变换之间保持恒定的线宽

linux - GDB 窗口中的远程终端

c - 如何在 Linux 中使用 C 通过串行端口连接发送 .gif 文件

python - 使用 Anaconda Python 的 PyQt Windows 安装程序——未找到 PyQt4;我该如何排除故障?

python - 关于修改python列表的初学者问题

python-3.x - 如何在 Python 3.6 中使用 LXML find() 用变量替换谓词值