C++ Arduino ESP8266 函数给出了一个异常,但是 运行 同样直接在循环中工作正常
C++ Arduino ESP8266 fucntion gives an exception, but running the same directly in loop works fine
我编写的函数应该发出 url 请求。
功能:
int updateX(float x)
{
if(WiFi.status() == WL_CONNECTED)
{
WiFiClient client;
HTTPClient http;
String sendStr = "192.168.1.1/updateXdeg?xDegVal="+String(x);
http.begin(client, sendStr);
int httpCode = http.GET();
http.end();
}
else
{
Serial.println("Wifi disconnected");
}
}
当我在主循环中执行函数时出现异常 0
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
Exception (0):
epc1=0x40201145 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
>>>stack>>>
ctx: cont
sp: 3ffffc70 end: 3fffffc0 offset: 0190
3ffffe00: 3fffdad0 00000000 41b1999a 40201138
3ffffe10: 00000000 00000000 60831200 00000000
3ffffe20: 3f010000 00001388 00000000 40212205
3ffffe30: 00000000 00000000 00001a24 00000000
3ffffe40: 00000000 00000430 00000000 00000000
3ffffe50: 0011001f 00000000 00000000 4020fdb5
3ffffe60: 00000000 00000000 00000000 00000000
3ffffe70: ffffffff 000e0000 00000000 3ffe000a
3ffffe80: 00000000 00000020 00000000 00000000
3ffffe90: 00000000 40207dec 00000000 00001388
3ffffea0: 3fffdad0 00000000 00000000 00000000
3ffffeb0: 00000000 00000000 0024002f 00000000
3ffffec0: 00000000 0024002f 00000000 40201b60
3ffffed0: 3fffdad0 00000000 3ffee614 402011e7
3ffffee0: 3fffff64 00000000 000b000f 00000000
3ffffef0: ff010050 fe001388 00000000 0015001f
3fffff00: 00000000 00000000 00000000 00000000
3fffff10: 00000000 0000001f 00000000 00000000
3fffff20: 0011001f 00000000 00000000 40205db4
3fffff30: 00000000 00000000 00000000 00000000
3fffff40: ffffffff 18b2b801 00000000 3ffe000a
3fffff50: 00000000 3ffe8848 00000000 00000000
3fffff60: 00000000 40207dec 00000000 00001388
3fffff70: 000010e1 00000000 00000000 3ffef41c
3fffff80: 00000000 00000000 002a002f 00000000
3fffff90: 00000000 002a002f 00000000 402010a2
3fffffa0: feefeffe 00000000 3ffee614 40204bb8
3fffffb0: feefeffe feefeffe 3ffe85d8 40100b51
<<<stack<<<
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
这是解码后的堆栈结果:
0x40201138: updateX(float) at C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266.0.2\cores\esp8266/WString.h line 79
0x40212205: tcp_enqueue_flags at core/tcp_out.c line 1085
0x4020fdb5: tcp_close_shutdown_fin at core/tcp.c line 448
0x40201b60: WiFiClient::~WiFiClient() at C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266.0.2\libraries\ESP8266WiFi\src\WiFiClient.cpp line 101
0x40205db4: uart_write(uart_t*, char const*, size_t) at C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266.0.2\cores\esp8266\uart.cpp line 546
0x402010a2: setup() at C:\Users\User\OneDrive - sluz\Dokumente\Arduino\sketch_jan19b/sketch_jan19b.ino line 28
0x40204bb8: loop_wrapper() at C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266.0.2\cores\esp8266\core_esp8266_main.cpp line 201
当我 运行 直接在主循环中使用来自 updateX 函数的相同代码时,它工作得很好。
我的函数被声明为 return 一个整数,但我没有 return 任何东西。
我编写的函数应该发出 url 请求。
功能:
int updateX(float x)
{
if(WiFi.status() == WL_CONNECTED)
{
WiFiClient client;
HTTPClient http;
String sendStr = "192.168.1.1/updateXdeg?xDegVal="+String(x);
http.begin(client, sendStr);
int httpCode = http.GET();
http.end();
}
else
{
Serial.println("Wifi disconnected");
}
}
当我在主循环中执行函数时出现异常 0
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
Exception (0):
epc1=0x40201145 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
>>>stack>>>
ctx: cont
sp: 3ffffc70 end: 3fffffc0 offset: 0190
3ffffe00: 3fffdad0 00000000 41b1999a 40201138
3ffffe10: 00000000 00000000 60831200 00000000
3ffffe20: 3f010000 00001388 00000000 40212205
3ffffe30: 00000000 00000000 00001a24 00000000
3ffffe40: 00000000 00000430 00000000 00000000
3ffffe50: 0011001f 00000000 00000000 4020fdb5
3ffffe60: 00000000 00000000 00000000 00000000
3ffffe70: ffffffff 000e0000 00000000 3ffe000a
3ffffe80: 00000000 00000020 00000000 00000000
3ffffe90: 00000000 40207dec 00000000 00001388
3ffffea0: 3fffdad0 00000000 00000000 00000000
3ffffeb0: 00000000 00000000 0024002f 00000000
3ffffec0: 00000000 0024002f 00000000 40201b60
3ffffed0: 3fffdad0 00000000 3ffee614 402011e7
3ffffee0: 3fffff64 00000000 000b000f 00000000
3ffffef0: ff010050 fe001388 00000000 0015001f
3fffff00: 00000000 00000000 00000000 00000000
3fffff10: 00000000 0000001f 00000000 00000000
3fffff20: 0011001f 00000000 00000000 40205db4
3fffff30: 00000000 00000000 00000000 00000000
3fffff40: ffffffff 18b2b801 00000000 3ffe000a
3fffff50: 00000000 3ffe8848 00000000 00000000
3fffff60: 00000000 40207dec 00000000 00001388
3fffff70: 000010e1 00000000 00000000 3ffef41c
3fffff80: 00000000 00000000 002a002f 00000000
3fffff90: 00000000 002a002f 00000000 402010a2
3fffffa0: feefeffe 00000000 3ffee614 40204bb8
3fffffb0: feefeffe feefeffe 3ffe85d8 40100b51
<<<stack<<<
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
这是解码后的堆栈结果:
0x40201138: updateX(float) at C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266.0.2\cores\esp8266/WString.h line 79
0x40212205: tcp_enqueue_flags at core/tcp_out.c line 1085
0x4020fdb5: tcp_close_shutdown_fin at core/tcp.c line 448
0x40201b60: WiFiClient::~WiFiClient() at C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266.0.2\libraries\ESP8266WiFi\src\WiFiClient.cpp line 101
0x40205db4: uart_write(uart_t*, char const*, size_t) at C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266.0.2\cores\esp8266\uart.cpp line 546
0x402010a2: setup() at C:\Users\User\OneDrive - sluz\Dokumente\Arduino\sketch_jan19b/sketch_jan19b.ino line 28
0x40204bb8: loop_wrapper() at C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266.0.2\cores\esp8266\core_esp8266_main.cpp line 201
当我 运行 直接在主循环中使用来自 updateX 函数的相同代码时,它工作得很好。
我的函数被声明为 return 一个整数,但我没有 return 任何东西。