public float[] UltrasonicPing( )
{
byte[] response = new byte[100];
int read = SendAndReceive( new byte[] { (byte) 'p' }, response );
string str = System.Text.ASCIIEncoding.ASCII.GetString( response, 0, read );
str = str.Replace( "##ping ", "" );
str = str.Trim( );
// split string into separate values
string[] strs = str.Split( ' ' );
try
{
float[] distance = new float[4];
for ( int i = 0; i < 4; i++ )
{
distance[i] = (float) int.Parse( strs[i] ) / 100f;
}
return distance;
}
catch
{
throw new ApplicationException( "Failed parsing response from SRV-1." );
}
}