if (Serial.available() > 1) is wrong. Always use
if (Serial.available()) in such cases. Also it seems you are communicating with the GPS shield using Hardware Serial. However, the Arduino also uses the same serial port for communicating with the PC via the USB connection. So what you have basically is:
- Arduino TX, PC RX and GPS RX are all connected
- Arduino RX, PC TX and GPS TX are all connected
So anything the Arduino writes to the Serial port using
Serial.println() is received by both the PC and the GPS shield. And the other hand, responses from the GPS shield and commands sent from the serial monitor all arrive at the same Arduino pin. So when you use
Serial.read(), assuming you used the serial monitor to send the command, you will end up receiving your own command (like some sort of echo), and according to your program, you use
Serial.println() to send the command again which is received by both PC and GPS shield, with the GPS shield responding to the same command again. All undesirable.
TLDR; use SoftwareSerial instead for the GPS shield. Connect the GPS shield TX to pin 2 and its RX to pin 3 and use this code:
SoftwareSerial gps(2,3); // pin 2 = RX, pin 3 = TX
gps.begin(57600); // change to your baud rate, if not auto-baud
while (Serial.available()) //used to send commands from PC
gps.write(Serial.read()); // to gps
while (gps.available()) // used to read responses from gps
Serial.write(gps.read()); // to PC
So the Arduino forwards everything it receives from the PC monitor (commands) to the shield and sends everything it receives from the shield (responses) to the PC to be displayed in the serial monitor.