letscontrolit / ESPEasy

Easy MultiSensor device based on ESP8266/ESP32
http://www.espeasy.com
Other
3.26k stars 2.21k forks source link

IR Raw doesn't work and esp overload since 20190202 #2339

Closed dyter closed 5 years ago

dyter commented 5 years ago

1 | ✔ | Environment - DHT11/12/22 SONOFF2301/7021 | DHT |   | ❶(671) | GPIO-13 | Temperature:25.50Humidity:28.40 Edit | 2 | ✔ | Communication - IR Transmit | IR_Transmit |   |   | GPIO-5 |   Edit | 3 | ✔ | Communication - TSOP4838 | IR_Receive |   |   | GPIO-4 | IR:1809958797 Edit | 4 | ✔ | Output - NeoPixel (Basic) | Leds |   |   | GPIO-12 |   Edit | 5 | ✔ | Gases - CO2 MH-Z19 | Co2 |   |   | GPIO-14GPIO-2 | PPM:986.00Temperature:24.00U:0.00 Edit | 6 | ✔ | Analog input - internal | Battery |   |   | ADC (TOUT) | Volts:4.16 Edit | 7 | ✔ | Switch input - Switch | Button |   | ❶(50) | GPIO-0 | Portillon:0 Edit | 8 | ✔ | Generic - Dummy Device | Power |   |   |   | Low:0:0.00:0.00:0.00 Edit | 9 | ✔ | Generic - System Info | Sysinfo |   |   |   | FreeStack:3344FreeRAM:8376CPULoad:47Wifi:-71

jimmys01 commented 5 years ago

Give us the raw command you want to run and I will test it.

dyter commented 5 years ago

http://192.168.0.15/control?cmd=IRSEND,RAW2,^18BJB9BJB9BJD99*59BJBJB9B9^BD^19AJBBBHAABJB9BAA9B9AAA9BJBJAAA9,38,60,60

http://192.168.0.15/control?cmd=IRSEND,RAW2,^18BJB9BJB9BJD99*59BJBJB9B9^BD^19AJBBBHAABJB9BAA9B9AAA9BJBJAAA9,38,60,60

http://192.168.0.15/control?cmd=IRSEND,RAW2,R9F7CA696AD9*669D9D9696^A3Q9D9D96969D9*669D9D9696,38,90,68 |   http://192.168.0.15/control?cmd=IRSEND,RAW2,Q969D96969D969696A776969D9D9696^ABQ969D9696AD8*669D9D9696,38,90,68 http://192.168.0.15/control?cmd=IRSEND,RAW2,^15E9C9CID9CID*69CJDHC9D9^DP^16C9C9CID8DID9C9C8D9E7C9CICID9C9,38,62,51 http://192.168.0.15/control?cmd=IRSEND,RAW2,H99A494999499C7A4A494A499A894A8^9LH999495A794A8A8A*3494A8A8A499,38,138,67 50 | http://192.168.0.15/control?cmd=IRSEND,RAW2,LD5DAEADAE5DBCAE*45DAEAE5DA^DCLD5DBE9EAE5DADAE*45DAEAD5DA,38,112,47

The ESP go to overload or memory full, I do not know why

jimmys01 commented 5 years ago

IRSEND,RAW2,Q969D96969D969696A776969D9D9696^ABQ969D9696AD8*669D9D9696,38,90,68 works fine. Also you can use IRSEND,SONY,240C

IRSEND,RAW2,LD5DAEADAE5DBCAE*45DAEAE5DA^DCLD5DBE9EAE5DADAE*45DAEAD5DA,38,112,47 works fine. Also you can use IRSEND,SONY,3B0D

IRSEND,RAW2,H99A494999499C7A4A494A499A894A8^9LH999495A794A8A8A*3494A8A8A499,38,138,67works fine. the report from the IRrecvDumpV2 is


Timestamp : 004944.783
Encoding  : UNKNOWN
Code      : EBF674B3 (32 bits)
Library   : v2.5.5

Raw Timing[63]:
   +  2420, -   506,    +  1280, -   638,    +   592, -   566,    +   564, -   594, 
   +  1226, -   626,    +   538, -   620,    +  1226, -   802,    +  1038, -   630, 
   +   590, -   638,    +   564, -   570,    +   590, -   660,    +   566, -   592, 
   +  1248, -   670,    +  1120, -   592,    +   566, -   658,    +  1140, - 20684, 
   +  2402, -   580,    +  1280, -   566,    +   564, -   594,    +   676, -   690, 
   +  1042, -   536,    +   564, -   660,    +  1118, -   660,    +  1116, -   660, 
   +   588, -   572,    +   588, -   570,    +   566, -   594,    +   590, -   636, 
   +  1118, -   658,    +  1120, -   660,    +   566, -   594,    +  1226

uint16_t rawData[63] = {2420, 506,  1280, 638,  592, 566,  564, 594,  1226, 626,  538, 620,  1226, 802,  1038, 630,  590, 638,  564, 570,  590, 660,  566, 592,  1248, 670,  1120, 592,  566, 658,  1140, 20684,  2402, 580,  1280, 566,  564, 594,  676, 690,  1042, 536,  564, 660,  1118, 660,  1116, 660,  588, 572,  588, 570,  566, 594,  590, 636,  1118, 658,  1120, 660,  566, 594,  1226};  // UNKNOWN EBF674B3

So perhaps there is another problem? Also keep in mind that i used MQTT to send the commands and not http, so perhaps the problem is there.

EDIT: Aslo you have enabled many sensors, perhaps thats why you have issues.

dyter commented 5 years ago

IRSEND,SONY,540C,15 ... doesn't work for me since ESPEasy_IR function exist

So I reflashed the 20190216 for the another test and I found the bug: When I send http://192.168.0.15/control?cmd=IRSEND,RAW2,^18BJB9BJB9BJD99*59BJBJB9B9^BD^19AJBBBHAABJB9BAA9B9AAA9BJBJAAA9,38,60,60 power command on my Sony, in the log I have:

HTTP: IRSEND,RAW2,^18BJB9BJB9BJD99*59BJBJB9B9^BD^19AJBBBHAABJB9BAA9B9AAA9BJBJAAA9,38,60,60 126092: Invalid RAW2 B32 encoding!

My sony doesn't powered and the TSOP4838 IR crash ! I need to reboot the ESP

After this reset, when I do a new IR make with TSOP4838, the new RAW doesn't work on my Sony

jimmys01 commented 5 years ago

try http://192.168.0.15/control?cmd=IRSEND,SONY,540C

dyter commented 5 years ago

not work

the new RAW code http://192.168.0.15/control?cmd=IRSEND,RAW2,^17CJC9CJC9CLBCA8C*49CJCJC9C9^DM^17CJDCBKA9CJC9C9C9D*39CJCJC9C9,38,62,50 crash the TSOP4838

Sometime I have message Low memory. Cannot display webpage :-( when I want to go web page

TD-er commented 5 years ago

Has this ever worked? And if so, in what version was it working?

jimmys01 commented 5 years ago

My guess is that the HTTP ?cmd=etc is too many chars for the command to get through HTTP? I have tested MQTT up to 250 chars with no problems tomorrow I will also test he http method as well

TD-er commented 5 years ago

As far as I know, the command parser has some limits on the number of characters on a single argument.

The "Low memory" message is also an indication some plugins may need some attention or it is simply using too many memory hungry plugins.

dyter commented 5 years ago

Raw recognized or Raw transmit work fine with 20190121. And with no memory crash plugin

TD-er commented 5 years ago

So it must have been this pull request: https://github.com/letscontrolit/ESPEasy/pull/2232

TD-er commented 5 years ago

I've just done a ctrl-F on malloc and this is the first hit: https://github.com/letscontrolit/ESPEasy/blob/fce9acdba30746f8e243a8abbeaac7ca559e47ba/src/_P035_IRTX.ino#L636-L651

I notice there is no check for the value of count, so this one can get out of bounds without noticing and that will cause a crash. And that's just the first call to malloc.

jimmys01 commented 5 years ago

20190202 is the version I use on all my IR ( nodes, and the one I tested the raw commands posted above. Something else is going on. @TD-er the code that you mention is about Pronto devices, it is not called in this circumstances.

TD-er commented 5 years ago

Well, even if it isn't the cause of these issues, it still is a potential crash. And like I said, it was the first item I looked for.

Also when using large buffers, it is possible a malloc may fail and there should be a check for it (it will return a nullptr then). Do you have any idea where in the code I should start looking? I don't know the code of the IR plugins and library.

uzi18 commented 5 years ago

@TD-er in case of error buf is not deleted

jimmys01 commented 5 years ago

buf is created at lines 128-131 https://github.com/letscontrolit/ESPEasy/blob/fce9acdba30746f8e243a8abbeaac7ca559e47ba/src/_P035_IRTX.ino#L126-L131

buf is deleted at lines 244 245 https://github.com/letscontrolit/ESPEasy/blob/fce9acdba30746f8e243a8abbeaac7ca559e47ba/src/_P035_IRTX.ino#L243-L245

the only check not done is for variable idx (created at line 126). It represents the pulses count and we have 250 as the limit (the size of buf)

Edit TD-er: added permalinks

uzi18 commented 5 years ago

@jimmys01 No, it is not deleted in 219 and 223 idx is checked in 218 and 222

https://github.com/letscontrolit/ESPEasy/blob/fce9acdba30746f8e243a8abbeaac7ca559e47ba/src/_P035_IRTX.ino#L215-L223

Edit TD-er: added permalink

jimmys01 commented 5 years ago

Hmm OK I got it. So I assume this has to be addressed. Also there is another issue, that @dyter can't pass long commands through http. But I will test this tomorrow

TD-er commented 5 years ago

Can both of you give some link also when discussing the code? If you paste 'permalinks' to this repository here, it will be placed inline in the post. That will make it much easier to read what you're talking about.

uzi18 commented 5 years ago

@TD-er #2357 is ready ;)

jimmys01 commented 5 years ago

@uzi18 idx is not checked in case the encoding is Raw it is only checked in case is RAW2. But since RAW2 works for 90+% of remotes not many will be using RAW1

uzi18 commented 5 years ago

@jimmys01 but we talking about problem with RAW2 ;)

dyter commented 5 years ago

now with 20190226 no crash, but not work:

HTTP: IRSEND,RAW2,^18BJB9BJB9BJD99*59BJBJB9B9^BD^19AJBBBHAABJB9BAA9B9AAA9BJBJAAA9,38,60,60 140739: Invalid RAW2 B32 encoding!

and TSOP4838 not reponding, need a reboot

uzi18 commented 5 years ago

@dyter please provide more log and what you receive in browser when you click on this link: http://192.168.0.15/control?cmd=IRSEND,RAW2,^18BJB9BJB9BJD99*59BJBJB9B9^BD^19AJBBBHAABJB9BAA9B9AAA9BJBJAAA9,38,60,60

dyter commented 5 years ago

Browser say:

Base32Hex RAW Code: ^18BJB9BJB9BJD99*59BJBJB9B9^BD^19AJBBBHAABJB9BAA9B9AAA9BJBJAAA9 kHz: 38 Pulse Len: 60 Blank Len: 60

uzi18 commented 5 years ago

So it is not truncated string. Ok thanks

jimmys01 commented 5 years ago

2357 fixed his freeze issues and #2360 fixes the command not beeing decoded properly, my initial assumptions about the HTTP not passing the command was wrong.