arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
21.73k stars 4.72k forks source link

Reading ascii serial communication with from Nextion display #5774

Closed andreapede closed 5 years ago

andreapede commented 5 years ago
### ISSUE DESCRIPTION - TROUBLESHOOTING Nextion display send data via serial port using ascii string that ends with a triple ansi code delimiter \xFF\xFF\xFF. To send data to the nextion the procedure is the same and it is necessary to send a string ending with the same three escapes code. I can send the data (just fixed the last bugs) using the SerialSend3 command that accepts the 3 escape code at the end. I can also read the incoming message from Nextion display in hex from Tasmota firmware, but only if I use, triggering the routine, the SerialCommand5. In this way the esp8266 start receiving information in hex, otherwise there is no effect. ### REQUESTED INFORMATION Due to the fact that I use node-red flow to send and receive the data, sending a message using the SerialSend3 and after that another SS5 is quite tricky. Also it does seems to me that a proper reception should be independent from this sort of triggering. Something to suggest or is it a bug? **FAILURE TO COMPLETE THE REQUESTED INFORMATION WILL RESULT IN YOUR ISSUE BEING CLOSED** - [ x] Read the [Contributing Guide and Policy](https://github.com/arendst/Sonoff-Tasmota/blob/development/CONTRIBUTING.md) and [the Code of Conduct](https://github.com/arendst/Sonoff-Tasmota/blob/development/CODE_OF_CONDUCT.md) - [ x] Searched the problem in issues (https://github.com/arendst/Sonoff-Tasmota/issues) - [ x] Searched the problem in the wiki (https://github.com/arendst/Sonoff-Tasmota/wiki/Troubleshooting) - [ x] Searched the problem in the forum (https://groups.google.com/d/forum/sonoffusers) - [ x] Searched the problem in the chat (https://discord.gg/Ks2Kzd4) - [ x] Device used (i.e. Sonoff Basic) : 18 Generic - [ x] Tasmota binary firmware version number used : 6059/ self-compiled ? - [ x] Development IDE - Compiler / Upload tools used : VSCODE Platformio - [ x] Provide the output of command ``status 0`` : ``` STATUS 0 OUTPUT HERE: 23:13:49 RSL: Group 0, Index 1, Command STATUS, Data 0 23:13:49 MQT: stat/sonoff-next/STATUS = {"Status":{"Module":18,"FriendlyName":["Sonoff-next"],"Topic":"sonoff-next","ButtonTopic":"0","Power":0,"PowerOnState":3,"LedState":1,"LedMask":"FFFF","SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":0}} 23:13:49 MQT: stat/sonoff-next/STATUS1 = {"StatusPRM":{"Baudrate":9600,"GroupTopic":"sonoffs","OtaUrl":"http://thehackbox.org/tasmota/release/sonoff.bin","RestartReason":"External System","Uptime":"0T00:29:08","StartupUTC":"2019-05-09T21:44:41","Sleep":50,"CfgHolder":4617,"BootCount":10,"SaveCount":26,"SaveAddress":"FA000"}} 23:13:49 MQT: stat/sonoff-next/STATUS2 = {"StatusFWR":{"Version":"6.5.0.9(sonoff)","BuildDateTime":"2019-05-09T18:58:47","Boot":31,"Core":"2_4_2","SDK":"2.2.1(cfd48f3)"}} 23:13:49 MQT: stat/sonoff-next/STATUS3 = {"StatusLOG":{"SerialLog":0,"WebLog":4,"SysLog":0,"LogHost":"","LogPort":514,"SSId":["axiot","cAP-ax2"],"TelePeriod":300,"Resolution":"558180C0","SetOption":["00C08009","280500000100000000000000000000000000","00000000"]}} 23:13:49 MQT: stat/sonoff-next/STATUS4 = {"StatusMEM":{"ProgramSize":533,"Free":468,"Heap":20,"ProgramFlashSize":4096,"FlashSize":4096,"FlashChipId":"1640E0","FlashMode":2,"Features":["00000809","0FDAE394","240783A1","23B617CE","01003BC0"]}} 23:13:49 MQT: stat/sonoff-next/STATUS5 = {"StatusNET":{"Hostname":"sonoff-next-4217","IPAddress":"192.168.1.39","Gateway":"192.168.1.1","Subnetmask":"255.255.255.0","DNSServer":"192.168.1.1","Mac":"18:FE:34:CA:F0:79","Webserver":2,"WifiConfig":4}} 23:13:49 MQT: stat/sonoff-next/STATUS6 = {"StatusMQT":{"MqttHost":"192.168.1.9","MqttPort":1883,"MqttClientMask":"DVES_%06X","MqttClient":"DVES_CAF079","MqttUser":"admin","MqttCount":1,"MAX_PACKET_SIZE":1000,"KEEPALIVE":15}} 23:13:49 MQT: stat/sonoff-next/STATUS7 = {"StatusTIM":{"UTC":"Thu May 09 22:13:49 2019","Local":"Thu May 09 23:13:49 2019","StartDST":"Sun Mar 31 02:00:00 2019","EndDST":"Sun Oct 27 03:00:00 2019","Timezone":"+01:00","Sunrise":"05:17","Sunset":"20:16"}} 23:13:49 MQT: stat/sonoff-next/STATUS10 = {"StatusSNS":{"Time":"2019-05-09T23:13:49"}} 23:13:49 MQT: stat/sonoff-next/STATUS11 = {"StatusSTS":{"Time":"2019-05-09T23:13:49","Uptime":"0T00:29:08","Vcc":3.017,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"Wifi":{"AP":2,"SSId":"cAP-ax2","BSSId":"CC:2D:E0:5D:7E:E6","Channel":5,"RSSI":100,"LinkCount":1,"Downtime":"0T00:00:04"}}} ``` - [x] Provide the output of console when you experience your issue if apply : _(Please use_ ``weblog 4`` _for more debug information)_ ``` 22:58:53 RSL: Received Topic cmnd/sonoff-next/SerialSend3, Data Size 34, Data t0.txt="1557439134158"\xFF\xFF\xFF 22:58:53 RSL: Group 0, Index 3, Command SERIALSEND, Data t0.txt="1557439134158"\xFF\xFF\xFF 22:58:53 MQT: stat/sonoff-next/RESULT = {"SerialSend":"Done"} 22:59:05 WIF: Checking connection... 22:59:05 WIF: Connected ***starting from here there are some data incoming from the nextion ***** 22:59:20 CMD: SerialSend \x04 22:59:20 SRC: WebConsole from 192.168.1.37 22:59:20 RSL: Received Topic /SerialSend, Data Size 4, Data \x04 22:59:20 RSL: Group 0, Index 1, Command SERIALSEND, Data \x04 22:59:20 MQT: stat/sonoff-next/RESULT = {"SerialSend":"Done"} 22:59:25 WIF: Checking connection... 22:59:25 WIF: Connected 22:59:45 WIF: Checking connection... 22:59:45 WIF: Connected **** only after the following command i'm able to receive the messages from nextion**** 22:59:50 CMD: SerialSend5 \xFF 22:59:50 SRC: WebConsole from 192.168.1.37 22:59:50 RSL: Received Topic /SerialSend5, Data Size 4, Data \xFF 22:59:50 RSL: Group 0, Index 5, Command SERIALSEND, Data \xFF 22:59:50 MQT: stat/sonoff-next/RESULT = {"SerialSend":"Done"} 22:59:50 CFG: Saved to flash at FA, Count 26, Bytes 3584 22:59:53 MQT: tele/sonoff-next/RESULT = {"SerialReceived":"706369616f313121ffffff"} 22:59:55 MQT: tele/sonoff-next/STATE = {"Time":"2019-05-09T22:59:55","Uptime":"0T00:15:14","Vcc":3.013,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"Wifi":{"AP":2,"SSId":"cAP-ax2","BSSId":"CC:2D:E0:5D:7E:E6","Channel":5,"RSSI":100,"LinkCount":1,"Downtime":"0T00:00:04"}} 22:59:55 MQT: tele/sonoff-next/RESULT = {"SerialReceived":"706369616f313121ffffff"} 23:00:05 WIF: Checking connection... 23:00:05 WIF: Connected 23:00:23 MQT: tele/sonoff-next/RESULT = {"SerialReceived":"706369616f313121ffffff"} 23:00:25 WIF: Checking connection... ``` **(Please, remember to close the issue when the problem has been addressed)**
andreapede commented 5 years ago

I suppose I must try to use directly the SerialSend5 to transmit and recive all the data.

andreapede commented 5 years ago

Just discovered the the flag mqtt_serial_raw flush out all the ascii code > 127 if set to 0 (as in the SerialSend3) and the reason for not reciving the string from Nextion (that contains the escape codes).