esp8266 / source-code-examples

Examples of code for the ESP8266
275 stars 127 forks source link

I dont think the basic example never reaches the loop method #1

Closed fasmide closed 9 years ago

fasmide commented 9 years ago

Hi

Is the loop method meant to be running along kind of like the arduino's main loop?

Ive tried modifying the basic example, adding some output but also increased the os_delay_us to not block the serial connection completely

#include "ets_sys.h"
#include "osapi.h"
#include "gpio.h"
#include "os_type.h"
#include "user_config.h"
#include "user_interface.h"

#define user_procTaskPrio        0
#define user_procTaskQueueLen    1
os_event_t    user_procTaskQueue[user_procTaskQueueLen];
static void loop(os_event_t *events);

//Main code function
static void ICACHE_FLASH_ATTR
loop(os_event_t *events)
{
    os_printf("loop\r\n");
    os_delay_us(1000000);

}

//Init function 
void ICACHE_FLASH_ATTR
user_init()
{
    char ssid[32] = SSID;
    char password[64] = SSID_PASSWORD;
    struct station_config stationConf;

    //Set station mode
    wifi_set_opmode( 0x1 );

    //Set ap settings
    os_memcpy(&stationConf.ssid, ssid, 32);
    os_memcpy(&stationConf.password, password, 32);
    wifi_station_set_config(&stationConf);

    //Start os task
    system_os_task(loop, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen);
    os_printf("Prepped\r\n");
}

Ive only added the os_printf lines, it produces this on poweron:

 ets Jan  8 2013,rst cause:1, boot mode:(3,7)

load 0x40100000, len 23156, room 16 
tail 4
chksum 0xea
load 0x3ffe8000, len 2644, room 4 
tail 0
chksum 0x4e
load 0x3ffe8a60, len 3352, room 8 
tail 0
chksum 0x0c
csum 0x0c
Prepped
mode : sta(18:fe:34:99:23:db)
add if0
scandone
add 0
aid 3
pm open phy2,type:2 0 0
cnt 

connected with xyz, channel 6
dhcp client start...
ip:192.168.1.5,mask:255.255.255.0,gw:192.168.1.1

Notice how it does print out Prepped but not loop, it does connect to wifi and responds to icmp ping requests just fine - but that loop method never seems to be called.

themindfactory commented 9 years ago

You need to post these type questions on esp8266.com

Thanks.

On Wed, Nov 5, 2014 at 5:50 PM, Kristian Mide notifications@github.com wrote:

Hi

Is the loop method meant to be running along kind of like the arduino's main loop?

Ive tried modifying the basic example, adding some output but also increased the os_delay_us to not block the serial connection completely

include "ets_sys.h"

include "osapi.h"

include "gpio.h"

include "os_type.h"

include "user_config.h"

include "user_interface.h"

define user_procTaskPrio 0

define user_procTaskQueueLen 1os_event_t user_procTaskQueue[user_procTaskQueueLen];static void loop(os_event_t *events);

//Main code functionstatic void ICACHE_FLASH_ATTRloop(os_event_t *events) { os_printf("loop\r\n"); os_delay_us(1000000);

} //Init function void ICACHE_FLASH_ATTRuser_init() { char ssid[32] = SSID; char password[64] = SSID_PASSWORD; struct station_config stationConf;

//Set station mode
wifi_set_opmode( 0x1 );

//Set ap settings
os_memcpy(&stationConf.ssid, ssid, 32);
os_memcpy(&stationConf.password, password, 32);
wifi_station_set_config(&stationConf);

//Start os task
system_os_task(loop, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen);
os_printf("Prepped\r\n");

}

Ive only added the os_printf lines, it produces this on poweron:

ets Jan 8 2013,rst cause:1, boot mode:(3,7)

load 0x40100000, len 23156, room 16 tail 4 chksum 0xea load 0x3ffe8000, len 2644, room 4 tail 0 chksum 0x4e load 0x3ffe8a60, len 3352, room 8 tail 0 chksum 0x0c csum 0x0c Prepped mode : sta(18:fe:34:99:23:db) add if0 scandone add 0 aid 3 pm open phy2,type:2 0 0 cnt

connected with xyz, channel 6 dhcp client start... ip:192.168.1.5,mask:255.255.255.0,gw:192.168.1.1

Notice how it does print out Prepped but not loop, it does connect to wifi and responds to icmp ping requests just fine - but that loop method never seems to be called.

— Reply to this email directly or view it on GitHub https://github.com/esp8266/source-code-examples/issues/1.

zarya commented 9 years ago

Fasmide, i will look in to that.

zarya commented 9 years ago

Fixed the problem

fasmide commented 9 years ago

Great ill try the updated example later today...

Sorry if i posted this the wrong place it seemed appropriate

zarya commented 9 years ago

@Fasmide i aggree with you this was the right place

@themindfactory Its hard to keep track of all the stuff on the forum so please let the bugs to the code in github be reported in github else i wont be able to keep track.

fasmide commented 9 years ago

Its at 74880 if i remember correctly On 17 Nov 2014 13:15, "Wouter Van Vlaenderen" notifications@github.com wrote:

ets Jan 8 2013,rst cause:1, boot mode:(3,7)

load 0x40100000, len 23156, room 16 tail 4 chksum 0xea load 0x3ffe8000, len 2644, room 4 tail 0 chksum 0x4e load 0x3ffe8a60, len 3352, room 8 tail 0 chksum 0x0c csum 0x0c Prepped mode : sta(18:fe:34:99:23:db) add if0 scandone add 0 aid 3 pm open phy2,type:2 0 0 cnt

connected with xyz, channel 6 dhcp client start... ip:192.168.1.5,mask:255.255.255.0,gw:192.168.1.1

How did you get to this output? Using what baudrates?

— Reply to this email directly or view it on GitHub https://github.com/esp8266/source-code-examples/issues/1#issuecomment-63296556 .