Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 03:25
    oio123456789 starred espressif/arduino-esp32
  • 02:11
    paynterf commented #1411
  • 00:56
    ZhuBiaogh starred espressif/arduino-esp32
  • 00:15
    stale[bot] closed #2886
  • 00:15
    stale[bot] commented #2886
  • 00:15
    stale[bot] labeled #2931
  • 00:15
    stale[bot] commented #2931
  • 00:08
    doanerock commented #1225
  • 00:07
    doanerock commented #1225
  • Aug 24 23:15
    stale[bot] closed #1611
  • Aug 24 23:15
    stale[bot] commented #1611
  • Aug 24 23:15
    stale[bot] labeled #2722
  • Aug 24 23:15
    stale[bot] commented #2722
  • Aug 24 21:15
    manuelbl closed #3133
  • Aug 24 21:15
    manuelbl commented #3133
  • Aug 24 20:42
    atanisoft commented #3133
  • Aug 24 20:25
  • Aug 24 20:15
    manuelbl opened #3133
atanisoft
@atanisoft
take out everything except main.h and DEFAULT_CONST lines
chegewara
@chegewara
freertos is required for ets_printf
for some reason regular printfdoes not work
atanisoft
@atanisoft
one sec
pull that repo content
chegewara
@chegewara
i fixed it:
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "main.h"
DEFAULT_CONST(foo, 3)
void blink_task3()
{
    ets_printf("\r\nstart 3\r\n");

}
atanisoft
@atanisoft
ok
chegewara
@chegewara
but output is strange:
start 1
value 2
typeof int
false

start 2
value 2
typeof int
false

start 3
DEFAULT_CONST is not working, or im not using it correct way
atanisoft
@atanisoft
you have OVERRIDE_CONST still in there
comment it out
chegewara
@chegewara
yes, figured it out
ok, result is consistent with yours:
start 1
value 1
typeof int
false

start 2
value 1
typeof int
false

start 3
atanisoft
@atanisoft
yeah, it is very odd
still not 100% sure why 1 == 1 fails
chegewara
@chegewara
and typeof value is INT as you can see, so my theory is wrong about float
atanisoft
@atanisoft
it is a bug of some sort in the compiler
it is optimizing it poorly in the asm
chegewara
@chegewara
wait
Ben
@bzeeman
Iā€™m waiting
atanisoft
@atanisoft
also note that enabling NEED_SIMPLE_CONST will fix it as well but generates other compiler warnings
chegewara
@chegewara
start 1
value 1
typeof int
ā›[0;32mI (2247) TAG: 01 00 00 00 ā›[0m

true

start 2
value 1
typeof int
false

start 3
success
atanisoft
@atanisoft
what did you change
chegewara
@chegewara
this small change "fixes" it:
void blink_task()
{
    ets_printf("start 1\r\n");
    ets_printf("value %d\r\ntypeof ", config_foo()); 

    ets_printf(typename(config_foo())); 
    int a = (int)config_foo();
    ets_printf("\r\n");
    ESP_LOG_BUFFER_HEX("TAG", &a, sizeof(a));
    if (a == 1) 
    { 
        ets_printf("\r\ntrue\r\n"); 
    } 
    else 
    { 
        ets_printf("\r\nfalse\r\n"); 
    }
}
add ESP_LOG_BUFFER_HEX
atanisoft
@atanisoft
ahh, you added explicit cast
chegewara
@chegewara
no, cast did not fix it
this did ESP_LOG_BUFFER_HEX
atanisoft
@atanisoft
and a local var
chegewara
@chegewara
without ESP_LOG_BUFFER_HEX casting and/or local variable did not change anything
but it still works without casting to int with ESP_LOG_BUFFER_HEX
atanisoft
@atanisoft
very odd
there must be some sort of compiler optimization going on
is also isn't the first time we've seen odd behavior on the esp32
chegewara
@chegewara
this is even more odd, another variation, did not work:
ets_printf("start 1\r\n");
    ets_printf("value %d\r\ntypeof ", config_foo()); 

    ets_printf(typename(config_foo())); 
    int a = config_foo();
    ets_printf("\r\n");
    ESP_LOGI("TAG", "%d", a);
    if (a == 1) 
    { 
        ets_printf("\r\ntrue\r\n"); 
    } 
    else 
    { 
        ets_printf("\r\nfalse\r\n"); 
    }
changing ESP_LOG_BUFFER_HEX with ESP_LOGI and back to error
so, making local variable and accessing it with reference fixing that bug
atanisoft
@atanisoft
the question is why
there is a lot of code in the lib that do similar checks for constants without a local var
and some that pass in the constant as a function param and it works fine there
chegewara
@chegewara
you have to ask smart people, i am only smartass
atanisoft
@atanisoft
right there with you on that one :)
I have no clue why one works and the other doesn't
chegewara
@chegewara

you can play with this:

    int a = config_foo();
    ESP_LOG_BUFFER_HEX_LEVEL("TAG", &a, 4, ESP_LOG_NONE);
    if (a == 1)

when log level is high enough to print value it works, when is low and cant print it then its false

now you can attack devs with issue
lbernstone
@lbernstone
@chegewara Better a smartass than a dumbass :smile:
William Gaylord
@wgaylord
Any idea why on some docs or examples people are setting WiFi to channel 0? (Which is technically not existing and also part of a Ham band.)