Problems pairing codes

Hi I have two motor controllers that are supposed to work together. One masterboard which has an lsm303 tilt compensated compass to give it heading and elevation, it calculates the error correction the motors need to move and drives the elevation portion and then does a serial.print of the commands for the motor that is set through XBEE to the heading motor controller. should look like this !C,F* or the F can be a B or S (forward, backward, stop)- and it prints the commands perfectly.

The heading motor controller then takes that serial and controls the heading motor. For some reason they work perfectly when I test them separately. But when they get paired it only works for the first command then wont take any other commands.

Code will be posted below

MasterBoard_vPaul.ino (10.6 KB)

AZMUITH_VPaul.ino (6.71 KB)

im not sure what exactly is going wrong, possibly I dont understand the serial prints enough. Or is the delays I have in the heading control affecting it? Or just small syntax error. Im not sure.

Any help is appreciated. Thankyou

void loop()
{
inByte = Serial.read(); 
  if (inByte == '!') //Will begin protocol 
  {
    int command = Serial.read();
    if (command == 'P')
    {

Have you heard of the Serial.available() function? It's past time you learned about it, and integrated it in your code.

Why do you have a variable named inByte whose type is int? Are you in the habit of misnaming variables? Could I expect to find outFloat whose type is int, to? Perhaps float inChar? or double inInt?

You may want to read about Serial.available ()