NewSoftwareSerial and Hardware Serial interupts

Hello again...

I have discovered I have a problem receiving data from the hardware serial port when I use NewSoftwareSerial to read data from another device. The problem seems to be that when the interrupt that NSS uses is running the data coming in from the hardware serial is not stored in the serial buffer.

My set up is quite simple, I have an em406a GPS connected to the NSS pins and am receiving a set of commands from the computer via Xbee's the hardware serial and acting upon this data using the TLC5940's.

The GPS BAUD rate is set to 4800 (as the em406a datasheet states it's set to this) and the hardware serial at 57600 (as the Xbees operate at this and am using the lovely FIO).

I noticed when I constantly send a string from the Serial Monitor such as
"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
(111 bytes)
and use simple echo code on the Arduino such as:

   while( Serial.available() && c != '\n' && c !='\0' ) {  
      c = Serial.read();
      if(c>=0 && c<=255) {
        delay(1);  
         Serial.print(c);
      }

most of the time there is missing data, ie:
012345678901234567890123456789012345678901234567890123456789012345678901234567890189
or
456789012345678901234567890145679
or
010123456789012345678901239013459

and maybe 1/3 of the time the full string...

If I set the NSS BAUD to higher rates the errors are less and less, until I match at 57600 and it works perfectly, however the GPS is programmed is 4800 and so I get no data (of course).

I am trying to decide if it's worth trying to set the em406a to 57600 (if this is possible?) or to maybe change the Xbee configuration to lower the data rate and somehow meet in the middle somewhere on the BAUD or if there is another suggestion to cut out the loss of the data not getting into the serial buffer.

Any suggestions?

And Mikal, if you see this many thanks for all the hard work on NSS and TinyGPS!

I think the problem is that NSS disables interrupts once a character arrives. It then waits for the character to be fully received, then interrupts are enabled again. This means that during that time only 1 hardware serial character can be received. It makes sense that the faster the NSS baud rate, the less time is spent with interrupts off, so the fewer hardware serial characters are missed.

--
The Quick Shield: breakout all 28 pins to quick-connect terminals

May be this is the reason for some funny complains with NSS ....

It all depends on the relation between the bit rates. As HS input is double buffered the NSS bitrate should be set at least (!) to the bitrate of HS. Double bit rate at HS might already give you drop outs at the HS receiving...

Does anybody know how to in crease the serial of the GPS to 57600, if it's possible?

Hmm.. it seems the GPS cannot go at 57600 due to it's clock... Is it possible to use NSS or SoftwareSerial without interfering with the interrupts?

you can time de-couple both.
(1) receive the complete NMEA record.
(2) then you have 1sec to transmit