Exemplo n.º 1
0
        private void valueTrackBar1_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_gps_raw_int();

            if (GpsFixCheckBox.CheckState == CheckState.Unchecked)
            {
                tmp.fix_type = 0;
            }
            else if (GpsFixCheckBox.CheckState == CheckState.Indeterminate)
            {
                tmp.fix_type = 2;
            }
            else
            {
                tmp.fix_type = 3;
            }
            tmp.satellites_visible = (byte)valueTrackBar1.Value;

            p.ComponentId    = (int)MavLink.MAV_COMPONENT.MAV_COMP_ID_GPS;
            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");
        }
Exemplo n.º 2
0
        private void valueTrackBar1_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_gps_raw_int();
            if(GpsFixCheckBox.CheckState == CheckState.Unchecked)
                    tmp.fix_type = 0;
            else if(GpsFixCheckBox.CheckState == CheckState.Indeterminate)
                tmp.fix_type = 2;
            else {
                tmp.fix_type = 3;
            }
            tmp.satellites_visible = (byte)valueTrackBar1.Value;

            p.ComponentId = (int)MavLink.MAV_COMPONENT.MAV_COMP_ID_GPS;
            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");
        }