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

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

Read data from Low Speed bus.
public LsRead ( Sensor sensor, byte readValues, int &bytesRead ) : bool
sensor Sensor Sensor to read data from.
readValues byte Array to read data to.
bytesRead int Bytes actually read from I2C device.
Результат bool
        public bool LsRead( Sensor sensor, byte[] readValues, out int bytesRead )
        {
            byte[] command = new byte[3];
            byte[] reply = new byte[20];

            // prepare message
            command[0] = (byte) NXTCommandType.DirectCommand;
            command[1] = (byte) NXTDirectCommand.LsRead;
            command[2] = (byte) sensor;

            if ( SendCommand( command, reply ) )
            {
                bytesRead = reply[3];
                Array.Copy( reply, 4, readValues, 0, Math.Min( readValues.Length, bytesRead ) );
                return true;
            }

            bytesRead = -1;
            return false;
        }