AForge.Robotics.Lego.NXTBrick.GetDeviceInformation C# (CSharp) Метод

GetDeviceInformation() публичный Метод

Get information about NXT device.
public GetDeviceInformation ( string &deviceName, byte &btAddress, int &btSignalStrength, int &freeUserFlash ) : bool
deviceName string Device name.
btAddress byte Bluetooth address.
btSignalStrength int Bluetooth signal strength.
freeUserFlash int Free user Flash.
Результат bool
        public bool GetDeviceInformation( out string deviceName, out byte[] btAddress, out int btSignalStrength, out int freeUserFlash )
        {
            byte[] reply = new byte[33];

            if ( SendCommand( new byte[] { (byte) NXTCommandType.SystemCommand,
                (byte) NXTSystemCommand.GetDeviceInfo }, reply ) )
            {
                // devince name
                deviceName = System.Text.ASCIIEncoding.ASCII.GetString( reply, 3, 15 );
                // Bluetooth address
                btAddress = new byte[7];
                Array.Copy( reply, 18, btAddress, 0, 7 );
                // Bluetooth signal strength
                btSignalStrength = reply[25] | ( reply[26] << 8 ) |
                    ( reply[27] << 16 ) | ( reply[28] << 24 );
                // free user Flash
                freeUserFlash = reply[29] | ( reply[30] << 8 ) |
                    ( reply[31] << 16 ) | ( reply[32] << 24 );

                return true;
            }

            deviceName = null;
            btAddress = null;
            btSignalStrength = 0;
            freeUserFlash = 0;

            return false;
        }