public void TestDebugMessage() { State.Reset(); DebugMessage dm = new DebugMessage(); SendBytes(State, dm.ToTx()); Telemetry.WaitForHandle(); Assert.IsInstanceOfType(LatestReceived, typeof(DebugMessage)); Assert.AreEqual("",(LatestReceived as DebugMessage).Message); dm = new DebugMessage("Test message"); SendBytes(State, dm.ToTx()); Telemetry.WaitForHandle(); Assert.IsInstanceOfType(LatestReceived, typeof(DebugMessage)); Assert.AreEqual("Test message", (LatestReceived as DebugMessage).Message); }
public static KFlyCommand Parse(List<Byte> bytes) { if (bytes.Count > 3) { KFlyCommand cmd = null; switch ((KFlyCommandType)(bytes[1])) { case KFlyCommandType.DebugMessage: cmd = new DebugMessage(); break; case KFlyCommandType.Ping: cmd = new Ping(); break; case KFlyCommandType.GetDeviceInfo: cmd = new GetDeviceInfo(); break; case KFlyCommandType.GetSensorData: cmd = new GetSensorData(); break; case KFlyCommandType.GetEstimationAttitude: cmd = new GetEstimationAttitude(); break; case KFlyCommandType.GetRawSensorData: cmd = new GetRawSensorData(); break; case KFlyCommandType.GetRateControllerData: cmd = new GetRateControllerData(); break; case KFlyCommandType.GetAttitudeControllerData: cmd = new GetAttitudeControllerData(); break; case KFlyCommandType.GetSensorCalibration: cmd = new GetSensorCalibration(); break; case KFlyCommandType.GetChannelMix: cmd = new GetChannelMix(); break; case KFlyCommandType.GetRCCalibration: cmd = new GetRCCalibration(); break; case KFlyCommandType.GetRCValues: cmd = new GetRCValues(); break; case KFlyCommandType.GetArmSettings: cmd = new GetArmSettings(); break; case KFlyCommandType.ACK: cmd = new Ack(); break; default: cmd = new NotImplemented((KFlyCommandType)(bytes[1])); break; } if (cmd != null) { List<byte> data = bytes.GetRange(4, bytes.Count-4); cmd.ParseData(data); } return cmd; } return null; }