Trouble reading, NMEA sentences with a GPS module and NewSoftSerial in LINUX

Hello everyone, this is my first post in this community. I have a problem, I'm working with a GPS module, and Windows 7, my code can read the NMEA sentences from the module without problems, but my problem is when I work on linux.

With the library SoftwareSerial only get unreadable characters, and I get better results with the library NewSoftSerial, but not get the expected result, because I get is a "ÿ" (y with A diaeresis) between each byte as follows:

ÿ$ÿGÿPÿRÿMÿCÿ,ÿ0ÿ6ÿ1ÿ3ÿ3ÿ5ÿ.ÿ4ÿ8ÿ2ÿ,ÿAÿ,ÿ3ÿ4ÿXÿXÿ.ÿ4ÿ9ÿ8ÿ9ÿ,ÿSÿ,ÿ0ÿ5ÿ8ÿXÿXÿ.ÿ7ÿ0ÿ1ÿ7ÿ,ÿWÿ,ÿ0ÿ.ÿ6ÿ0ÿ,ÿ2ÿ9ÿ4ÿ.ÿ2ÿ9ÿ,ÿ0ÿ5ÿ0ÿ9ÿ1ÿ1ÿ,ÿ,ÿ*ÿ0ÿ4ÿ
ÿ

and I should get a sentence like this:

$GPRMC, 061335.482, A, 34XX.4989, S, 058XX.7017, W, 0.60,294.29,050911,, * 04

Someone can give me an idea??

thank you very much!


my code for debugging:

#include <ks0108.h>  
#include <Arial14.h>  
#include "SystemFont5x7.h"   
#include "ArduinoIcon.h"    

// GPS  *******************************************
#include <NewSoftSerial.h>
#define rxPin 3      //rx pin in gps connection
#define txPin 2      //tx pin in gps connection
NewSoftSerial gps = NewSoftSerial(rxPin, txPin);

// variables
char lat[12];
char pos1[2];
char lng[12];
char pos2[2];
char hora[12];
char fecha[7];
char altitud[5];
char mychar[100];

int comas = 0;
int x_pos = 0;
int y_pos = 0;
byte byteGPS = 0;
int i = 0;
int h = 0;
// Buffers for data input
char inBuffer[300] = "";
char GPS_RMC[100]="";
char GPS_GGA[100]="";
//************************************************


unsigned long startMillis;
unsigned int iter = 0;

void setup(){
  
  //gps setup for mySerial port
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  gps.begin(9600);
  Serial.begin(19200);
  Serial.print("Inicializando GPS...");
  //*************************
  
  GLCD.Init(NON_INVERTED);   
  GLCD.ClearScreen();  
  GLCD.DrawBitmap(ArduinoIcon, 32,0, BLACK); 
  delay(3000);
  GLCD.ClearScreen();
  GLCD.SelectFont(System5x7);     
}

void loop(){ 
  x_pos = 0;
  y_pos = 0;
    byteGPS = gps.read();
    Serial.print(byteGPS, BYTE);
/*
// Read the RMC sentence from GPS
  byteGPS = 0;
  byteGPS = gps.read();
  while(byteGPS != 'C'){
    //Serial.print(byteGPS);
    byteGPS = gps.read();
  }
  GPS_RMC[0]='

;
 GPS_RMC[1]='G';
 GPS_RMC[2]='P';    
 GPS_RMC[3]='R';
 GPS_RMC[4]='M';    
 GPS_RMC[5]='C';
 
   i = 6;
   while(byteGPS != ''){                  
     byteGPS = gps.read();        
     inBuffer[i]=byteGPS;
     GPS_RMC[i]=byteGPS;
     i++;                      
 }
/

 // Read GGA sentence from GPS
 byteGPS = 0;
 byteGPS = gps.read();
 while(byteGPS != 'A'){
   byteGPS = gps.read();
 }
 GPS_GGA[0]='


;
  GPS_GGA[1]='G';
  GPS_GGA[2]='P';    
  GPS_GGA[3]='G';
  GPS_GGA[4]='G';
  GPS_GGA[5]='A';
  
    i = 6;
    while(byteGPS != '*'){                  
      byteGPS = gps.read();
      inBuffer[i]=byteGPS;
      GPS_GGA[i]=byteGPS;
      i++;                      
  }
    
[/size]
  
  // print the GGA sentence to USB
  Serial.print("GGA sentence: ");
  h = 0;
  while(GPS_GGA[h] != 42){
    Serial.print(GPS_GGA[h],BYTE);
    h++;
  }
  Serial.println();
*/

  /*
// print the RMC sentence to USB
  Serial.print("RMC sentence: ");
    h = 0;
  while(GPS_RMC[h] != 42){
    Serial.print(GPS_RMC[h], BYTE);
        h++;
  }
  Serial.println();


  comas=0;
  h = 0;
  while(GPS_RMC[h] != 42){
     if(GPS_RMC[h] == ','){
       comas++;
       i = 0;
       if(GPS_RMC[h+1] == ','){
           switch(comas){
            case 1: hora[0]='0'; break;
            case 3: lat[0]='0'; break;
            case 4: pos1[0]='0'; break;
            case 5: lng[0]='0'; break;
            case 6: pos2[0]='0'; break;
            case 9: fecha[0]='0'; break;    
           }      
        } 
      } else {
         switch(comas){
            case 1: hora[i]=GPS_RMC[h]; break;
            case 3: lat[i]=GPS_RMC[h]; break;
            case 4: pos1[i]=GPS_RMC[h]; break;
            case 5: lng[i]=GPS_RMC[h]; break;
            case 6: pos2[i]=GPS_RMC[h]; break;
            case 9: fecha[i]=GPS_RMC[h]; break;    
         }
     i++;
     }
  h++;
  }
 
  comas=0;
  h = 0;
  while(GPS_GGA[h] != 42){
    if(GPS_GGA[h] == ','){
      comas++;
      i = 0;
      if(GPS_GGA[h+1] == ','){
        switch(comas){
          case 9: altitud[0]='0'; break;
        }
      } 
    }else {
      switch(comas){
        case 9: altitud[i]=GPS_GGA[h]; break;
      }
    i++;
    }
  h++;
  }

    Serial.print(fecha);
    Serial.print("|");
    Serial.print(hora);
    Serial.print("|");
    Serial.print(lat);
    Serial.print("|");
    Serial.print(pos1);
    Serial.print("|");
    Serial.print(lng);
    Serial.print("|");
    Serial.print(pos2);
    Serial.print("|");
    Serial.print(altitud);
    Serial.println();

    GLCD.ClearScreen();
    GLCD.CursorTo(0,0);
    GLCD.Puts(fecha);
    GLCD.CursorTo(0,1);
    GLCD.Puts(hora);
    GLCD.CursorTo(0,2);
    GLCD.Puts(pos1);
    GLCD.CursorTo(2,2);
    GLCD.Puts(lat);
    GLCD.CursorTo(0,3);
    GLCD.Puts(pos2);
    GLCD.CursorTo(2,3);
    GLCD.Puts(lng);
    GLCD.CursorTo(0,4);
    GLCD.Puts(altitud);
    */
 }

I haven't used the software serial; do you need a
if (gps.available()>0){
kind of thing here so you know when good data has been received?

// Read the RMC sentence from GPS
byteGPS = 0;
if (gps.available() >0){ // so you know to expect good gps data ?
byteGPS = gps.read();

wow! Cross thanks you solved my problem, sorry for my newbie mistake!

it's working perfectly now
Thank you!
:grin:

Cool!