Creating a Blocking Thread on espconn_gethostbyname

AgentSmithers
Posts: 123
Joined: Sat Apr 01, 2017 1:21 am
Contact:

Creating a Blocking Thread on espconn_gethostbyname

Postby AgentSmithers » Sun Jul 08, 2018 7:41 am

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?

AgentSmithers
Posts: 123
Joined: Sat Apr 01, 2017 1:21 am
Contact:

Re: Creating a Blocking Thread on espconn_gethostbyname

Postby AgentSmithers » Tue Jul 31, 2018 7:22 am

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.

Pato
Posts: 31
Joined: Sat Mar 24, 2018 12:52 am

Re: Creating a Blocking Thread on espconn_gethostbyname

Postby Pato » Thu Aug 02, 2018 10:24 pm

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
Last edited by Pato on Fri Aug 03, 2018 3:55 pm, edited 1 time in total.

AgentSmithers
Posts: 123
Joined: Sat Apr 01, 2017 1:21 am
Contact:

Re: Creating a Blocking Thread on espconn_gethostbyname

Postby AgentSmithers » Thu Aug 02, 2018 11:08 pm

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;

Pato
Posts: 31
Joined: Sat Mar 24, 2018 12:52 am

Re: Creating a Blocking Thread on espconn_gethostbyname

Postby Pato » Fri Aug 03, 2018 3:59 pm

Yep, and here is their ASM solution :)
https://github.com/esp8266/Arduino/blob ... 266/cont.S

Who is online

Users browsing this forum: Google [Bot] and 10 guests