int CMUcam_MiddleMass(void) //echos # of characters expected for each command
{
int temp; // set up temporary variable
int counter=0; //set the counter to 0
int echo_counter=0; // set the echo_counter to 0
int temp1;
rprintfInit(uart1SendByte);//change UART to bluetooth
temp = uart0GetByte(); // Get a Byte
while (temp != 255) { // Keep on getting new bytes until the byte = 255
temp = uart0GetByte();
}
rprintf("Start= %d ",temp);
temp = uart0GetByte(); // Get a Byte
while (temp != 77) { // Keep on getting new bytes until the byte = 'M'
temp = uart0GetByte();
}
rprintf("M= %d ",temp);
echo_counter = 8; // expect 8 bytes ( 0 thru 7)
while(1) {
temp=uart0GetByte();//returns -1 if no data present
response[counter]=temp;//store values into an array
counter++; // add one to "counter" array
if(counter == echo_counter) // once the counter equals the echo_counter
{
// successfully captured the entire M packet
uartFlushReceiveBuffer(0);//flush out receive camera buffer to stop phase shifting
delay_us(100);
temp1 = response[0];
rprintf("MiddleMassX= %d ",temp1);
temp1 = response[1];
rprintf("MiddleMassY= %d ",temp1);
temp1 = response[2];
rprintf("MinimumX= %d ",temp1);
temp1 = response[3];
rprintf("MinimumY= %d ",temp1);
temp1 = response[4];
rprintf("MaximumX= %d ",temp1);
temp1 = response[5];
rprintf("MaximumY= %d ",temp1);
temp1 = response[6];
rprintf("Pixels= %d ",temp1);
temp1 = response[7];
rprintf("Confidence= %d ",temp1);
return response[0]; // return MiddleMass of X axis
} //endif
} // end while
} // end sub