我正在使用这个库(https://github.com/SensorsIot/Sonoff-POW)并且它工作得非常好,但是我不时会得到一个异常并且sonoff重新启动。
我已经实现了一个简单的草图,它读取功率值并使用webclient发送它们。 webclient部件在没有POWER代码的情况下工作正常,因此我认为它可能与POWER库中的中断有关
这是串口监视器中显示的堆栈错误...
连接到xxxxx.xxx.me
Exception 0: Illegal instruction
Decoding 29 results
0x402034f4: ESP8266PowerClass::measureVoltageFreq() at C:\Users\Sergio\Documents\SERGIO\libraries\Sonoff_POW-master/power.cpp line 294
0x40107018: interrupt_handler at C:\Users\Sergio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/core_esp8266_wiring_digital.c line 119
0x4010177d: ppEnqueueRxq at ?? line ?
0x40101433: ppProcessTxQ at ?? line ?
0x40106fe0: interrupt_handler at C:\Users\Sergio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/core_esp8266_wiring_digital.c line 113
0x40103d19: lmacProcessTXStartData at ?? line ?
0x4010707c: interrupt_handler at C:\Users\Sergio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/core_esp8266_wiring_digital.c line 135
0x401055c1: ets_timer_disarm at ?? line ?
0x40106fe0: interrupt_handler at C:\Users\Sergio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/core_esp8266_wiring_digital.c line 113
0x4020954c: pm_get_sleep_type at ?? line ?
0x40105b26: spi_flash_read at ?? line ?
0x401074b8: pvPortZalloc at C:\Users\Sergio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/heap.c line 33
0x4020901d: pm_set_sleep_time at ?? line ?
0x402094b2: pm_get_sleep_type at ?? line ?
0x4020955f: pm_get_sleep_type at ?? line ?
0x4021ac3d: ets_timer_handler_isr at ?? line ?
0x4021ac82: ets_timer_handler_isr at ?? line ?
重启总是在以下代码中发生:
Serial.print("connecting to ");
Serial.print(host);
// Use WiFiClient class to create TCP connections
WiFiClient client;
// const int httpPort = 80;
if (!client.connect(host, httpPort)) {
Serial.println("....connection failed");
return;
}
Serial.println("....connected!");
在我看到"连接到主机"的串口中的打印之后。消息,但我没有得到打印"已连接。"
在" client.connect"中,图书馆是否有可能做某事。这导致异常:
异常原因(EXCCAUSE)EXCCAUSE代码原因名称原因 描述必需选项EXCVADDR已加载
0 IllegalInstructionCause非法指令异常否
我不希望对整个图书馆进行审核,但可能会就这可能发生的原因提供一些指导。 也许我可以在客户端请求期间分离中断? 也许实现一些代码来停止这个计时器,然后再次调用它? (我不知道该怎么做)
从库中提取:
void ESP8266PowerClass::startMeasure(void)
{
os_timer_setfn(&myTimer, (os_timer_func_t *)&ESP8266PowerClass::timerCallback, NULL);
os_timer_arm(&myTimer, 1, true); // every ms
}
谢谢你的帮助