AForge.Robotics.Surveyor.SRV1.I2CReadByte C# (CSharp) Method

I2CReadByte() public method

Read byte from I2C device.
Not connected to SRV-1. Connect to SRV-1 before using /// this method. Connection lost or communicaton failure. Try to reconnect. Failed parsing response from SRV-1.
public I2CReadByte ( byte deviceID, byte register ) : byte
deviceID byte I2C device ID (7 bit notation).
register byte I2C device register to read.
return byte
        public byte I2CReadByte( byte deviceID, byte register )
        {
            byte[] response = new byte[100];

            int    read = SendAndReceive( new byte[] { (byte) 'i', (byte) 'r', deviceID, register }, response );
            string str  = System.Text.ASCIIEncoding.ASCII.GetString( response, 0, read );

            try
            {
                str = str.Trim( );
                // split string into separate values
                string[] strs = str.Split( ' ' );

                return byte.Parse( strs[1] );
            }
            catch
            {
                throw new ApplicationException( "Failed parsing response from SRV-1." );
            }
        }