Page 1 of 1

nextion.py on 4.2.0 and 4.3.0

Posted: Fri Jan 26, 2024 10:12 pm
by VE3RD
I just installed the 4.2.0
DMRGateway(my version) working fine
Nextion 2,4" Screen(TGIFSpot) working Fine

The problem I ran into was a commandline python script to flash the nextion screen. (a new image can be flashed from the screen so this is no biggie)
There is a script called nextion.py that fails on the
"import serial" command, I found very little on the internet regarding this issue that works, One comment was to run
"pip install pyserial" == this does not work

Sample of nextion.py
import serial
import time
import sys
import os
import re

e = "\xff\xff\xff"

def getBaudrate(ser, fSize=None, checkModel=None):
for baudrate in (2400, 4800, 9600, 19200, 38400, 57600, 115200):
ser.baudrate = baudrate
ser.timeout = 3000 / baudrate + .2
print 'Trying with baudrate: ' + str(baudrate) + '...'
ser.write("\xff\xff\xff")
ser.write('connect')
ser.write("\xff\xff\xff")
r = ser.read(128)
if 'comok' in r:
print 'Connected with baudrate: ' + str(baudrate) + '...'
noConnect = False
status, unknown1, model, fwversion, mcucode, serial, flashSize = r.strip("\xff\x00").split(',')
print 'Status: ' + status.split(' ')[0]
if status.split(' ')[1] == "1":
print 'Touchscreen: yes'
else:
print 'Touchscreen: no'
print 'Model: ' + model
print 'Firmware version: ' + fwversion
print 'MCU code: ' + mcucode
print 'Serial: ' + serial
print 'Flash size: ' + flashSize

Re: 4.2.0 Beta feedback

Posted: Fri Jan 26, 2024 11:41 pm
by MW0MWZ
VE3RD wrote: Fri Jan 26, 2024 10:12 pm I just installed the 4.2.0
DMRGateway(my version) working fine
Nextion 2,4" Screen(TGIFSpot) working Fine

The problem I ran into was a commandline python script to flash the nextion screen. (a new image can be flashed from the screen so this is no biggie)
There is a script called nextion.py that fails on the
"import serial" command, I found very little on the internet regarding this issue that works, One comment was to run
"pip install pyserial" == this does not work
I spotted (yesterday I think) that python was a little broken, the image has 2.7 and 3.x installed, but the python symlink was missing.
That has been corrected (an update will put that in for you). That might well help.

I'll come back to you on import serial in a moment when I go test it.

Re: 4.2.0 Beta feedback

Posted: Sat Jan 27, 2024 12:05 am
by MW0MWZ
Well I expected that the modules would be there somewhere, and they really are not - looks like it is finally time to migrate any python scripts to python3