help with serial ports

Hi,
I'm completely new to arduino, so I need some help with the serial ports.
I want to read data from gps with my arduino due.

So I need to communicate via serial ports with my computer and the gps-modul.
I found lots of code solving the Problem with the library: SoftwareSerial
But as I have read, there is no need (and also not working for the arduino due, i tried) for this library, because the due has 4 serial ports, which I can use.

Now my question: I managed to send and recieve data from my computer. But i can't recieve the Data from the gps-modul. How do I get the serial Input from the other ports?
This is my poor version =(

int rx1pin = 19;                  // gps-rx
int incomingByte = 0;   // for incoming serial data
void setup() {
  Serial.begin(9600);            //serial PC
  Serial1.begin(4800);            //serial gps
  pinMode(PPSPin, INPUT);       // Initialize LED pin
  Serial.println("Hello world!");  // prints hello with ending line break 
}
void loop() {
        // send data only when you receive data:
        if (Serial1.available() > 0) {
                // read the incoming byte:
                incomingByte = Serial1.read();
                // say what you got:
                Serial.print("I received: ");
                Serial.println(incomingByte, DEC);
        }   
}

You connect the GPS to serial1 and then read data from it. You can then write it on serial eg

if (Serial.available()>0){
    Serial.write(Serial1.read());
}

And you will see what the GPS is sending.

The other serials can be used (or not) as you wish

Mark

Well your suggestion works better than mine, but I have still problems with my Code.

First of all: When I compare your code with mine, you replaced in the if-statement Serial1.available() by Serial.available() and it worked.
So why doesn't Serial1.available() work, because I want the Signal from the gps?
Now the serial monitor just prints output, when I give him input from pc. But then he prints endless data

My second problem is, that I get output now, but the serial monitor prints nonsens.
By searching the web I found, that the Baud-rate (9600) has to match my code

  Serial.begin(9600);            //serial PC
  Serial1.begin(9600);            //serial gps

Serial Monitor is printing ?????????? endless.

I also updated my code a little.
Do I have to write this line for a rx port? pinMode(rx1pin, INPUT);

int rx1pin = 19;                  // gps-rx
int incomingByte = 0;   // for incoming serial data
char gpsoutput;
const int sentenceSize = 80;
char sentence[sentenceSize];

void setup() {
  Serial.begin(9600);            //serial PC
  Serial1.begin(9600);            //serial gps
  pinMode(rx1pin, INPUT);       
 // Serial.println("Hello world!");  // prints hello with ending line break 
}
void loop() {
 static int i = 0;    
 // send data only when you receive data:
 if (Serial.available()>0)      
      {    
      gpsoutput=Serial1.read();
      if (gpsoutput != '\n' && i < sentenceSize)
        {
        sentence[i] = gpsoutput;
        i++;
        }
      else
        {
        sentence[i] = '\0';
        i = 0;
        }
      Serial.write(sentence);     
      }
}

Endless garbage on the serial ports normally means you have the wrong baud rate (could be a problem with number of stop bits). Check you have the right settings for the GPS and the serial monitor.

Mark

Ok. So I checked the Datasheet from my gps (Venus638FLPx GPS Receiver): Baud Rate 4800 / 9600 / 38400 / 115200

I select 9600, because it worked fine, when I just communicated with my PC.

But it doesn't work