Raspberry Pi build

I am trying to plan a build using 2 Spartan 3 OEM Lites, communicating via UART and displaying the data on a screen and data logging. My question before I make my purchase is do you have an example line of code that would send the “G” command and then the line of code that would read and store the return value? I am a beginner at projects like this but I have some basic knowledge.

Thanks

void setup(){

Serial.begin(9600);

}

void loop(){

Serial.write(G);

sensordata = Serial.read();

delay(100);

}

After sending G, you need to send (LF) or newline

Would this work?

Or what is preferred: Serial.print(), Serial.println(), or Serial.write()? I see an arduino example for the Spartan 2 OEM with I2C but not for uart. Do you happen to have an example to share?