ezieragabriel / arduino

Automatically exported from code.google.com/p/arduino
Other
0 stars 0 forks source link

SoftwareSerial documentation could mention AltSoftSerial library #1111

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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.htm

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.

Original issue reported on code.google.com by paul.sto...@gmail.com on 13 Nov 2012 at 4:37

GoogleCodeExporter commented 9 years ago
The AltSoftSerial page ACTUALLY, link needs trailing l  (ell)

http://www.pjrc.com/teensy/td_libs_AltSoftSerial.html

Original comment by jaguar3s...@gmail.com on 14 Nov 2012 at 3:47

GoogleCodeExporter commented 9 years ago

Original comment by s.fitzge...@arduino.cc on 8 Nov 2013 at 8:13