* Add valgrind and string tests to host_tests
Valgrind identified an error that was causing intermittent failures in
the host tests, and can check for subtle memory access and allocation bugs.
Add it to the standard host_test suite, and any errors will cause test
failure.
Also start adding string tests, since two undefined behaviors have been
found so far just by inspection.
* Add additional String tests
Looks like a possible bug in the concatenation operator, need to verify
expected behavior.
* Remove verbose from valgrind run
No need to be so chatty on the test. Errors were a little hard to spot.
Go to normal verbosity.
* Add lcov and more string tests
LCOV and genhtml can generate nice HTML coverage charts hilighting test
coverage issues in a much simpler way than gcov text format. Generate these
automatically from gcov output.
Add additional string creation and comparison tests.
* Move String coverage to >50%
Additional string tests and checks
* 66% test coverage in String
* Add allocation-unit-sized strings test
Ensure that strings that are right on the edge of the allocation
size are handled properly and account for trailing 0.
As @devyte noticed, PR #4955 has an issue when you catenate a string to
itself and the string used to hold a longer value because it does not
explicitly 0-terminate the resulting string. If the string was extended,
however, reserve() would 0-terminate by default.
Always terminate the result of `s += s;` now.
When a string is concatted to itself, the pointer to its c_str can change
due to realloc(). This would invalidate the passed-in pointer being
concatted, and cause a use-after-free error. Special case this to avoid
the issue. Now "a += a;" works properly.
Also use sprintf(%{l}d) instead of non-POSIX ltoa/itoa calls to construct a
string from a signed number (in base 10 only). The non-posix versions don't
handle INT_MIN properly on either host_tests or on the ESP8266.
When the ESP cycle counter rolls over, the "now" can be smaller than the
next-edge time of a waveform generator. This would cause the edge to be
missed on that specific pin, and make it look like PWM was hung.
Use proper comparison between current time and edge time.
Fixes#4944
Also remove the "sigma-delta.c.unused" file which was replaced by a
working one some time ago.
memcpy() is undefined when source and destination overlap. String::trim
uses it when shifting the string left to remove left padding.
Replace with memmove() which is always safe, even when overlapped.
MD5Builder tests have been randomly, non-repeatably failing due to a problem
with the returned value of MD5Builder.
Valgrind detected a strncpy with an overlapping memory range, which is
an undefined operation. Fix it with a memmove instead, and get rid
of a couple #define redefinitions which were causing compile warnings
on the host side as well.
Fixes#4882 and updates GitHub certificate fingerprint to the current one
in BearSSL_Validation example.
When setting a authentication mode or stopping, clear all others out in case
the object is being re-used.
Add in a yield during the SSL handshake to allow a graceful timeout and not
a WDT error when the remote server hiccups. Thanks to @Jeroen88 for
finding and testing this.
Thanks to ideas from @shimarin for offering ideas to speed up the stopWaveform
calls which may help things like SoftwareSerial run better.
Optimize the stopWaveform routine to abort fast and early whenever possible.
Remove the stopWaveform call from digitalRead(). If you're running a waveform
on a pin and try to read it, that is a logic error and you'll end up reading the
waveform and not the outside world's view of the pin.
Several users have been worried that they need to generate the IDX file,
but don't know how. The CertStore code actually writes this file on object
creation, and the user never needs to explicitly generate or upload it.
Add a comment to the example explicitly noting this.
Setting a pin direction would cause a waveform generator attached to it to stop.
This could cause PWM to stop if pinMode() is called while running (as it was
called in __analogWrite()).
Remove the stopWaveform call from pinMode, the Tone, analogWrite, or Servo
that initiated the waveform has responsibility for stopping it (and it does)
when complete, irrespective of the pinMode.
Fixes#4905
* Compatibility and IRQ fixed for waveform/tone/pwm
Fix a compiler ambiguity introduced with a floating point frequency option
for tone(). Thanks to @Rob58329 for discovering this and proposing the
fix.
Match original analogWrite behavior by going from 0...1023 (PWMRANGE) and
not 0...1024, and also explicitly set the analogWrite pin to an OUTPUT.
Thanks to @jandrassy for finding this.
Fixes#4380 discovered by @cranphin where interrupts were disabled on a
stopWaveform(). Remove that completely and bracket the update of non-atomic
fields in the structure with disable/enable IRQs for safety.
* Fix tone(int,int,int) infinite loop
Explicitly cast the frequency, when passed in as an int, to an
unsigned int. Verified with snippet:
tone(D1, (int)1000, 500);
tone(D1, (unsigned int)1000, 500);
tone(D1, 1000.0, 500);
tone(D1, (int)1000);
tone(D1, (unsigned int)1000);
tone(D1, 1000.0);
* Scheduled Interrupt
* use capital letter for Schedule.h
* Prevent memory leak when attach is called multiple times without detach
* Add improved schedule_function
* WIP : Integrate FunctionalInterrupt & ScheduledInterrupt
* Fix travis error
Due to popular demand, remove the hardcoded dependency on SPIFFS
or SD from the CertStore by factoring out the file interface into
a new class (CertStoreFile) that the user will need to implement
as a thin wrapper around either a SPIFFS.file or a SD.file
Combine the downloaded certificates into a UNIX "ar" archive
and parse that on-the-fly to allow easy inspection and creation
of the Cert Store database.
Examples updated with a new certificate downloader that creates
the certs.ar archive and with a single sample that can be built
for either SPIFFS or SD with a #define. Users can copy the
implementation of the CertStoreFile they need to their own code
as it is self-contained.
Also move the CertStore to the BearSSL namespace and remove the
suffix and separate SPIFFS/SD sources.
Remove the "deep+" change from the CI build as well (no special
options needed on any PIO or makefile build).
We'll revisit the filesystem wrapper for 2.5.0, hopefully having a
unified template for both filesystem usage at a global level. For
current users, be aware the interface may change (simplify!) in
release 2.5.0.
Fixes#4740
When a message is sent by the app that is larger than the SSL buffer,
it will take multiple TLS fragments to transfer. Writes will loop
through and not return until either all data is transferred or there
is an error.
Remove and rewrite all the parts of the core/libraries using TIMER1
and consolidate into a single, shared waveform generation interrupt
structure. Tone, analogWrite(), Servo all now just call into this
shared resource to perform their tasks so are all compatible
and can be used simultaneously.
This setup enables multiple tones, analogWrites, servos, and stepper
motors to be controlled with reasonable accuracy. It uses both TIMER1
and the internal ESP cycle counter to handle timing of waveform edges.
TIMER1 is used in non-reload mode and only edges cause interrupts. The
interrupt is started and stopped as required, minimizing overhead when
these features are not being used.
A generic "startWaveform(pin, high-US, low-US, runtime-US)" and
"stopWaveform(pin)" allow for further types of interfaces. Minimum
high or low period is ~1 us.
Add a tone(float) method, useful when working with lower frequencies.
Fixes#4321. Fixes 4349.
* interactive example: update with option for using DHCP again after using static IP
* lwip2: avoid crash when IP address is set to 0(any) by dhcp not getting its lease renewal in due time
* lwip2: automatically remove oldest PCBs in time-wait state, limit their number
thanks to @me-no-dev 07f4d4c241 (diff-f8258e71e25fb9985ca3799e3d8b88ecR399)
* faq: update about tcpCleanup()
* lwip2: add a macro HAS_PHY_CAPTURE=1 indicating capture facility is available