public async void WriteToRobot(DeviceMessage message) { RobotSession robotSession = this; Int32 num = robotSession._seqNum; Int32 num1 = num; robotSession._seqNum = num + 1; if (num1 >= 255) { _seqNum = 0; } message.setSequence((Byte)_seqNum); Byte[] data = message.Data; DataWriter dataWriter = new DataWriter(); try { dataWriter.WriteBytes(data); await _socket.OutputStream.WriteAsync(dataWriter.DetachBuffer()); } finally { if (dataWriter != null) { dataWriter.Dispose(); } } }
public void Roll(Int32 heading, Single speed) { Byte num = (Byte)(speed * 255f); Byte[] numArray = Value.BytesForInt(Value.clamp(heading, 0, 359)); Byte[] numArray1 = new Byte[] { num, numArray[0], numArray[1], 1 }; DeviceMessage deviceMessage = new DeviceMessage(2, 48, numArray1, DeviceMessage.SopParameters.ResetTimeout); deviceMessage.NoResponse(); base.WriteToRobot(deviceMessage); }
public void SetRGBLED(Int32 red, Int32 green, Int32 blue) { red = Value.clamp(red, 0, 255); green = Value.clamp(green, 0, 255); blue = Value.clamp(blue, 0, 255); Byte[] numArray = new Byte[] { (Byte)red, (Byte)green, (Byte)blue, 1 }; DeviceMessage deviceMessage = new DeviceMessage(2, 32, numArray, DeviceMessage.SopParameters.ResetTimeout); deviceMessage.NoResponse(); base.WriteToRobot(deviceMessage); }
public void WriteToRobot(DeviceMessage msg) { if (ConnectionState == ConnectionState.Connected) { _session.WriteToRobot(msg); } }