yozik04 / nextion

Nextion serial client
GNU Lesser General Public License v3.0
25 stars 10 forks source link

Async event handler function not executed #29

Closed zsoltmazlo closed 1 year ago

zsoltmazlo commented 1 year ago

Hey there!

I'm using your example code with my Nextion NX4024T032_011R, and sending data to the device works fine. It seems that the connection works properly:

2022-10-14 20:31:38,590 - INFO - Connecting: COM4, baud: 115200 2022-10-14 20:31:38,601 - INFO - Connected to serial 2022-10-14 20:31:38,601 - DEBUG - sent: b'DRAKJHSUYDGBNCJHGJKSHBDN' 2022-10-14 20:31:38,608 - DEBUG - received: b'1a' 2022-10-14 20:31:38,638 - DEBUG - sent: b'connect' 2022-10-14 20:31:38,654 - DEBUG - received: b'636f6d6f6b20312c33373637332d302c4e5834303234543033325f303131522c3136332c36313438382c444536373730353534373241343032452c34313934333034' 2022-10-14 20:31:38,655 - INFO - Address: 37673-0 2022-10-14 20:31:38,655 - INFO - Detected model: NX4024T032_011R 2022-10-14 20:31:38,655 - INFO - Firmware version: 163 2022-10-14 20:31:38,655 - INFO - Serial number: DE677055472A402E 2022-10-14 20:31:38,655 - INFO - Flash size: 4194304 2022-10-14 20:31:38,655 - DEBUG - sent: b'bkcmd=3' 2022-10-14 20:31:38,669 - DEBUG - received: b'01' 2022-10-14 20:31:38,671 - DEBUG - sent: b'get sleep' 2022-10-14 20:31:38,685 - DEBUG - received: b'7100000000' 2022-10-14 20:31:38,686 - INFO - Successfully connected to the device

However, when I click on a button, the event_handler method is not executed at all. This button would change the page, so the 'Send Component ID' checkbox is ticked and also a sendme instruction is issued when the page is initialized.

The device sends back both information, I tried with the Nextion Editor application: image

I'm not sure what am I missing. Tested both on Linux and Windows.

Python 3.10, package versions: image

yozik04 commented 1 year ago

Hi @zsoltmazlo If device would send anything, then you'd see that in DEBUG - received messages.

zsoltmazlo commented 1 year ago

OK, sorry, It's absolutely my bad.

What I did is I changed the run method in the App class, where I made a while cycle periodically updating some texts in the screen. The problem was I used time.sleep for waiting, because "for now it's OK", but because of that, the other tasks/co-routines were not executed at all.