Page 1 of 1

Creating a Blocking Thread on espconn_gethostbyname

Posted: Sun Jul 08, 2018 7:41 am
by AgentSmithers
Anyone know of a useful way to make the command espconn_gethostbyname a blocking thread. I've tried using a while loop on a Global Bool var but no dice. Does anyone have a workaround?

Re: Creating a Blocking Thread on espconn_gethostbyname

Posted: Tue Jul 31, 2018 7:22 am
by AgentSmithers
Everyone, I wanted to circle back and say at this point in time I am convinced this is not possible due to internal processes that take place once the code returns to the SDK internal calls. I required this to simplify the call tree being created depending on the circumstances but at this point, I have to store a checkpoint/marker as a Global Variable to return to the correct location.

Re: Creating a Blocking Thread on espconn_gethostbyname

Posted: Thu Aug 02, 2018 10:24 pm
by Pato
Hey,

I am also studying a way to do a kind of wait() or delay() that would block the execution of my function while letting the SDK do its background tasks like Wifi and TCP processing.

I've found very intersesting things in the ESP support for Arduino IDE: their great guys have built this exact same function with some pieces of assembler to switch context and stack (https://github.com/esp8266/Arduino/blob ... 6_main.cpp)

You can grep "esp_yield" on this whole Git repo to see how they achieved this, I'm also doing so to understand their tricks, you may figure out a solution for you :)
Good luck

Re: Creating a Blocking Thread on espconn_gethostbyname

Posted: Thu Aug 02, 2018 11:08 pm
by AgentSmithers
Pato wrote:Hey,

I am also studying a way to do a kind of wait() or delay() that would block the execution of my function while letting the SDK do its background tasks like Wifi and TCP processing.

I've found very intersesting things in the ESP support for Arduino IDE: their great guys heve build this exact same function with some pieces of assembler to switch context and stack (https://github.com/esp8266/Arduino/blob ... 6_main.cpp)

You can grep "esp_yield" on this whole Git repo to see how they achieved this, I'm also doing so to understand their tricks, ou may figure out a solution for you :)
Good luck


Yeah, In X86 ASM we use PUSHAD and POPAD to store all the CPU Vars onto the stack You can then set your pointer to another function to pop the var's and assume that it's pretty much where it left off. Not sure if we have that here as a possibility.

*Update* After searching the forum I did find this sniblet so it's doable in 'C'. Maybe we can do a pushpop trick to resume where we started. Tottally a unsupported hack attempt but could be fun :)

For turning on GPIO

Code: Select all

__asm__ volatile ("movi a2, 0x60000304\n"
"movi a4, %0\n"
"memw\n"
"s32i a4, a2, 0\n"
::"r" (setbits):"a2", "a4");
setbits is a static uint16;

Re: Creating a Blocking Thread on espconn_gethostbyname

Posted: Fri Aug 03, 2018 3:59 pm
by Pato
Yep, and here is their ASM solution :)
https://github.com/esp8266/Arduino/blob ... 266/cont.S