Пример #1
0
        // Need to test communication? Example of a reset command: "#bR@T\r"
        private void buttonReset_Click(object sender, EventArgs e)
        {
            Stream serialStream = simpleSerialPort.Port.BaseStream;

            byte[] bytes = FlightControllerMessage.CreateMessage('R', 1);
            serialStream.Write(bytes, 0, bytes.Length);
        }
Пример #2
0
        private void buttonVersion_Click(object sender, EventArgs e)
        {
            try
            {
                sbyte yaw      = Convert.ToSByte(textBoxYaw.Text);
                sbyte pitch    = Convert.ToSByte(textBoxPitch.Text);
                sbyte roll     = Convert.ToSByte(textBoxRoll.Text);
                byte  throttle = Convert.ToByte(textBoxThrottle.Text);

                ExternControl cmd     = new ExternControl(yaw, pitch, roll, throttle);
                byte[]        message = FlightControllerMessage.CreateMessage('b', 1, cmd.Bytes);
                serialCommunicationManager.Send(message);
            }
            catch (OverflowException exc)
            {
                Console.WriteLine("The command in one of the text boxes is out of range.");
            }
            catch (InvalidOperationException exc)
            {
                Console.WriteLine("Could not read from serial port.  Is it open? Exception:" + exc.ToString());
            }
        }