SoftwareSerial documentation could mention AltSoftSerial library [imported]
This is Issue 1111 moved from a Google Code project. Added by 2012-11-13T16:37:36.000Z by [email protected]. Please review that bug for more context and additional comments, but update this bug.
Original labels: Type-Enhancement, Priority-Medium
Original description
What change would like to see?
Please create a link to AltSoftSerial on the SoftwareSerial reference page.
http://arduino.cc/en/Reference/SoftwareSerial
The AltSoftSerial page is
http://www.pjrc.com/teensy/td_libs_AltSoftSerial.html
Perhaps in the Limitations list, this text might work: "Slower baud rates can cause SoftwareSerial to interfere with hardware serial, tone, millis and other functions. The AltSoftSerial library can sometimes solve these problems, but had a different set of usage limitations. Refer to the AltSoftSerial page for details."
Why?
SoftwareSerial has a lot of limitations. Many users experience these difficult problems, but do not know an alternative exists that can quickly and easily solve them.
SoftwareSerial can't transmit and receive at the same time (anythign that arrives while it's transmitting is lost or corrupted). It blocks while transmitting, so no other code can run.
SoftwareSerial often interferes with reception of incoming data on HardwareSerial, especially when SoftwareSerial is used at a slow baud rate and HardwareSerial at a fast baud rate (which is the way most people try to use it). The lengthy interrupt disable times from SoftwareSerial at slower baud rates can cause HardwareSerial to completely miss incoming data. Other interrupt-based code like tone() and millis() can also be impacted.
AltSoftSerial offers a different set of trade-offs. It's transmit is fully buffered, similar to HardwareSerial. It works very well together with HardwareSerial, tone, millis, etc. It does consume a 16 bit timer, so it disables some PWM pins and can't work with Servo or other libraries that need the same timer. But when the timer is available, and the user tries to build a sketch that simultaneously moves data on HardwareSerial, AltSoftSerial solves the common and impossible-to-diagnose data loss problems.
Would this cause any incompatibilities with previous versions? If so, how can these be mitigated?
Simply linking to another web page shouldn't cause any trouble!
Often users build projects on Arduino Uno using SoftwareSerial. It works well for a limited class of uses, such as waiting for a GPS module to send data, then using it and returning to waiting before the next message arrives.
But even with SoftwareSerial receiving GPS data at 4800 baud, the interrupt disable times are long enough to cause millis() to count slower than 1000 Hz. If the user tries to also receive commands from the PC, they don't arrive reliably if they're sent while the GPS is transmitting!
These problems are almost impossible for novices to troubleshoot. The SoftwareSerial reference page doesn't even warn about the troubles associated with slower baud rates. Many users could be spared a lot of suffering if the reference page mentioned the limitations and linked to AltSoftSerial as an alternative to solve those problems.
@cmaglie Do we want to link to a 3rd party library from one of the core ones? I'm aware of how active Paul is in the community, but this seems to be saying "Hey! Don't use our stuff, use someone else's!"
Hey, Paul here.
Really, this isn't a sinister plot to get people to "using someone else's" stuff. I wrote AltSoftSerial about a year ago after personally getting involved in troubleshooting some projects where SoftwareSerial caused data loss with ordinary Serial. This was on Arduino brand boards, not Teensy... it's rarely used on Teensy because Teensy has a free hardware serial port. So yeah, I wrote an entirely different software serial implementation that isn't really needed much on my own products. I'm kinda crazy like that, but I do love a good technical challenge (the whole thing took only a few days). I also really want people's projects to work well.
For very simple projects where you never communicate on both at the same time, SoftwareSerial works pretty well. But as soon as people try to do simultaneous communication on both, things go badly, where ordinary Serial loses incoming data.
These problems are extremely confusing to novice users. Even for experts, it's very challenging to troubleshoot (at the time, I found many threads on the Arduino Forum with unresolved SoftwareSerial problem interfering with normal Serial). The SoftwareSerial documentation does little to help, since it even doesn't mention these problems. The "limitations" list is incomplete, implying these other problems don't exist. Worst of all, most "experts" incorrectly believe SoftwareSerial should be run at slower baud rates, which is exactly the WRONG advice for resolving interrupt latency problems!
Rather than "don't use our stuff", I would characterize mentioning AltSoftSerial as "our stuff works great for ABC but has problems with XYZ. If you're doing XYZ, this other stuff can let you accomplish your goals, but it also has some other limitations mentioned on its page". That's a LOT more helpful to your users than neglecting to mention these limitations. On a documentation page which does have a limitations list, failing to mention some of the limitations isn't such a great thing to do.
Regardless of whether you link to AltSoftSerial or even mention it, I do hope you'll improve the SoftwareSerial documentation.
Thanks for the clear response Paul. I'll address this soon.
On Wed, Nov 6, 2013 at 1:23 PM, Paul Stoffregen [email protected]:
Hey, Paul here.
Really, this isn't a sinister plot to get people to "using someone else's" stuff. I wrote AltSoftSerial about a year ago after personally getting involved in troubleshooting some projects where SoftwareSerial caused data loss with ordinary Serial (on Arduino brand boards, not Teensy... it's rarely used on Teensy because there's a free hardware serial port). For very simple projects where you never communicate on both at the same time, SoftwareSerial works pretty well. But as soon as people try to do simultaneous communication on both, things go badly, where ordinary Serial loses incoming data.
These problems are extremely confusing to novice users. Even for experts, it's very challenging to troubleshoot (at the time, I found many threads on the Arduino Forum with unresolved SoftwareSerial problem interfering with normal Serial). The SoftwareSerial documentation does little to help, since it even doesn't mention these problems. The "limitations" list is incomplete, implying these other problems don't exist. Worst of all, most "experts" incorrectly believe SoftwareSerial should be run at slower baud rates, which is exactly the WRONG advice for resolving interrupt latency problems!
Rather than "don't use our stuff", I would characterize mentioning AltSoftSerial as "our stuff works great for ABC but has problems with XYZ. If you're doing XYZ, this other stuff can let you accomplish your goals, but it also has some other limitations mentioned on its page". That's a LOT more helpful to your users than neglecting to mention these limitations. On a documentation page which does have a limitations list, failing to mention some of the limitations isn't such a great thing to do.
Regardless of whether you link to AltSoftSerial or even mention it, I do hope you'll improve the SoftwareSerial documentation.
— Reply to this email directly or view it on GitHubhttps://github.com/arduino/Arduino/issues/1111#issuecomment-27854089 .
Scott, I do really appreciate your effort in solving the documentation issues.
But in this particular case, since the issue is open from almost one year, I will make less conjectures and more edits to avoid wasting Paul's precious time.
C
I understand. I asked because there's no precedent for it in the docs.
I think he made a good case for it and I have no problem adding it. I just needed some clarification. On Nov 6, 2013 4:42 PM, "Cristian Maglie" [email protected] wrote:
Scott, I do really appreciate your effort in solving the documentation issues.
But in this particular case, since the issue is open from almost one year, I will make less conjectures and more edits to avoid wasting Paul's precious time.
C
— Reply to this email directly or view it on GitHubhttps://github.com/arduino/Arduino/issues/1111#issuecomment-27870054 .
+1