nxtlib/src/Protocol.cs
/// <summary>
/// [Native] Writes an array of bytes to a lowspeed sensor port.
/// </summary>
/// <param name="port">The port of the attached sensor.</param>
/// <param name="txData">The tx Data to be written.</param>
/// <param name="rxDataLength">The rx Data Length. </param>
[Native] Writes an array of bytes to a lowspeed sensor port.
[ Native ] Writes an array of bytes to a lowspeed sensor port .
public void LowspeedWrite(SensorPort port, byte[] txData, byte rxDataLength)
        {
            byte txDataLength = (byte)txData.Length;
            if (txDataLength == 0)
                throw new NXTException("No data to send.");
            if (txDataLength > 16)
                throw new NXTException("Tx data may not exceed 16 bytes.");
            if (rxDataLength < 0 || 16 < rxDataLength)
                throw new NXTException("Rx data length should be in the interval 0-16.");
            byte[] request = new byte[5 + txDataLength];
            request[0] = (byte)(0x00);
            request[1] = (byte)DirectCommand.LSWrite;
            request[2] = (byte)port;
            request[3] = txDataLength;
            request[4] = rxDataLength;
            txData.CopyTo(request, 5);
            CompleteRequest(request);
            return;
        }
public void LowspeedWrite ( SensorPort port , byte [ ] txData , byte rxDataLength ) { byte txDataLength = ( byte ) txData . Length ; if ( txDataLength == 0 ) throw new NXTException ( " " ) ; if ( txDataLength > 16 ) throw new NXTException ( " " ) ; if ( rxDataLength < 0 || 16 < rxDataLength ) throw new NXTException ( " " ) ; byte [ ] request = new byte [ 5 + txDataLength ] ; request [ 0 ] = ( byte ) ( 0x00 ) ; request [ 1 ] = ( byte ) DirectCommand . LSWrite ; request [ 2 ] = ( byte ) port ; request [ 3 ] = txDataLength ; request [ 4 ] = rxDataLength ; txData . CopyTo ( request , 5 ) ; CompleteRequest ( request ) ; return ; }
[Native] Writes an array of bytes to a lowspeed sensor port.
[ Native ] Writes an array of bytes to a lowspeed sensor port .
port
SensorPort
The port of the attached sensor.
The port of the attached sensor .
txData
byte[]
The tx Data to be written.
The tx Data to be written .
rxDataLength
byte
The rx Data Length.
The rx Data Length .