Releases: plerup/espsoftwareserial
Releases · plerup/espsoftwareserial
Release 5.2.1
Quick-fix release 5.2.1: there are more than Wemos boards - ESP8266 C…
Release 5.2.0
Release 5.2.0 (#102) * Use FunctionalInterrupt.h on ESP8266 instead of template-meta programming ISR table. * signedness streamlining. * Hint for future refactoring of word size. * Paranoid check might be unexpected in refactoring. * Lambda function for ISR must be in ICACHE RAM. * Use attachInterruptArg introduced in ESP8266 Arduino master * Don't use FunctionalInterrupt.h directly. * Compact buffer whenever empty, in preparation of zero-copy block reads. * API and dumb impl for readBytes. * Reduce buffer pressure. * Don't announce an overflow where no data is actually lost. * readBytes() full impl. * More hints for future refactoring of word size. * More clearly express difference between ring buffer size and capacity. * Top error-free bitrates for SoftwareSerial loopback example, running pure local software loopback, updated. * Mention ESP32 compatibilty in README.md * Loopback example with hardware UART loop device for ESP8266 as well as ESP32. * Comment, explains difference to hardware serial, readBytes is not blocking. * Default config for loopback example changed by mistake. * Refactoring to use microseconds (micros()) instead of CPU cycle count (ESP.getCycleCount()). * Revert "Refactoring to use microseconds (micros()) instead of CPU cycle count (ESP.getCycleCount())." This reverts commit 3784f13237e6dfb0954a781b019ebbb1c9025e28. No noticeable difference between use of CPU cycles and microsecond resolution on ESP8266, but on ESP32 the error rate is measurably lower when using CPU cycles. API portability in ESP eco system is not affected, revert to using ESP.getCycleCount/getCPUCycles. * Minor release 5.1.0 brings readBytes() block reading, fixed buffer capacity vs. size, removal of ISR trampoline table, and some prep work for implementing 9 bit data words. * Breaking change: adopt separation between constructor and begin() like HardwareSerial in ESP32. Makes porting more obvious, there is reasonable concern that ESP32 users might overlook the three HardwareSerial devices in favor of EspSoftwareSerial. Plus, begin() and end() are more resource conserving this way. * Update examples for breaking API change. * Source formatting. * Use C++ memory smart pointers for buffer allocation. * Use WEMOS D1-16 pin names. * Loopback with HW serial as source and final sink for regression tests, implemented also for ESP32. * Use WEMOS D1-16 pin names. * Ported loopback and repeater examples to WEMOS D1 MINI ESP32, accounting for the WEMOS pinout and shield compatibilities. * Delete default constructor and assignment operator. * Help catch a few misuses when switching HardwareSerial and EspSoftwareSerial. * Write() error return and better code readability. * The ESP32 does not implement optimistic_yield, calling delay() in available loops is thus mandatory in sketches. Reached better comprehension of optimistic_yield's parameter meaning. * std::function does not need initialization. * Disable and reenable interrupts more precisely, i.e., save and restore the level. * Refactor circular queue into own class. * fixup! Disable and reenable interrupts more precisely, i.e., save and restore the level. ESP32 Arduino.h defines disable / enable interrupt as noops. Do the same. * CircularQueue performance improvement. * Lock-free for multi-producer / single-consumer. * Make sketch filename case match folder name (#96) The Arduino IDE requires the sketch folder name to match the filename of the primary sketch file. On a filename case-sensitive OS like Linux, this includes matching case. This change causes the example sketch to be accessible via the Arduino IDE's File > Examples > LIBRARYNAME menu after the library is installed. Reference: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#library-examples * Correct Arduino library folder layout for utility classes. Dummy availableForWrite for ESP32 HardwareSerial portability. * More precise write timings in ESP32 tests. * fixup! Lock-free for multi-producer / single-consumer. * Updated improved bitrates in examples. * Refactor single publisher and multi publisher queue into derived classes. Fix atomicity in MP push(). * loopback and repeater examples mini cleanup. * Cleanup, concurrency fix. * New ISR level encoding using sign bit instead of LSB. * Fix for ESP8266. * Debouncing receive. * Revert "New ISR level encoding using sign bit instead of LSB." This reverts commit 43360a1cad305f40ab2cce75528baeb71162663d. * Error in wiring instructions. Use halfduplex, ESP32 works poorly in full duplex. * Tested queue on x86_64, finalized MP template (mutex in push, lock-free pop) * CircularQueue renamed, refactored according to inspection hints. * fixup! CircularQueue renamed, refactored according to inspection hints. * write() for char buffer complementes uint8_t buffer. * fixup! Error in wiring instructions. * Drop implicit atomic<> queue member type wrapping. * RAII pattern for interrupt locking. * capacity() preserves queue contents, MP safe when called from single consumer. * Add getter for queue capacity. * Use Rvalue reference in push() argument. * Due to complete explicit fences, use relaxed memory order for atomic loads and stores. * circular_queue Rvalue, constness improvements. * circular_queue rvalue reference improvements, new for_each functions. * Use circular_queue::for_each * Rename *_revenant to the more common *_requeue wording * for gcc 4.8.4 on Ubuntu 14.04.3 * pop_requeue() and for_each_requeue() need non-const reference to value * Added memory barrier to circular_queue * Update from ESP32 portability. * circular_queue: added Doxygen-style source code documentation. * Fixed: Read after no data for 27s (2^31 CPU cycles) bug * Fix race on non-MP queue. * Shorter deadline in example is sufficient * Memory fence adjustments in queue * Move timing relevant code into timing function * Signedness and stop-bit detection timeout tweak * Discard timestamps with same level - probably from end-bit detection or glitches * Breakthrough low error count at full duplex, 38400bps, EspSoftwareSerial at both ends. * Stop bit detection fixed * Rx bit timings tweak. * ESP32 requires GPIO input pullup. * Improved (re)sync logic in repeater. Reset expected on each error, otherwise errors multiply and give very poor reports. * Updated * Fix response for mismatched receives * Cleanup includes in response to fixed included in cores/esp8266/interrupts.h * Workaround for missing attachInterruptArg() on ESP8266 * Release 5.2.0
5.0.4
5.0.3
5.0.0
5.0.0-rc3: Testing signal generation (OUTPUT vs. INPUT_PULLUP)
against 3rd party hardware, ESP8266 internal UART, Wemos D1 mini USB UART. Removed ALT_DIGITAL_WRITE. Commited tests Loopback and Repeater in default configuration to run two ESP8266 internal UARTs connected - max. reliable bitrate is only 2400bps in tests.
Second 5.0.0 release candidate
Improved write timing with yielding to other tasks between bytes of block writes. Supports large chunks without
blocking other activity too much.
Full duplex tested up to 28800bps, half-duplex works in some cases at 115200bps.
5.0.0-rc1
"Real-time" ISR and async interface
Rx interrupttimed (#64) * On Wemos D1 mini, serial TX from D4 (GIOP 2) to 5V SDS 011 was rather unreliable. Per comments in http://www.esp8266.com/viewtopic.php?f=13&t=4256 changed to setting pinMode instead of digitalWrite. Now have reliable serial output. * Separation of concern between constructor and begin method. * rename m_bitTime to m_bitCycles to be precise. * return to use optimistic_yield, but compute proper duration. Use optimistic_yield in available(). * Per Arduino docs, use digitalPinToInterrupt for ISR to pin mapping; use volatile on objects shared between ISR and main program. * Reformat (2-blank indents instead of 3 or 4) by other commiter caused minor merge glitch. * More cleanup of inconsistent indents. * Reinforce bearable formatting via Visual Studio Format Document, Untabify. * Use output mode instead of value for stronger signals in enableTx() also. * Experimental check of timings; 400 cycles appear to be delay for ISR startup; 1/3 bit time to have a stable ramp up for reading levels. * digitalWrite(...LOW) is sufficient once during initialization for pinMode-based level switching. * Level-change triggered interrupt for receiver should free more time for main task. * Reply to message received correctly on first try. Auto-training of bitrate achieved this. * available yields for 4 bytes duration. * Allow for 6 percent bit time jitter. * revert to setting pin mode OUTPUT and writing LOW or HIGH. * Loopback test/example. * Repeater test sketch. * created .gitignore * repeater example, report mismatch errors in sequential values. * loopback example, report throughput on received data instead of sent. * Allow interrupts by default at any data rate. * Rx bit timing tuned. * Fixed reportings in tests. * Revert "revert to setting pin mode OUTPUT and writing LOW or HIGH." This reverts commit 261f86d2a93ab4e6b95a57f2ef4bf6b3b925ec11. * Loopback on same device works quite well @ 115200bps, 0.4% bad bytes. Looping over a second ESP8266 running repeater doesn't work so well. * Update 160MHz frequency from setup? * Identified obstacle to duplex mode: interrupts turned off in available() led to dropped receives * 2 ESP8266 asymmetrical duplex loopback test works at better than 3p.c. error rate * Must use ICACHE_RAM_ATTR for timing sensitive functions. * Duplex local loopback and loopback via 2nd ESP8266 running repeater works (0 - 3.5% errors). Tested with SDS011 particulate matter sensor in air quality monitoring application. Commands are issued with 3 retries, full functionality is given. * Increased report rate to avoid wdt * revert to setting pin mode OUTPUT and writing LOW or HIGH. (cherry picked from commit 261f86d2a93ab4e6b95a57f2ef4bf6b3b925ec11) # Conflicts: # SoftwareSerial.cpp * #define ALT_DIGITAL_WRITE compile-time selects writing HIGH/LOW or LOW/INPUT_PULLUP signal generation. * Line-end or reformat failure - no effective code change! * Contention on masked stop bit resolved by blocking interrupts and speeding up critical code * Factor 9 correction for start bit timing works well with SDS011 sensor. * Library and samples compile for ESP32. Not yet tested on hardware. * Need factor 10 correction for start bit timing with SDS011 sensor, otherwise measurements frequently get lost. * In available(), yield for 2 bytes duration. * Renames for clarity. * Fixes possible endless loop in ISR. * Masked data bit calculation fixed. Timing tolerance based on bit cycle duration instead of CPU frequency is safer. * Turn on internal pullups on RX pin. Improves SNR significantly in ESP8266 nullmodem test. * Align to and take clues from HardwareSerial.h in Arduino core for ESP8266 community release 2.4.1. * Use default member values where applicable. * Figured out that ESP8266 timing-critical functions need to warm up. Sending a single byte and receiving it is sufficient. * Format sources according to Artistic Style. * Async event handling for received serial data. * Fully automatic application of Artistic Style (astyle), using Visual Studio plugin. * Merge parts of master release 3.4.1 * Substituted F_CPU for ESP.getCpuFreqMHz as suggested in 3.4.1 release. * Off by factor 1E6 * Be more expressive and help compiler generate constant expressions. * Revert "Substituted F_CPU for ESP.getCpuFreqMHz as suggested in 3.4.1 release." CPU frequency can be set via API, the define F_CPU may not be trustworthy. This reverts commit ae05b897887b7653365182c8338d532a87b50dfe. * Move bit-detection from ISR to main code. * Fix masked stop bit detection. * SDS011 particulate matter sensor crashed after short while - longer optimistic_yield timing works now. * Everyone, stop using unsigned for natural non-negative numbers - this doesn't work as you expect on computers. unsigned long (ESP8266 cycle count) wraps around after circa every 26.8s at 160MHz clock speed - this really matters. * Updated README.md to outline specific area of concern for this fork. * Use C++ function inlining instead of C-style macro expansion. Fix unsigned arithmetic bug in waitBitCycles(). * Remove some paranoia. * In endurance test, SDS011 still either locks up or is not stopped after measurement interval. Trying fixes: - implement block write for tighter timing - busy wait 13/14 bit length instead of 1/5 for more precise timing. * SDS011 keeps locking up. Iterating optimistic_yield duration downward from 13/14 factor. * Calculated ISR buffer size. Use calculated delta in hidden stop-bit code. * Use delayMicroseconds() in write's bit waiting. * Do less in ISR to ease timing impact in full duplex. * Doing as little as possible in ISR, do everything possible in main code. Double full duplex throughput compared to previous ISR code. * # Conflicts: # SoftwareSerial.cpp # SoftwareSerial.h * Revisited write timings. Can now write up to 9600bps with interrrupts enabled at near zero errors. Can write at 115200bps with interrupts disabled at zero errors. * Prepared tests to work with improved write timings. Have not yet re-run the test cases, may still change the default initialization of interrupt enable/disable based on bitrate and errors. Given that bidirectional is more of a generally expected feature than absolute zero-errors on serial lines, I tend toward allowing interrupts by default at a bitrate as high as it will provide low error frequency. With disabled interrupts during send, the receiver is in simplex mode. * - improved write, collapses identical bitvalues into single wait interval. - improved wait function. * - watchdog fires if interrupts are enabled, but no yielding. * Enabling/disabling interrupts during tx based on rate or preference breaks timings, remove this function. * Set start bit level first, then starting timing. * Updated test cases. Spurious bit errors occur at any bitrate, depending on simplex or duplex transmissions. * Reorganize write signal generation like a waveform generator. * Fixed for SDS011 particulate matter sensor, real 9600bps hardware. * loopback test can perform (comment/uncomment accordingly) single char or block write. * Enhanced loopback test case to use HW UART as loopback device. * Use HW UART for repeater. * Rx: stop bit detection on timer used inverted logic value. * Updated examples/swsertest to run SoftwareSerial at 74880bps now. Works with minor sporadic bit errors. * Describe footprint optimization in README.md. * Add (default enabled) half-duplex test mode. Highest bitrates in SoftwareSerial work only half-duplex, because otherwise interrupt-driven receiver interferes too much with send timings, or disabling interrupts for high bit-rate sending handicaps the receiver. * Allowing Interrupts during tx depends on full-duplex requirements. Interrupts are now enabled throughout by default, this provides the best f ull-duplex experience at any bitrates. High bitrates (57600, 115200) work at low error frequency in half-duplex with disabled tx interrupts - for instance, if only logging through SoftwareSerial, or if a request-reply synchronous packet protocol is in use. Revert "Enabling/disabling interrupts during tx based on rate or preference breaks timings, remove this function." This reverts commit 037fb61a63f0dd0f9f389b60144bb1060e5afaaf. # Conflicts: # SoftwareSerial.cpp # SoftwareSerial.h * Amended copyright notice in source code. * Standard library header include for std::function<> template added. * Updated library.properties * Update ISR list for ESP32 specifics. * Updated examples to compile for ESP32. * Use C++ 11 atomic instead of volatile. Use explicit 32bit integer types.