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

Add support for the ESP8266 env. Fix headers in readme. #57

Closed
wants to merge 3 commits into from
Closed

Add support for the ESP8266 env. Fix headers in readme. #57

wants to merge 3 commits into from

Conversation

crankyoldgit
Copy link
Contributor

@crankyoldgit crankyoldgit commented May 8, 2017

Initial support for the ESP8266 env.:

  • PROGMEM doesn't really make sense in ESP land.
  • Sprinkle yield()s in likely spots to reduce the Watch Dog timer firing.
    This happened regularly on the advanced.ino example.
    That is, the ESP module will fire the software Watch Dog timer if it isn't fed approximately ever second or so. delay(), wdt_reset(), or yield()'s will feed it.
  • Remove some trailing white space (thanks to my IDE)

Fixes #55

readme.md:

  • A white space is needed after '#' headings for them to work. Fixed malformed headings.

[Tested using basic.ino & advanced.ino. They seem to run as expected.]

crankyoldgit and others added 2 commits May 8, 2017 17:31
- PROGMEM doesn't really make sense in ESP land.
- Sprinkle yield()s in likely spots to reduce the Watch Dog timer firing.
  This happened regularly on the advanced.ino example.

[Tested using basic.ino & advanced.ino. They seem to run as expected.]
A white space is needed after '#' headings for them to work. Fixed malformed headings.
@crankyoldgit crankyoldgit mentioned this pull request May 8, 2017
@wmacevoy
Copy link
Collaborator

Sorry I have not looked at this sooner. I don't see how the changes can break the standard arduino platforms, but I cant test these on the ESP. Are you willing to support the ESP changes going forward? If so, merging seems like a good idea.

@crankyoldgit
Copy link
Contributor Author

crankyoldgit commented Jul 27, 2017 via email

@wmacevoy
Copy link
Collaborator

Ok I have looked more carefully at your code. If yeilds are necessary frequently I think there are better places for it. Instead of adding yeild inside the isLess functions (there are a lot of them, and these have grown in other branches), define the assertOp to have the yeild instead, this is more generic and covers all the other cases. Similarly, instead of placing the yeild in resolve, put it after line 234 in the run() method, which calls the others.

Can you please see if this works? If it does it should be easier to maintain.

@crankyoldgit
Copy link
Contributor Author

SGTM, I'll take a look later.
Basically, the watchdog timer on the esp8266 needs to be fed frequently (at least once per second) else the board will reset. The more common/frequent the operation that does a yield() or delay() etc, the better.

@wmacevoy
Copy link
Collaborator

On second thought; maybe just strip the yield method. Having it part of every assert makes testing the watchdog hard on that platform, but add a section suggesting a yield at the end of every test. Turning off testing should have as few side effects as possible.

1 similar comment
@wmacevoy
Copy link
Collaborator

On second thought; maybe just strip the yield method. Having it part of every assert makes testing the watchdog hard on that platform, but add a section suggesting a yield at the end of every test. Turning off testing should have as few side effects as possible.

@wmacevoy wmacevoy closed this Jul 31, 2017
@wmacevoy wmacevoy reopened this Jul 31, 2017
@crankyoldgit
Copy link
Contributor Author

crankyoldgit commented Aug 1, 2017

I see your point, but that's a fairly a-typical use case. It would be by far a less likely use case. In another OS etc, you wouldn't expect to be feeding the OS watch dog etc in a unit test. Given the nature of these AVR-esque devices, we effectively are the OS.

If you wanted to test the watchdog, you could construct a test-case such that it waits the appropriate time without feeding it (e.g. 1 sec, without deliberate feeding, delay()s, or yield()s) So, its easy to still test for it.

Given the watchdog causes a device reset, it's kind of out of the scope of a simple unit test. i.e. You are not likely to catch it in an exception etc.

Perhaps a better approach would be to have it configurable. Defaulting to feeding it, as that's the desired and expected case. However, I think that is unnecessary.
i.e. The unit tests themselves shouldn't be a test of the watchdog timer as a side-effect.

For a typical use case/example:

Assume the watchdog causes a reset/reboot after 1 sec (1000ms) of no feeding.

If I'm testing a function, that takes say 100ms to finish. And I happen to call it 10+ times in a unit test I'm not really testing if the an individual instance of a function call itself exceeds the watch dog timer (WDT). I'm not thinking about it if I have a number of asserts in my unit tests etc.
However, if my function call does take longer than 1000ms, and with our suggested code, the WDT would trigger, and hence the test would implicitly fail. That's something we'd want to detect. So, feeding the WDT in an expect/assert call really isn't an issue, IMHO.

Having people code around a property of the OS in a unit test is just yuck IMHO. Especially as it is the majority use case.

@wmacevoy
Copy link
Collaborator

Ok this has an alternate merge #58 with an arguably partly more correct solution and supports another board. It does not add yield and there is a philosophy problem there, which is why this has taken a long time to resolve. I think there should be a yield between tests, since AU has control over running multiple tests the user cannot easily influence. But adding yields at every assert I think breaks orthogonality; something you think passes a tests actually does not work on the tested platform because it takes too long to perform.

Between this, #58 and these ideas I think there is a good update.

@ssilverman
Copy link
Contributor

Should this line: #define typeof(x) __typeof__(x)
be inside the #ifdef ESP8266 section?

@crankyoldgit
Copy link
Contributor Author

@ssilverman I think you are correct. It's was too long ago for me to remember why it was outside of that block in the first place. Probably human error. Moved.
However, I believe it's a moot point as I think this PR is a dead-end as the project has gone down another path for ESP support.

@wmacevoy
Copy link
Collaborator

Ok, branch iss58 includes, I think, the changes to support ESP 8266 and ESP 32. Can someone please verify that? I don't have these boards.

@wmacevoy
Copy link
Collaborator

iss58 changes the way these are implemented: Compare.h is auto-generated (in meta), and so I edited the generator for Compare instead. And since __typeof__ is more portable than typeof, I changed the references to that instead, so there is nothing different about the esp boards in that regard. Finally, I did no changes about adding yeilds. I'm still not sure about a consistent way to do this...

@wmacevoy
Copy link
Collaborator

@crankyoldgit, @ssilverman : a version of this has been pulled into the v2.3.X-alpha next release. That version adds a single yield after every test called in the loop. I hope this is a reasonable compromise.

@wmacevoy wmacevoy closed this Apr 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants