Go Down

Topic: NewSoftSerial Library: An AFSoftSerial update (Read 18981 times) previous topic - next topic

mikalhart

Jason,

I like your thinking.  Unfortunately, the symbol you reference there is defined inside Print.h, and GekoCH's error message was that NewSoftSerial couldn't find Print.h.  So this wouldn't solve his particular problem.

I'd love in the future to be able to simply write something like

Code: [Select]
#if ARDUINO_VERSION < 12
#error "Whoops!"
#endif


Thanks much for your feedback.

Mikal

mellis

In this case, you could offer a better error message, but it still wouldn't work.  I know it's not that hard to add, and wouldn't really cause any problems, but I'm still not really convinced that it's that useful.  Are there cases where we can't just tell people to upgrade to the latest version of the IDE?

mikalhart

#92
Mar 25, 2009, 06:30 pm Last Edit: Mar 25, 2009, 06:31 pm by mikalhart Reason: 1
In my experience, there are a number of users -- GekoCH here for example -- that like to stick with earlier versions of Arduino.  There are a number of "stale" libraries that no longer work on the newer Arduino versions.  That's frequently the motivation for staying with one version.  Is that the case here, GekoCH?

When these users try to deploy certain newer libraries like NewSoftSerial, they get these cryptic error messages.  Then we get thrash on the forum as the well-meaning library writer tries to make sure his users are happy. :)

If I had been able to deliver a succinct #error "This library requires Arduino version X.  Please update." I think some thrash could be avoided.

Thanks,

Mikal


mellis

Can't we just put that on the website where you download the library?  Again, it's not that I'm opposed to the ARDUINO_VERSION define, I'm just not convinced yet.  :)

mikalhart

#94
Mar 25, 2009, 06:54 pm Last Edit: Mar 25, 2009, 07:07 pm by mikalhart Reason: 1
Yes.  You are right.  I can (and should) put a "requirements" section in the documentation.  That's a good idea whether or not we have ARDUINO_LIBRARY symbol.

But if users read documentation anywhere as haphazardly as I do, I bet there will still be forum thrash. :)

I guess that I usually follow the philosophy that "if it could be useful and it almost certainly will not be harmful, then put it in", although I very much appreciate that the conservative strategy "keep it out unless it must be in" pays great dividends in many cases.  Frankly, I'll save my passion for other issues. :)

Mikal

GekoCH

Quote
In my experience, there are a number of users -- GekoCH here for example -- that like to stick with earlier versions of Arduino.  There are a number of "stale" libraries that no longer work on the newer Arduino versions.  That's frequently the motivation for staying with one version.  Is that the case here, GekoCH?


That's right. I got a Project and I'm limited to the space of the Arduino Nano. And the new version of Arduino (0013) has something changed with the millis() and now it takes to much space. That's one reason why I stick to the 0011 version.

Project under:
www.snowflakeONE.ch

Geko

madworm

#96
Mar 29, 2009, 06:44 pm Last Edit: Mar 29, 2009, 07:00 pm by madworm Reason: 1
@mikalhart

I've tracked down my problem on linux (gcc 4.3.3_20090316-17.1) to this block of inline assembler code:

Code: [Select]
/*
 asm volatile("sbiw    %0, 0x01 \n\t"
   "ldi %1, 0xFF \n\t"
   "cpi %A0, 0xFF \n\t"
   "cpc %B0, %1 \n\t"
   "brne .-10 \n\t"
   : "+r" (delay), "+a" (tmp)
   : "0" (delay)
   );
*/



Error messages:
Code: [Select]


/tmp/ccdD9LWq.s: Assembler messages:
/tmp/ccdD9LWq.s:855: Error: register r24, r26, r28 or r30 required
/tmp/ccdD9LWq.s:912: Error: register r24, r26, r28 or r30 required
/tmp/ccdD9LWq.s:957: Error: register r24, r26, r28 or r30 required

o: In function `main':
undefined reference to `NewSoftSerial::NewSoftSerial(unsigned char, unsigned char)'  


The .o file of the library never gets built. It is irrelevant if I choose the 168 or 328 chip as target

Edit:

If I remove the "SBIW ...." line, it compiles. But I don't think is is any good. Hope it points to a solution though.
• Upload doesn't work? Do a loop-back test.
• There's absolutely NO excuse for not having an ISP!
• Your AVR needs a brain surgery? Use the online FUSE calculator.
My projects: RGB LED matrix, RGB LED ring, various ATtiny gadgets...
• Microsoft is not the answer. It is the question, and the answer is NO!

jcw

Thanks for making NewSoftSerial - it works very well for me. Saved my day when SoftwareSerial's limitations were too stringent.

But for one specific project I really wanted the ability to receive multiple independent serial streams at the same time so I started working on a somewhat different approach to try and see how far one can push the ATmega chip. It turns out that it is possible to receive at least 5 streams @ 9600 baud with an Arduino - though I don't know how much processing power that leaves for other tasks.

The basic idea is shown here:
   http://jeelab.equi4.com/2009/03/25/multiplexing-code-for-arduino/
It's being used in a "MuxShield", which is described in these posts:
   http://jeelab.equi4.com/tag/muxshield/
The complete source code is available here:
   http://jeefiles.equi4.com/muxshield.pde

Perhaps some of this is of use to Mikal or others - feel free to adopt any part of this if it helps you take the NewSoftSerial library further. Ironically perhaps, I'm also using NewSoftSerial inside the MuxShield (to implement its slave bootstrap function).

mikalhart

Thanks for the interesting write up, Jean-Claude.  There are a couple of people working on a timer-based approach to serial communication.  It all seems very promising.  Perhaps I would suggest making a parallel library?  (I'm a little reluctant to modify NewSoftSerial so radically at this point when there are so many other features in the works for it.)

Really, really good work!

Mikal

TeamMCS

Hey guys, great work!

Can I make a simple suggestion. For my library I had to create a branch of your library to support dynamic instancing (AVR-GCC doesn't support the new operator implicity?!). This support can be added in about 4 lines (download the library to see).

Throwing that in would be really useful for devs like myself. Cheers

Keshka

Sorry if I missed this information somewhere else Mikal. Does NSS work on the new Arduino Mega? I am trying to send data from Liquidware's TouchShield Slide to the Mega. My Oscilloscope tells me that the Slide is doing it's part and I have data on pin three of the Mega but mySerial.available() never returns anything. Here is the code from the Mega:

#include <NewSoftSerial.h>

int RXpin = 3;
int TXpin = 2;

NewSoftSerial mySerial = NewSoftSerial(RXpin,TXpin);
int zz = 0;

void setup()  
{
 Serial.begin(57600);    //set data rate from Arduino to PC
 Serial.println("Lets get started!");  // this prints fine.
 mySerial.begin(9600);   // set the data rate for the NewSoftSerial port
}

void loop()
{
 if (mySerial.available() > 0)  // this never triggers...
 {
     Serial.print((char)mySerial.read());
     Serial.print(zz++);
 }
}

------------------------------------------------------
Thank you
Keshka

mikalhart

I know that NewSoftSerial definitely does not work on the Mega when the RX pin > 19.  What I don't know is whether the Mega's lower numbered pins are compatible with the "regular" Arduino.  I'm guessing not based on what you report.  Does anyone know?

Mikal


Matt Elias

I have not tried the NSS library on my Mega yet, I thought the beauty of the Mega was that it has 4 hardware Serial ports....

mikalhart


Keshka

And using one of those ports looks like what I am going to have to do.  Did like having the TouchSlide mount right on top of the Mega as a "shield" but I will get over it. Pin 2 & 3 on the Mega are routed to (OC3B/INT4)PE4 & (OC3C/INT5)PE5 on the ATMEGA1280-16AU.

Keshka

Go Up