These are chat archives for esp8266/Arduino

17th
Apr 2016
Michael Miller
@Makuna
Apr 17 2016 05:47
@bernamorillo Small? It seems a little on the large side. Looks like it might fit in a standard single mains box, but it wouldn't leave much room anything else (like a local switch).
sticilface
@sticilface
Apr 17 2016 07:26
@me-no-dev cool cheers that makes sense. So by unmask the inturrupt do you just use detachinturript?
sticilface
@sticilface
Apr 17 2016 07:44
Or disable them entirely using the nointerrupts().
sticilface
@sticilface
Apr 17 2016 07:55
Or InterruptLock lock; as I just found. I guess as pjon is a communication protocol that actually it should be allowed to just do its thing. I thing the 50byte limit is quite small, not sure what the total message timing is though. Will experiment. and see if it causes problems with wifi. How would I set inturrupts to disable the inturrupt on the pin, but keep the important wifi ones going?
sticilface
@sticilface
Apr 17 2016 08:58
ah perfect.
thanks
@igrr... is there a particular reason why the arduino.h attachinturrupt functions can not be cpp? ie... use functional so that you can define use lambdas with the callbacks?
Ivan Grokhotkov
@igrr
Apr 17 2016 09:01
no, i think it should be perfectly fine to replace attachInterrupt callback argument type with std::function<void(void)>
need to think if there are some edge cases when this can break existing sketches
Me No Dev
@me-no-dev
Apr 17 2016 09:05
it will prevent anyone to write an interrupt enabled stuff using C
same as with digitalRead/Write and so on
Ivan Grokhotkov
@igrr
Apr 17 2016 09:06
Oh yeah, right, it will break twi.c for example
#ifdef __cplusplus maybe, and different names for C- and C++ versions (non-mangled and mangled)
with C version implemented in C++, and calls C++ version :)
Me No Dev
@me-no-dev
Apr 17 2016 09:07
:D
Ivan Grokhotkov
@igrr
Apr 17 2016 09:08
scratch that, twi.c doesn't use attachInterrupt
Me No Dev
@me-no-dev
Apr 17 2016 09:08
no, but other things might
as far as I know all arduinos are C on that side
can we wrap the c++ callback and that be called from the C callback if lambda is needed?
sticilface
@sticilface
Apr 17 2016 09:35
That was quick! Awesome!
Cheers.
Under 10min. Even more awesome!!
Me No Dev
@me-no-dev
Apr 17 2016 09:51
@igrr is the size of the pointer to the labda the same as to a normal C function?
we have this struct in the core for each attached interrupt
typedef struct {
  uint8_t mode;
  void (*fn)(void);
} interrupt_handler_t;
Ivan Grokhotkov
@igrr
Apr 17 2016 10:09
well, lambda is just one case, in general the idea is to support any function object
so in theory you could store an object pointer and a member function pointer, but doing that manually is dirty and discouraged since c++11
or even, c++0x
marksev1
@marksev1
Apr 17 2016 15:22
So the sparkfun lib for the Apds-9930 gesture sensor uses interrupts that means ita no-go for a esp running wifi. But what if i had that sensor on arduino promini and it would send data via serial to esp8266? Would that work?
Clemens Kirchgatterer
@everslick
Apr 17 2016 15:34
any thoughts on declaring malloc, free and realloc as weak (attribute((weak))) so we can wrap them in sketches (for debugging and profiling purposes) ?
Ivan Grokhotkov
@igrr
Apr 17 2016 16:02
You mean wrap as -WL,wrap,malloc or just redefine weak symbol?
I think making malloc weak is not very useful, because it's a big complex function, and you would have to duplicate it's functionality in your sketch. That would be difficult because it uses some static variables from umm_malloc.c
Wrapping may be useful, because you can call real definition after/before you do profiling/logging
I wonder how widespread such use would be though... It's pretty easy to add corresponding flags locally in your platform.txt, so maybe a short piece of documentation on how to do that would be sufficient?
Clemens Kirchgatterer
@everslick
Apr 17 2016 17:31
i would like libraries also to use MY wrapper, that call malloc/free themself (also new and delete, but they call malloc and free anyway). i do not care so much as HOW this can be acomplished. i'm open to suggestions.
i just found #ifdef UMM_REDEFINE_MEM_FUNCTIONS. if there was a way to unset this define, i could wrap malloc/free in my scatch and call umm_malloc in my wrappers.
Me No Dev
@me-no-dev
Apr 17 2016 17:33
you comment it and it's unset. umm is built with the core every time you compile the sketch
Clemens Kirchgatterer
@everslick
Apr 17 2016 17:34
Me No Dev, yes i know, but that means i have to mess with my local copy of the Arduino core. I'd prefere to be able to do it from my makefile or such
Me No Dev
@me-no-dev
Apr 17 2016 17:36
whatever way you chose, you will need to modify a file or two. If you do your own makefile, then maybe you can wrpa them and go that way with just modifying the flags
there are already two functions rewritten and you can see the flags in the platform.txt
then one is implemented in core_esp8266_postmortem.c
system_restart_local that is
Clemens Kirchgatterer
@everslick
Apr 17 2016 17:41
thx, i look at plattform.txt and postmortem.c
Clemens Kirchgatterer
@everslick
Apr 17 2016 17:48
hmm, i see __wrap_system_restart_local(), but i don't see where it is used ??? i' confused
Me No Dev
@me-no-dev
Apr 17 2016 17:49
for example there is a function called system_restart_local that is in the inclued prebuilt libs that we need to overwrite in order to get the stack trace
so we need our function to be called instead
and we wrap it this way :)
Clemens Kirchgatterer
@everslick
Apr 17 2016 17:50
-Wl,-wrap,system_restart_local AHH
abviously th linker adds _wrap by itself ?
Me No Dev
@me-no-dev
Apr 17 2016 17:51
yes and __real_[method name]
Clemens Kirchgatterer
@everslick
Apr 17 2016 17:51
thats what ivan mentioned above
now i get it
Me No Dev
@me-no-dev
Apr 17 2016 17:51
that coresponds to the original function
Clemens Kirchgatterer
@everslick
Apr 17 2016 17:53
so i have to declare extern void ___real_malloc(size_t) and implement void ___wrap_malloc(size_t)
and set the linker flag -Wl,wrap,malloc and be done
argl this chat swallows all kind of symbols :(
Me No Dev
@me-no-dev
Apr 17 2016 17:55
extern void * __real_malloc(size_t);
void * __wrap_malloc(size_t len){
  ets_printf("trying to mallog %u bytes\n", len);
  return __real_malloc(len);
}
Clemens Kirchgatterer
@everslick
Apr 17 2016 17:56
nice, cut'n paste for me! THX!!! :-)
Me No Dev
@me-no-dev
Apr 17 2016 17:56
:)
but... since we are using umm_malloc, you might need to wrap actually umm_malloc(size_t) ninstead
I have not checked how umm maps it['s functions to malloc/free and so on
Clemens Kirchgatterer
@everslick
Apr 17 2016 18:00
it just adds defines i.e. umm_malloc malloc ...
so yes, i guess i have to wrap umm*
marksev1
@marksev1
Apr 17 2016 18:15
https://www.youtube.com/watch?v=fPDBZUztAhY here i found code so that the gesture sensor can work with esp8266 :)
Clemens Kirchgatterer
@everslick
Apr 17 2016 18:51
hmpf, slight annoyance: my __wrap_malloc functions get mangled even though i declare them extern "C"
Mario Mikočević
@mozgy
Apr 17 2016 20:41
sigh, #1916 stolen code ..
Michael Miller
@Makuna
Apr 17 2016 21:38
@mozgy stolen? They had copied code and made it into a usable Arduino Library, code that is not marked with any license, and they gave accreditation to that original code. What are you seeing that I didn't?