Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read still 777777 #54

Open
puhycz opened this issue Apr 5, 2023 · 16 comments
Open

Read still 777777 #54

puhycz opened this issue Apr 5, 2023 · 16 comments

Comments

@puhycz
Copy link

puhycz commented Apr 5, 2023

I have HMI with page0 and page1. Writing data is ok, nextion lissen and trigger works perfectly, but i can't read any variable. I try any variables, local, global but still return 777777:

myNex.writeStr("page 1") Serial.println(myNex.readNumber("n0.val"));

I think reading works when nextionlisten works on the touch pad. Why readings of variables still return 777777?
Thanks for any ideas.

Platform: ESP32/platformio/arduino framework

@Seithan
Copy link
Owner

Seithan commented Apr 11, 2023

https://github.com/Seithan/EasyNextionLibrary#function-documentation

NOTE: As these commands are using the Serial port to read and write, it is more preferred not to run them in the loop() without delay(); or some other method of not running them with the frequency of the loop and use them only when it is needed. Using them in a loop, a delay in the loop can be noticed, especially when reading from the Serial. A Serial buffer overflow can also be caused.

@18Markus1984
Copy link

I have HMI with page0 and page1. Writing data is ok, nextion lissen and trigger works perfectly, but i can't read any variable. I try any variables, local, global but still return 777777:

I have the same issue, I didn't get the controller to send any data. I tried a lot of different configurations by sending the print at different times. The Data always is 777777. I also checked if I can only read the data while I'm on the same page but this also did work. Maybe we can find a solution. I'm using an NodeMCU ESP8266 but I will try it on my ESP32 S2 Mini and the Arduino Uno.

@puhycz
Copy link
Author

puhycz commented Apr 28, 2023

I tested it on ESP32. Still read 777777. I tested 4800 - 115200 baudrate. And still the same. 777777. Write is ok, trigger is ok, but when I need read values, return 777777. I use HW Serial2 on ESP32. I try on 3 different ESP32 board. Still same, 777777.

@18Markus1984
Copy link

I tested it on ESP32. Still read 777777. I tested 4800 - 115200 baudrate. And still the same. 777777. Write is ok, trigger is ok, but when I need read values, return 777777. I use HW Serial2 on ESP32. I try on 3 different ESP32 board. Still same, 777777.

What if we can read the data on a seperate SoftwareSerial connection we switch to while the trigger is recogniced? And send the data as a printh because the next data char have to be the data?

@Seithan Seithan closed this as completed Apr 30, 2023
@18Markus1984
Copy link

18Markus1984 commented Apr 30, 2023

Why do you closed the issue? Do you have a solution? I really want to get your library working for my university project. It would be super kind to get an answer.

@Seithan Seithan reopened this May 9, 2023
@Seithan
Copy link
Owner

Seithan commented May 9, 2023

@18Markus1984 Can you provide more information?
It will be better if you can send me the code and the HMI that you are using

@puhycz
Copy link
Author

puhycz commented Sep 21, 2023

So, for example, in this HMI is set global variable va1: HMI . How read this variable? myNex.readNumber("va1.val")); not function. Still reads 777777.

Thanks.

@Grandpa-G
Copy link

Any solution yet? I am trying to read rtc0 in setup with 500 delay after. I have tried other variables with the same result - all 7.

@Grandpa-G
Copy link

I belive I have found the problem and have a solution. At line 245 in EasyNextionLibrary.cpp, the checking of the incoming data for the end of data flag(s) is incorrect. The code is looking for either FF or FFFFFF. I have it is FFFFFF which matches. However the code wants 3 bytes of code before setting the _endOfCommandFound flag. When FFFFFF comes in, it is a end of command flag, but all at once. A solution is to make 2 seperate if statements so the FFFFFF will immediately set the _endOfCommandFound flag and break. I have done limited testing, but it work for me. Thus the new code looks like:

			if(_tempChar == 0xFFFFFFFF){  // If the read byte is the end command byte, 
				_endOfCommandFound = true;  // If the counter is equal to 3, we have the end command
				break;
			}
			if(_tempChar == 0xFF){  // If the read byte is the end command byte, 

@Seithan
Copy link
Owner

Seithan commented Oct 10, 2023

So, for example, in this HMI is set global variable va1: HMI . How read this variable? myNex.readNumber("va1.val")); not function. Still reads 777777.

Thanks.

https://github.com/Seithan/EasyNextionLibrary#usefull-tips

be at the page you are currently on.
Otherwise, if the variables are of global scope, you will need to use a prefix with the page name that the variables are at.
Example:
myNex.readNumber("page0.va0.val"); // If the variable is at page0
The same goes for the other functions as well.

Always use a prefix with the page name for global variables
And on Preinitialize Event
baud=9600
bkcmd=0

image

@18Markus1984
Copy link

18Markus1984 commented Oct 12, 2023

I finally got it working. My problem was it to use the "printh 23 02 54 00" in the button, where I also added the "page page1" to go to the next page. I think that creates a problem between the Arduino and the display. The solution was to add sliders to set the values after the slider was moved. Maybe that can help somebody.

Also this Wiki page is pretty nice and organized: https://wiki.iteadstudio.com/index.php?title=Nextion_Instruction_Set&oldid

@Seithan
Copy link
Owner

Seithan commented Oct 14, 2023

I belive I have found the problem and have a solution. At line 245 in EasyNextionLibrary.cpp, the checking of the incoming data for the end of data flag(s) is incorrect. The code is looking for either FF or FFFFFF. I have it is FFFFFF which matches. However the code wants 3 bytes of code before setting the _endOfCommandFound flag. When FFFFFF comes in, it is a end of command flag, but all at once. A solution is to make 2 seperate if statements so the FFFFFF will immediately set the _endOfCommandFound flag and break. I have done limited testing, but it work for me. Thus the new code looks like:

			if(_tempChar == 0xFFFFFFFF){  // If the read byte is the end command byte, 
				_endOfCommandFound = true;  // If the counter is equal to 3, we have the end command
				break;
			}
			if(_tempChar == 0xFF){  // If the read byte is the end command byte, 

@Grandpa-G

I think this is not a permanent solution. If you want to try something, consider trying the following:

In line 178, change the char _tempChar; to byte _tempChar;

Let me know if this works better

@Grandpa-G
Copy link

I will try it but I am not sure how that will help.

I am having more problems with getNumber. I am almost always get 777777. Also there are many times when the trigger doesn't fire. I am at the end of the project deadline so I have to get this working.

@Seithan
Copy link
Owner

Seithan commented Oct 16, 2023

@Grandpa-G

If you want, you can send me the .ino and .HMI files of your project, so I can have a closer look at it and help you

@Grandpa-G
Copy link

I appreciate the offer but I am making progress. There some timing issues I may have introduced that delayed triggers.

2 Suggestions

  1. Rename readNumber to readNum. That would be consistent with writeNum. I would just add another entry point so it would be backward compatible.
  2. In the readNumber function, change each of the 777777 flags to individual values, like 777771, 777772,... and then remove the assignment from the last one when no end of command was found. Then the user would know which area is failing. This helped me.

@cattledogGH
Copy link

I had issues with 777777 from .readNumber( ) statements in trigger events when I had page switching code in the touch release event from the button press which sent the trigger command to the Arduino. I moved the page switching code into the Trigger function and the 777777 errors went away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants