-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[P016] DecodeType UNKNOWN was not on the web interface (decodetypes UNKNOWN and UNUSED were mixed up!) #4907
Conversation
src/_P016_IR.ino
Outdated
} | ||
else { | ||
Log += F("\' type: 0x"); | ||
Log += uint64ToString(results.decode_type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't have a base argument here, so it isn't a proper hex value and thus the leading 0x
in the string is a bit misleading to say the least.
In ESPEasy src/src/Helpers/StringConverter_Numerical.h
there are ull2String
and ll2String
to print uint64_t
and int64_t
respectively.
Also IMHO there should be no negative hex values, so better not mark it as a hex formatted value (leading 0x
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Hm, though I've done quite some work on this plugin and the IR library, I'm absolutely no expert on the matter, so that question should probably be redirected to the maintainers of the IRremoteESP8266 library. |
@TD-er and @tonhuisman: I have already tried
What is wrong? |
Can you get a stacktrace of that exception? (When using VSCode/PIO, using the Monitor feature, it will try to catch that when the unit crashes, though it may take a few attempts for the monitor to actually grab the stacktrace...) |
As reported here: #4907 (comment)
There seem to be 2 potential issues:
Size check could be fixed by this change: (line 222 of
The empty command check could be done at saving the commands, didn't try to fix that yet |
…command is really not empty
I did the changes @tonhuisman proposed and merged the latest mega (Fix crash in command arg parsing with nullptr string) into this PR. For me it looks like a stack overflow because the crash dump not even fits in the VS terminal window.
|
That's a very plausible cause, as both P016 and P036 are using quite a lot of memory and stack. |
I always have my own |
Would it be possible for you to test this on an ESP32, to determine if it's a code-issue or 'simply' stack related? |
Is your |
This file doesn't have P036 enabled? Which command do you give, how it is it being processed? (e.g received via MQTT, from rules, from HTTP-GET, via serial?) |
The P036 is enabled in my As I mentioned above the |
As I mentioned above the oledframedcmd is processed by |
In that function, there is a stack allocated object, which is relatively large: case PLUGIN_TEN_PER_SECOND:
{
decode_results results; This is 80 bytes. But anyway, what is the origin of the |
I also have also a modiefied section in
|
OK, and it is when using this exact pull request? |
Yes, it is except my |
I will have a look at your code to see if things can be improved or maybe something a-typical is happening when receiving IR commands. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo error in the first commit
@TD-er I'm not sure if I should merge your branch, too.
Therefore I reverted the merge.
Ehh now you really lost me... Why????? |
So you mean that with this commit it all became unstable? |
src/_P016_IR.ino
Outdated
log += description; | ||
addLogMove(LOG_LEVEL_INFO, log); | ||
} | ||
addLogMove(LOG_LEVEL_INFO, strformat(F("AC State: %s"), description)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fails compilation as you have to pass the .c_str()
pointer for strformat to handle in the %s
parameter.
I know, but I couldn’t change so far.
In my local build I do not test all #defines, that’s why I didn’t encounter the error.
|
Yes, at least with my local build.
I think in the context of drained resources, the additional booleans serve as the proverbial straw that breaks the camel's back.
|
I'm sorry that I made you desperate.
The changes are not lost!
I was not sure if I should merge your changes to this PR or whether you
wanted to do it.
|
I already split the P036 code to another PR, so I guess we can keep this PR just about the P016. I'm looking into the code a bit more and I'm still not 100% convinced it is a stack overflow. When receiving commands from some external source, which does not need an immediate reply, then those could be executed in the next loop without any issue. So I guess we should add some queue for at least the P016 and maybe some others too. If you could test this PR (with only the P036 code) to make sure I didn't break anything, then we can merge it and then merge it into this PR so we essentially move this PR to be on top of the other code changes. |
Sounds good.
I will test it but may be not this week.
I also had the idea to create dynamically the following structures in P036_data_struct.h to save ressources:
Only for page scrolling:
* tScrollLine SLine[P36_MAX_LinesPerPage]{}; (line 225)
* tScrollingPageLines In[P36_MAX_LinesPerPage]{}; (line240)
* tScrollingPageLines Out[P36_MAX_LinesPerPage]{}; (line 241)
Only for ticker:
* tTicker Ticker; (line 227)
All of them have strings inside.
|
@uwekaditz |
Use the new property addToQueue in ExecuteCommand_all() due to the lack of resources Using strformat() for the debug messages Heap and memory can be reported (P016_CHECK_HEAP)
@TD-er Thank you very much 👋
|
src/_P016_IR.ino
Outdated
# ifdef P016_CHECK_HEAP | ||
if (loglevelActiveFor(LOG_LEVEL_INFO)) { | ||
addLogMove(LOG_LEVEL_INFO, strformat( | ||
F("Before decode: FreeMem: %d FreeStack:%d / After: FreeMem: %d FreeStack:%d"), | ||
fMem, fFreeStack, | ||
FreeMem(), getCurrentFreeStack())); | ||
} | ||
# endif // ifdef P016_CHECK_HEAP | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, not indenting the #ifdef
's, and not formatting the source using Uncrustify, horribly breaks the indentation guides (lines) in modern editors like VSCode... 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn' uncrustify my changes. 😭
On the other hand it is much easier for me to read the code if the #ifdef's
start at the beginning of the line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to read the code if the
#ifdef's
start at the beginning of the line.
Nope, not for me, that totally breaks the normal flow of the code...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used the Uncrustify function in VScode, but position of the #ifdef's
were not changed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not configured in the settings for Uncrustify 🥲 and I haven't found the courage to learn yet another complicated config...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That means it has to be done manually?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I usually do, as I like my sourcecode prettified 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope you enjoy my code now too 😃
The position of the #ifdef's were not changed!
That's good to hear :) |
The position of the #ifdef's were not changed!
I created an issue about the protocol type for |
The maintainers of the IRremoteESP8266 library do suggest not to use Up to now, in the P016 settings decode type |
BUG: Decode types UNKNOWN and UNUSED were mixed up CHG: Reverted changes for this PR in \lib\IRremoteESP8266\src\IRtext.cpp CHG: Workaround for decode type UNKNOWN is not necessary CHG: Initalisation of the variables with decode type UNUSED (=0)
At the end it was so simpel 😆 |
NEW: For using any IR message in the [P016] Command map the protocol RAW needs to be set
FIX: uint64ToString() in a debug message in
PLUGIN_TEN_PER_SECOND
can not handle decode_type_t::UNKNOWN (-1)@tonhuisman I'm not sure if
DECODE_HASH
should get its own protocol?