Hi,
I'm having a trouble using NewSoftSerial to read data from a GPS. I'm using a very basic sketch (attached), but I just get strings of garbage on the screen
I can read the GPS data using hyperterminal without problems, it auto-detects the connections settings as 4800 baud, 8 bit, no parity. The data displayed by hyperterminal is fine, so I know the GPS is working.
Any suggestions appreciated.
Thanks
Mike
#include <NewSoftSerial.h>
NewSoftSerial mySerial = NewSoftSerial(2, 3);
#define BUFFSIZ 90 // plenty big
char buffer[BUFFSIZ];
char buffidx;
void setup()
{
- Serial.begin(4800);*
- mySerial.begin(4800);*
- Serial.println("\n\rNewSoftSerial + GPS test");*
}
void loop()
{
- Serial.print("\n\rread: ");*
- readline();*
}
void readline(void) { - char c;*
- buffidx = 0; // start at begninning*
- while (1) {*
- c=mySerial.read();*
- if (c == -1)*
- continue;*
- Serial.print(c);*
- if (c == '\n')*
- continue;*
- if ((buffidx == BUFFSIZ-1) || (c == '\r')) {*
- return;*
- }*
- buffidx++;*
- }*
}