nextion.py on 4.2.0 and 4.3.0

General support for the Pi-Star System
Post Reply
VE3RD
Posts: 113
Joined: Thu Oct 11, 2018 7:21 pm

nextion.py on 4.2.0 and 4.3.0

Post 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
User avatar
MW0MWZ
Site Admin
Posts: 1505
Joined: Wed Apr 04, 2018 9:15 pm
Location: Wales, UK
Contact:

Re: 4.2.0 Beta feedback

Post 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.
Andy

73 de MW0MWZ
http://pistar.uk
User avatar
MW0MWZ
Site Admin
Posts: 1505
Joined: Wed Apr 04, 2018 9:15 pm
Location: Wales, UK
Contact:

Re: 4.2.0 Beta feedback

Post 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
Andy

73 de MW0MWZ
http://pistar.uk
Post Reply