Yep!
Here's the server code, really simple LV server, went off a youtube tutorial
Here's the C# code to read the stream, note that this reads every 20ms.
Code:
private void timUpdate_Tick(object sender, EventArgs e)
{
//update revolutions X and Y and the Gyro Angle every 20ms from the server string value
//and make sure the connection is solid, otherwise update connection
Byte[] info = new Byte[Client.ReceiveBufferSize];
try
{
int rData = stream.Read(info, 0, System.Convert.ToInt32(Client.ReceiveBufferSize));
RobotData = System.Convert.ToString(rData);
}
catch (System.IO.IOException)
{
lblConnectInd.BackColor = System.Drawing.Color.Red;
Log("The robot ended the stream.");
stream.Close();
Client.Close();
}
//split string into X, Y and angle
strRevX = RobotData.Substring(0, 2);
strRevY = RobotData.Substring(5, 2);
strAngle = RobotData.Substring(8, 2);
//update values recieved in GUI
lblX.Text = strRevX;
lblY.Text = strRevY;
lblAngle.Text = strAngle;
//convert separated strings into doubles
Double.TryParse(strRevX, out dblRevolutionsX);
Double.TryParse(strRevX, out dblRevolutionsY);
Double.TryParse(strAngle, out dblAngle);
//make sure we're still connected
if (Client.Connected == true)
{
lblConnectInd.BackColor = System.Drawing.Color.Green;
}
else
{
lblConnectInd.BackColor = System.Drawing.Color.Red;
timUpdate.Stop();
}
}
Other than the jumbled string, it works great!