Pages: 1 ... 5 6 [7] 8 9 ... 11   Go Down
Author Topic: NewSoftSerial Library: An AFSoftSerial update  (Read 16348 times)
0 Members and 1 Guest are viewing this topic.
Austin, TX USA
Offline Offline
God Member
*****
Karma: 4
Posts: 997
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#if ARDUINO_VERSION < 12
#error "Whoops!"
#endif

Thanks much for your feedback.

Mikal
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 11
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Austin, TX USA
Offline Offline
God Member
*****
Karma: 4
Posts: 997
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. smiley

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

« Last Edit: March 25, 2009, 12:31:24 pm by mikalhart » Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 11
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.  smiley
Logged

Austin, TX USA
Offline Offline
God Member
*****
Karma: 4
Posts: 997
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. smiley

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. smiley

Mikal
« Last Edit: March 25, 2009, 01:07:25 pm by mikalhart » Logged

Switzerland
Offline Offline
Sr. Member
****
Karma: 0
Posts: 269
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

"The old Europe"
Offline Offline
Edison Member
*
Karma: 1
Posts: 2005
Bootloaders suck!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@mikalhart

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

Code:
/*
  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:

/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.
« Last Edit: March 29, 2009, 12:00:57 pm by madworm » Logged

• 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!

0
Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged

Austin, TX USA
Offline Offline
God Member
*****
Karma: 4
Posts: 997
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

The Big Smoke
Offline Offline
Sr. Member
****
Karma: 0
Posts: 260
Hacking and Slashing
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Summerville, Oregon
Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
I like this little thing!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Austin, TX USA
Offline Offline
God Member
*****
Karma: 4
Posts: 997
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 97
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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....
Logged

Austin, TX USA
Offline Offline
God Member
*****
Karma: 4
Posts: 997
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yeah, that's a good point.  
Logged

Summerville, Oregon
Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
I like this little thing!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: 1 ... 5 6 [7] 8 9 ... 11   Go Up
Jump to: