Sending Commands from Nextion to Linux CMD Line?

Hi All,

I have been making HMI files for ages that work with open source software but I am now in uncharted territory trying to send commands from the Nextion (Enhanced) via a USB to tty serial adapter in ttyUSB0 on a pi4 running python3. I want send plain text commands to the command line of the pi4 by entering them in the TouchReleaseEvent on a Nextion button.

Firstly, is that even possible? I can obviously run ‘screen’ on the pi4 and monitor what is coming through the serial port but that is obviously not the same as the pi4 receiving the data from the serial port as command line instructions.

Thanks.

You probably need a program to interpret the incoming serial commands and then execute them. The commands will need to already exist on the pi4.

1 Like

Thanks for the reply, Surely in the simplest of terms the OS on the pi is a program that will receive the commands and interpret them?

All I want to do for this test is create a button on nextion, that on the release event will send the word clear to the CMD line and have it clear the screen in the terminal window.

The button is already created, I have setup redirect so that the nextion output plugged into ttyUSB0 is appearing on the terminal window and is followed by a carriage return so the prompt moves to the next line.

However, a redirect only causes the received data ‘clear’ to be treated as a string in a dumb terminal, it is not received at the command prompt as command.

I am starting to believe this is not possible and I will have to scrap the nextion in favour of a proper raspberry pi touch screen.

It doesn’t work like that. You need a program on the pi to interpret the incoming serial and then act on that command.

Thanks ELF,
I have been on this simple task all weekend and clearly all the advice on using screen, Socat etc etc have been leading be in the wrong direction?
Can you give me an example of what I need on the pi please as obviously, googling “a program” or “interpreter” isn’t going to Weald a usable result :slight_smile:

Post #5 in this thread: https://www.linuxquestions.org/questions/linux-general-1/writing-to-the-command-line-from-a-device-on-ttyusb0-4175739183/

Did that not work? ???(extra characters to make post 20 characters long)

No, in actual fact the solution was much more simple than any of the previous replies. In part I guess I wasn’t detailed enough in my question?. You only know what you know but you don’t know what you don’t know until you know what it was you didn’t know.

I think this one sentence, and in particular the use of the word "interpret’ was the key to resolving my issue. The pi4 I was testing on wasn’t the pi4 I would ultimately be running my ttyUSB0 device on, that 2nd pi4 device had a software package running with it’s own specific “CLI” and it was that interface that would ‘interpret’ my redirected input. Once I made that link in my head the solution was simple.