Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Aditya Tannu
@AdySan
seems like, <sketchbook>/hardware does take priority over installed one though
Stavros Korokithakis
@skorokithakis
hey guys, i got into a bootloop/crash loop
would that be because i inadvertently applied 5v to the esp earlier? :(
Angus Gratton
@projectgus
skorokithakis: possibly, but FWIW I've applied 5V to ESPs a few times without incident
Stavros Korokithakis
@skorokithakis
hmm, yeah, i thought so too, but this is odd
Stavros Korokithakis
@skorokithakis
nah, i keep getting watchdog reset
i can flash it fine, it just won't run for some reason
i keep getting a long memory dump, does anyone know what that's about?
Stavros Korokithakis
@skorokithakis
turns out the tx/rx connections weren't secure enough and data was getting corrupted
is there a way to parse a string like "10 20 30" to ints easily?
Michael Miller
@Makuna
atoi() three times?
Stavros Korokithakis
@skorokithakis
that would require me to also know where to split the string, though
i'm looking for something like sscanf, but that doesn't seem to exist
i see it in a branch @igrr wrote, but it doesn't seem to be merged
Michael Miller
@Makuna
what about strtok
Stavros Korokithakis
@skorokithakis
aha! that's what i need, thanks!
ugh, why is everything in C so cumbersome...
Stavros Korokithakis
@skorokithakis
can anyone tell me why this strtok code leads to an infinite loop? https://www.pastery.net/ydthje/
Martin Ayotte
@martinayotte
You could try to use sscanf() to do the parsing, I've used it under STM32, but I don't if used under ESP will bring additional gcc libs
Oupps ! I've already figured out that you've already figured out that libcreplacement didn't provide it ... But maybe some tiny replacement could be added to libcreplacement
Stavros Korokithakis
@skorokithakis
yes, but i don't know how :/
i hate having to spend one hour to do something so simple
i used strtok as above and it just hangs in an infinite loop
Michael Miller
@Makuna
could strtok be used in the in mqttPublish? try strtok_r, strtok state can be reset if someone you don't know calls it.
Stavros Korokithakis
@skorokithakis
hmm, this takes different arguments
i can't even find documentation on this :(
Michael Miller
@Makuna
Stavros Korokithakis
@skorokithakis
thanks, that was a bit too confusing, but this is clearer: https://stackoverflow.com/questions/15961253/c-correct-usage-of-strtok-r
yep, looks like that was the problem
it's no longer infinitely looping now
thanks
Michael Miller
@Makuna
char* strtok(char* s, const char* delim) {
    static char* last;

    return (strtok_r(s, delim, &last));
}
Stavros Korokithakis
@skorokithakis
oh, will that work? what does static do?
Michael Miller
@Makuna
that is the implementation of strtok, and why its a problem to use, as it stores a value between calls (that's what static does, it states, make the variable live longer than the scope) so that if someone else calls it, it resets the static that you were calling.
it also shows how you can use strtok_r() where ever you used strtok before, just provide your own locally scoped (but still always within the scope of the multiple calls) variable to the last param.
Stavros Korokithakis
@skorokithakis
i see, that clarifies everything, thank you
so it looks like something else was indeed calling it, and it must have been something in mqttPublish, because it was sending the things in the preamble
mqttPublish concatenates some String objects, i think that was what was calling it
also, another interesting observation: analogWrite(2, 1000); digitalWrite(2, 0); doesn't reset the pin to 0
Michael Miller
@Makuna
which is scary, as do they protect themselves from someone doing it to them.
Stavros Korokithakis
@skorokithakis
it only resets it for an instant
@Makuna yeah, i don't think they do :/
Michael Miller
@Makuna
there is a whole series of these state storing C standard functions that SHOULD BE AVOIDED, as there is always the better alternative that doesn't.
Stavros Korokithakis
@skorokithakis
it's unfortunate that they don't do the right thing by default :/
Me No Dev
@me-no-dev
also, another interesting observation: analogWrite(2, 1000); digitalWrite(2, 0); doesn't reset the pin to 0
analogWrite(2, 0) will do it
pwm is software so digitalWrite will not do much
andig
@andig
hi guys, has anybody made the experience that the addition of the httpclient comes at a cost of ~6k ram?
is that the topic that igrr recently mentioned might be addressed by leaving https handling out with some linker changes?
andig
@andig
Found here: esp8266/Arduino#1857 original issue by @sticilface