private void BatteryValueTrackBar_ValueChanged(object sender, EventArgs e) { if(!CommunicationPort.IsOpen) return; MavLink.Mavlink m = new MavLink.Mavlink(); MavLink.MavlinkPacket p = new MavLink.MavlinkPacket(); var tmp = new MavLink.Msg_sys_status(); tmp.current_battery = 100; tmp.voltage_battery = (ushort)(BatteryValueTrackBar.Value * 100); p.ComponentId = (int)MavLink.MAV_COMPONENT.MAV_COMP_ID_SYSTEM_CONTROL; p.SystemId = 1; p.SequenceNumber = (byte)seq++; p.TimeStamp = DateTime.Now; p.Message = tmp; byte[] buffer = m.Send(p); //tmp.Serialize(buffer, ref offset); log.Info("Send Message"); log.Info(buffer); log.Info("Offset: " + buffer.Length.ToString()); CommunicationPort.Write(buffer, 0, buffer.Length); CommunicationPort.Write("\r\n"); }
private void BatteryValueTrackBar_ValueChanged(object sender, EventArgs e) { if (!CommunicationPort.IsOpen) { return; } MavLink.Mavlink m = new MavLink.Mavlink(); MavLink.MavlinkPacket p = new MavLink.MavlinkPacket(); var tmp = new MavLink.Msg_sys_status(); tmp.current_battery = 100; tmp.voltage_battery = (ushort)(BatteryValueTrackBar.Value * 100); p.ComponentId = (int)MavLink.MAV_COMPONENT.MAV_COMP_ID_SYSTEM_CONTROL; p.SystemId = 1; p.SequenceNumber = (byte)seq++; p.TimeStamp = DateTime.Now; p.Message = tmp; byte[] buffer = m.Send(p); //tmp.Serialize(buffer, ref offset); log.Info("Send Message"); log.Info(buffer); log.Info("Offset: " + buffer.Length.ToString()); CommunicationPort.Write(buffer, 0, buffer.Length); CommunicationPort.Write("\r\n"); }