Reading Array/Stream of bytes in serial?..

Hi i have this code in linux that sends hex data to arduino..

unsigned char pCom[2][7]={{0xFF,0x01,0x00,0x10,0x2F,0x2F,0x6F},   
                            {0xFF,0x01,0x00,0x08,0x2F,0x2F,0x67}};

write(fd,pCom[0],8);     // write to arduino which is /dev/ttyS0..

Now how can i let arduino read this stream of bytes?..

Here's the code im using in reading in the serial..

void setup (){
  Serial.begin(9600);
  
  Serial.flush();
}

void loop (){

  int i=0;
  char buffer[50];
  char c;
  if(Serial.available() > 0){
    
     delay(100);
     while( Serial.available() && i< 49) {
         
        buffer[i++] = Serial.read();
        
     }
        buffer[i++]='\0';
  }

  if(i>0)
     Serial.println((char*)buffer);
    
}

Now what i do to verify if data is sent to arduino is that i display it in php like this..

       sleep(1);
	$sGetData="";
    	    $sGetData.=fread($sCon, 40);
	
echo $sGetData;                                  // displays ^^@. why is it messed up?

But when i change

write(fd,pCom[0],8);

to

write(fd,"HELLO",5);

I get a proper output in php which is HELLO..

  Serial.begin(9600);
  
  Serial.flush();

The call to Serial.flush() makes no sense. If you are using a version of the IDE prior to 1.0, the flush() method dumps all as-yet-unread data in the serial buffer. Nanoseconds after opening the serial port, do you really think that there is a possibility that there is unread data pending? If there really could be, why do you want to delete it?

If you are using 1.0 or later, the flush() method blocks until all buffered output data has been sent. You haven't sent anything, so the function does absolutely nothing.

Useless code is best deleted.

write(fd,pCom[0],8);     // write to arduino which is /dev/ttyS0..

pCom[0] is one element of the array. It is not 8 bytes long. Why are you telling write() that it is? Don't you really want to send the whole array, or at least the first 8 bytes of the array?

The call to Serial.flush() makes no sense. If you are using a version of the IDE prior to 1.0, the flush() method dumps all as-yet-unread data in the serial buffer. Nanoseconds after opening the serial port, do you really think that there is a possibility that there is unread data pending? If there really could be, why do you want to delete it?

If you are using 1.0 or later, the flush() method blocks until all buffered output data has been sent. You haven't sent anything, so the function does absolutely nothing.

Ok sir understood thanks for pointing that out to me..

pCom[0] is one element of the array. It is not 8 bytes long. Why are you telling write() that it is? Don't you really want to send the whole array, or at least the first 8 bytes of the array?

Well that's what i thought that it will send 8 bytes of data to arduino.. if you so how can i send the first eight bytes of the array eg 0xFF,0x01,0x00,0x10,0x2F,0x2F,0x6F = which arduino outputs to serial then php read it as = ff0100102f2f06f

Thank you for helping..

PaulS:
pCom[0] is one element of the array.

pCom is a two-dimensional array. Isn't pCom[0] equal to &pCom[0][0]?

pCom is a two-dimensional array. Isn't pCom[0] equal to &pCom[0][0]?

Yeah that's what i also know so i did it like that to send a stream of bytes to arduino.. But anyway i got it working now.. thanks