Python Forum
serial write can't do it myself
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
serial write can't do it myself
#1
hello I'm having a lot of difficult to connect to serial port

I've a device that communicates by serial (Nextion HMI) with my raspberry pi via UART

I have this python file to read the port that works

serial_read.py
import serial

ser = serial.Serial(

    port='/dev/ttyAMA0',
    baudrate=9600,
    parity=serial.PARITY_NONE,
    stopbits=serial.STOPBITS_ONE,
    bytesize=serial.EIGHTBITS,
    timeout=1
)

while 1:
    x = ser.readline()
    print(x)
When i push a button in my tft screen i get

b'e\x06\x01\x00\xff\xff\xff'

this has a meaning (that i know)

the problem is that i want to do the opposite that is: write in the port the same command

so i've write this

serial_write.py
import time
import serial

ser = serial.Serial(

    port='/dev/ttyAMA0',
    baudrate=9600,
    parity=serial.PARITY_NONE,
    stopbits=serial.STOPBITS_ONE,
    bytesize=serial.EIGHTBITS,
    timeout=1
)

while 1:
    y='e\x06\x01\x00\xff\xff\xff'
    ser.write(y)
but it does not work. I don't get anything when i run serial_read.py
it seems that i'm not sending anything
what's wrong?
help is appreciated
Reply
#2
this has a meaning (that i know)
OK, so you know what the meaning is?
do tell
Reply
#3
I didn't think it would be helpful

https://nextion.itead.cc/resources/docum...ction-set/

0x65 7 Touch Event 0x65 0x06 0x01 0x00 0xFF 0xFF 0xFF


Returned when Touch occurs and component’s
corresponding Send Component ID is checked
in the users HMI design.
0x06 is page number, 0x01 is component ID,
0x01 is event (0x01 Press and 0x00 Release)
data: Page 6, Component 1, released
Reply
#4
Quote:I didn't think it would be helpful
Perhaps you're correct, at least on a high level. I have interfaced to
simpler devices, and knew that there are a series of commands that
must be sent, correctly, in proper order, before anything would be
seen on the device.
From the Nextion Instruction set manual:
Quote:Note: Nextion will remain waiting at step 5 until every byte of specified quantity is received.
so I suspect this is why you're not seeing anything

Have you seen this: https://github.com/g4klx/MMDVMHost
This appears to be a complete interface to one of their displays.

Another page http://vorsselmansphilip.blogspot.com/20...-test.html

and one final:
http://www.marrold.co.uk/2017/03/adding-...mhost.html
Reply
#5
thanks
I will have a look
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pyserial/serial "has no attribute 'Serial' " gowb0w 9 3,911 Aug-24-2023, 07:56 AM
Last Post: gowb0w
  UART Serial Read & Write to MP3 Player Doesn't Work bill_z 15 5,810 Jul-17-2021, 04:19 PM
Last Post: bill_z
  Python Read/Write serial dlizimmerman 0 6,621 Jan-31-2019, 03:12 AM
Last Post: dlizimmerman
  serial communication write(comand) and read(result) ricardons 1 2,903 Mar-01-2018, 04:26 PM
Last Post: mpd
  NMEA read parse and write from/to serial port ESEAMarine 1 10,584 Aug-11-2017, 12:36 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020