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

I2CReadWord() public method

Read word 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 I2CReadWord ( byte deviceID, byte register ) : ushort
deviceID byte I2C device ID (7 bit notation).
register byte I2C device register to read.
return ushort
        public ushort I2CReadWord( 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 ushort.Parse( strs[1] );
            }
            catch
            {
                throw new ApplicationException( "Failed parsing response from SRV-1." );
            }
        }