Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watchdog trigger changes #208

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

pennam
Copy link
Contributor

@pennam pennam commented Jan 13, 2022

I'm opening this PR to have a bit of discussion since i'm not 100% sure of the changes:

  • 162049a with the original code the wdog is triggered continously for 10 seconds without delays. Considering a wdog window of 32 seconds i've changed the code in order to kik the wdog each 10 seconds .

  • a37d350 since the wdog is triggered only if the callback is configured i think we can safely remove the check on feed_watchdog and always trigger the wdog if the callback is correctly configured in the library. This change will also extend the wdog trigger to all SpiDrv::waitForSlaveReady() calls. I have not experienced any drawback doing this, but propably is too much... if we want to drop this change we need to extend the wdog trig at least to ServerDrv::getClientState since i've seen some wdog resets also in this function.

  • 51590db I don't have an explanation for this, but i've noticed that without this delay sometimes the board gets stuck in this while loop, maybe is related to the fact digitalRead is not a real digital read, but is implemented as spi command...

@github-actions
Copy link

Memory usage change @ 51590db

Board flash % RAM for global variables %
arduino:mbed_nano:nanorp2040connect 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:megaavr:uno2018:mode=on ❔ -54 - +98 -0.11 - +0.2 0 - 0 0.0 - 0.0
arduino:samd:mkrvidor4000 💚 -84 - 0 -0.03 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrwifi1010 💚 -84 - 0 -0.03 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:nano_33_iot 💚 -84 - 0 -0.03 - 0.0 0 - 0 0.0 - 0.0
Click for full report table
Board examples/AP_SimpleWebServer
flash
% examples/AP_SimpleWebServer
RAM for global variables
% examples/ConnectNoEncryption
flash
% examples/ConnectNoEncryption
RAM for global variables
% examples/ConnectWithWEP
flash
% examples/ConnectWithWEP
RAM for global variables
% examples/ConnectWithWPA
flash
% examples/ConnectWithWPA
RAM for global variables
% examples/ConnectWithWPA2Enterprise
flash
% examples/ConnectWithWPA2Enterprise
RAM for global variables
% examples/ScanNetworks
flash
% examples/ScanNetworks
RAM for global variables
% examples/ScanNetworksAdvanced
flash
% examples/ScanNetworksAdvanced
RAM for global variables
% examples/SimpleWebServerWiFi
flash
% examples/SimpleWebServerWiFi
RAM for global variables
% examples/Tools/CheckFirmwareVersion
flash
% examples/Tools/CheckFirmwareVersion
RAM for global variables
% examples/Tools/FirmwareUpdater
flash
% examples/Tools/FirmwareUpdater
RAM for global variables
% examples/Tools/SerialNINAPassthrough
flash
% examples/Tools/SerialNINAPassthrough
RAM for global variables
% examples/WiFiChatServer
flash
% examples/WiFiChatServer
RAM for global variables
% examples/WiFiPing
flash
% examples/WiFiPing
RAM for global variables
% examples/WiFiSSLClient
flash
% examples/WiFiSSLClient
RAM for global variables
% examples/WiFiStorage
flash
% examples/WiFiStorage
RAM for global variables
% examples/WiFiUdpNtpClient
flash
% examples/WiFiUdpNtpClient
RAM for global variables
% examples/WiFiUdpSendReceiveString
flash
% examples/WiFiUdpSendReceiveString
RAM for global variables
% examples/WiFiWebClient
flash
% examples/WiFiWebClient
RAM for global variables
% examples/WiFiWebClientRepeating
flash
% examples/WiFiWebClientRepeating
RAM for global variables
% examples/WiFiWebServer
flash
% examples/WiFiWebServer
RAM for global variables
%
arduino:mbed_nano:nanorp2040connect 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:megaavr:uno2018:mode=on -50 -0.1 0 0.0 98 0.2 0 0.0 98 0.2 0 0.0 98 0.2 0 0.0 98 0.2 0 0.0 58 0.12 0 0.0 58 0.12 0 0.0 -54 -0.11 0 0.0 58 0.12 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 -54 -0.11 0 0.0 98 0.2 0 0.0 -46 -0.09 0 0.0 58 0.12 0 0.0 98 0.2 0 0.0 98 0.2 0 0.0 -46 -0.09 0 0.0 -46 -0.09 0 0.0 -54 -0.11 0 0.0
arduino:samd:mkrvidor4000 -80 -0.03 0 0.0 -28 -0.01 0 0.0 -28 -0.01 0 0.0 -28 -0.01 0 0.0 -28 -0.01 0 0.0 -20 -0.01 0 0.0 -28 -0.01 0 0.0 -84 -0.03 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 -84 -0.03 0 0.0 -40 -0.02 0 0.0 -76 -0.03 0 0.0 0 0.0 0 0.0 -64 -0.02 0 0.0 -64 -0.02 0 0.0 -76 -0.03 0 0.0 -76 -0.03 0 0.0 -84 -0.03 0 0.0
arduino:samd:mkrwifi1010 -80 -0.03 0 0.0 -28 -0.01 0 0.0 -28 -0.01 0 0.0 -28 -0.01 0 0.0 -28 -0.01 0 0.0 -20 -0.01 0 0.0 -28 -0.01 0 0.0 -84 -0.03 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 -84 -0.03 0 0.0 -40 -0.02 0 0.0 -76 -0.03 0 0.0 0 0.0 0 0.0 -64 -0.02 0 0.0 -64 -0.02 0 0.0 -76 -0.03 0 0.0 -76 -0.03 0 0.0 -84 -0.03 0 0.0
arduino:samd:nano_33_iot -80 -0.03 0 0.0 -28 -0.01 0 0.0 -28 -0.01 0 0.0 -28 -0.01 0 0.0 -28 -0.01 0 0.0 -20 -0.01 0 0.0 -28 -0.01 0 0.0 -84 -0.03 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 -84 -0.03 0 0.0 -40 -0.02 0 0.0 -76 -0.03 0 0.0 0 0.0 0 0.0 -64 -0.02 0 0.0 -64 -0.02 0 0.0 -76 -0.03 0 0.0 -76 -0.03 0 0.0 -84 -0.03 0 0.0
Click for full report CSV
Board,examples/AP_SimpleWebServer<br>flash,%,examples/AP_SimpleWebServer<br>RAM for global variables,%,examples/ConnectNoEncryption<br>flash,%,examples/ConnectNoEncryption<br>RAM for global variables,%,examples/ConnectWithWEP<br>flash,%,examples/ConnectWithWEP<br>RAM for global variables,%,examples/ConnectWithWPA<br>flash,%,examples/ConnectWithWPA<br>RAM for global variables,%,examples/ConnectWithWPA2Enterprise<br>flash,%,examples/ConnectWithWPA2Enterprise<br>RAM for global variables,%,examples/ScanNetworks<br>flash,%,examples/ScanNetworks<br>RAM for global variables,%,examples/ScanNetworksAdvanced<br>flash,%,examples/ScanNetworksAdvanced<br>RAM for global variables,%,examples/SimpleWebServerWiFi<br>flash,%,examples/SimpleWebServerWiFi<br>RAM for global variables,%,examples/Tools/CheckFirmwareVersion<br>flash,%,examples/Tools/CheckFirmwareVersion<br>RAM for global variables,%,examples/Tools/FirmwareUpdater<br>flash,%,examples/Tools/FirmwareUpdater<br>RAM for global variables,%,examples/Tools/SerialNINAPassthrough<br>flash,%,examples/Tools/SerialNINAPassthrough<br>RAM for global variables,%,examples/WiFiChatServer<br>flash,%,examples/WiFiChatServer<br>RAM for global variables,%,examples/WiFiPing<br>flash,%,examples/WiFiPing<br>RAM for global variables,%,examples/WiFiSSLClient<br>flash,%,examples/WiFiSSLClient<br>RAM for global variables,%,examples/WiFiStorage<br>flash,%,examples/WiFiStorage<br>RAM for global variables,%,examples/WiFiUdpNtpClient<br>flash,%,examples/WiFiUdpNtpClient<br>RAM for global variables,%,examples/WiFiUdpSendReceiveString<br>flash,%,examples/WiFiUdpSendReceiveString<br>RAM for global variables,%,examples/WiFiWebClient<br>flash,%,examples/WiFiWebClient<br>RAM for global variables,%,examples/WiFiWebClientRepeating<br>flash,%,examples/WiFiWebClientRepeating<br>RAM for global variables,%,examples/WiFiWebServer<br>flash,%,examples/WiFiWebServer<br>RAM for global variables,%
arduino:mbed_nano:nanorp2040connect,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino:megaavr:uno2018:mode=on,-50,-0.1,0,0.0,98,0.2,0,0.0,98,0.2,0,0.0,98,0.2,0,0.0,98,0.2,0,0.0,58,0.12,0,0.0,58,0.12,0,0.0,-54,-0.11,0,0.0,58,0.12,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,-54,-0.11,0,0.0,98,0.2,0,0.0,-46,-0.09,0,0.0,58,0.12,0,0.0,98,0.2,0,0.0,98,0.2,0,0.0,-46,-0.09,0,0.0,-46,-0.09,0,0.0,-54,-0.11,0,0.0
arduino:samd:mkrvidor4000,-80,-0.03,0,0.0,-28,-0.01,0,0.0,-28,-0.01,0,0.0,-28,-0.01,0,0.0,-28,-0.01,0,0.0,-20,-0.01,0,0.0,-28,-0.01,0,0.0,-84,-0.03,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,-84,-0.03,0,0.0,-40,-0.02,0,0.0,-76,-0.03,0,0.0,0,0.0,0,0.0,-64,-0.02,0,0.0,-64,-0.02,0,0.0,-76,-0.03,0,0.0,-76,-0.03,0,0.0,-84,-0.03,0,0.0
arduino:samd:mkrwifi1010,-80,-0.03,0,0.0,-28,-0.01,0,0.0,-28,-0.01,0,0.0,-28,-0.01,0,0.0,-28,-0.01,0,0.0,-20,-0.01,0,0.0,-28,-0.01,0,0.0,-84,-0.03,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,-84,-0.03,0,0.0,-40,-0.02,0,0.0,-76,-0.03,0,0.0,0,0.0,0,0.0,-64,-0.02,0,0.0,-64,-0.02,0,0.0,-76,-0.03,0,0.0,-76,-0.03,0,0.0,-84,-0.03,0,0.0
arduino:samd:nano_33_iot,-80,-0.03,0,0.0,-28,-0.01,0,0.0,-28,-0.01,0,0.0,-28,-0.01,0,0.0,-28,-0.01,0,0.0,-20,-0.01,0,0.0,-28,-0.01,0,0.0,-84,-0.03,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,-84,-0.03,0,0.0,-40,-0.02,0,0.0,-76,-0.03,0,0.0,0,0.0,0,0.0,-64,-0.02,0,0.0,-64,-0.02,0,0.0,-76,-0.03,0,0.0,-76,-0.03,0,0.0,-84,-0.03,0,0.0

@per1234 per1234 added the topic: code Related to content of the project itself label Jan 15, 2022
if ((millis() - start) < 10000) {
WiFi.feedWatchdog();
}
if (static_cast<int32_t>(trigger_time - millis()) <=0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I see your point. However, can't it be written in a simplified way without needing to cast to int32_t? Something along the lines of

unsigned long start = millis();
/* ... */
if(feed_watchdog)
{
  unsigned long const now = millis();  
  if(now - start > 10000)
  {
    WiFi.feedWatchdog();
    start = now;
  }
}

?
Also feed_watchdog is there for purpose, only the BearSSL offloaded SSL calls take longe enough to warrant feeding the watchdog outside of update().

khoih-prog added a commit to khoih-prog/WiFiNINA_Generic that referenced this pull request May 2, 2022
### Releases v1.8.14-4

1. Fix bugs by using some unmerged PRs from original WiFiNINA, such as:

 - [WiFi.config - setting defaults as the Ethernet library #219](arduino-libraries/WiFiNINA#219)
 - [Fix WiFiClient watchdog usage #211](arduino-libraries/WiFiNINA#211)
 - [Watchdog trigger changes #208](arduino-libraries/WiFiNINA#208)
 - [added server.accept() #204](arduino-libraries/WiFiNINA#204)
 - [Fix PinStatus error on some platforms #185](arduino-libraries/WiFiNINA#185)
 
2. Add many WiFiMulti-related examples in [WiFiMulti](https://github.com/khoih-prog/WiFiNINA_Generic/tree/master/examples/WiFiMulti)
3. Update examples
4. Update `Packages' Patches`
khoih-prog added a commit to khoih-prog/WiFiNINA_Generic that referenced this pull request May 2, 2022
### Releases v1.8.14-4

1. Fix bugs by using some unmerged PRs from original WiFiNINA, such as:

 - [WiFi.config - setting defaults as the Ethernet library #219](arduino-libraries/WiFiNINA#219)
 - [Fix WiFiClient watchdog usage #211](arduino-libraries/WiFiNINA#211)
 - [Watchdog trigger changes #208](arduino-libraries/WiFiNINA#208)
 - [added server.accept() #204](arduino-libraries/WiFiNINA#204)
 - [Fix PinStatus error on some platforms #185](arduino-libraries/WiFiNINA#185)
 
2. Add many WiFiMulti-related examples in [WiFiMulti](https://github.com/khoih-prog/WiFiNINA_Generic/tree/master/examples/WiFiMulti)
3. Update examples
4. Update `Packages' Patches`
khoih-prog added a commit to khoih-prog/WiFiNINA_Generic that referenced this pull request May 2, 2022
### Releases v1.8.14-4

1. Fix bugs by using some unmerged PRs from original WiFiNINA, such as:

 - [WiFi.config - setting defaults as the Ethernet library #219](arduino-libraries/WiFiNINA#219)
 - [Fix WiFiClient watchdog usage #211](arduino-libraries/WiFiNINA#211)
 - [Watchdog trigger changes #208](arduino-libraries/WiFiNINA#208)
 - [added server.accept() #204](arduino-libraries/WiFiNINA#204)
 - [Fix PinStatus error on some platforms #185](arduino-libraries/WiFiNINA#185)
 
2. Add many WiFiMulti-related examples in [WiFiMulti](https://github.com/khoih-prog/WiFiNINA_Generic/tree/master/examples/WiFiMulti)
3. Update examples
4. Update `Packages' Patches`
@per1234 per1234 added the type: enhancement Proposed improvement label Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants