Created
April 6, 2011 15:02
-
-
Save MKo-xx/905796 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
private Thread receive_thread = null; | |
private void button1_Click(object sender, EventArgs e) | |
{ | |
if (null != receive_thread) | |
{ | |
receive_thread.Abort(); | |
} | |
receive_thread = new Thread(receive_data); | |
receive_thread.Start(); | |
} | |
private UdpClient receiving_UdpClient = new UdpClient(49001); | |
private void receive_data() | |
{ | |
while (true) | |
{ | |
IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0); | |
Byte[] receiveBytes = receiving_UdpClient.Receive(ref RemoteIpEndPoint); | |
string[] data = Encoding.ASCII.GetString(receiveBytes).Split(','); | |
float aileron = float.Parse(data[0]); | |
aileron_recv_textBox.Text = aileron.ToString(); | |
float elevator = float.Parse(data[1]); | |
elevator_recv_textBox.Text = elevator.ToString(); | |
float throttle = float.Parse(data[2]); | |
throttle_recv_textBox.Text = throttle.ToString(); | |
float airpeed = float.Parse(data[3]); | |
airspeed_recv_textBox.Text = airpeed.ToString(); | |
Thread.Sleep(80); | |
} | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment