Start a new topic

serial instructions Raspberry pi (python 2.7) to screen

I'm new to python and struggling with communicating with the screen.

I have set up the image ok and now trying to use the "vis" command to turn off "T0"

Is there any body who has a simple script I can build on to get me started sending instructions from the Pi 3 to the screen. 

Basic Python 

import serial
ser = serial.Serial ("/dev/ttyAMA0")    #Open named port 
ser.baudrate = 9600                     #Set baud rate to 9600
data =                     #Read ten characters from serial port to data
ser.write(data)                         #Send back the received data

Nextion Instruction Set:  vis command  2.10

So looks like Python to turn vis off for t0 should be

  ser.write("vis t0,0ÿÿÿ".encode())

import serial

ser = serial.Serial ('/dev/ttyUSB0') 

ser.baudrate = 115200

ser.write('vis t0,1\xFF\xFF\xFF')



Thanks for your help, the code above worked. Is that safe to use.

Do I need to flush the rx buffers before sending?


Safe? implies harm is the opposite result.  A good communication implementation has no need to flush buffers.  Flushing risks data loss, all bytes should have held some level of importance and once flushed are gone.  RX and TX are usually separate buffers, why flush the opposite one to use the first?

But your answer is in your documentation, for PI MCU chip, kernel, and Python libraries and your coding. All these in combination makes up what limitations and considerations need be made for a stable communications.  Your RX buffer should be exclusive to your process, I am sure what other accesses you gave for other processes to use your buffers in a shared manner.  So if exclusive buffers to your process, why would there be such a need to flush.

Login or Signup to post a comment