I have tried probably 6 different ways. I am just too much of a beginner, when it come to this. I need to be able to get this Axis Position info., below is an example of position 30000 and 0.
This is what comes into the serial port, after I send a request for Position info. - Other times it may be Velocity I am trying to read. Which would be anywhere from 100 to 33000.
Here is what I am trying to read:
Hex Ascii
FF 2F 30 60 33 30 30 30 30 03 ÿ/0`30000.
Sometimes this:
FF 2F 30 60 30 03 ÿ/0`0.
I have already sent request to my controller. It has already sent back my reply. I can see it with my terminal programs. But my program just doesn't work. I have tried to use .ReadByte and .ReadExisting, with no success.
//BUTTON TO READ THE PORT AND ATTEMPT TO CONVERT DATA TO USABLE DATA.
private void Com10rcvbutton_Click(object sender, EventArgs e)
{
try
{
string line = serialPort1.ReadLine();
StreamReader sr = new StreamReader(line);
sr.BaseStream.Position = 0x04;
byte[] buffer = new byte[0];
sr.BaseStream.Read(buffer, 4, 8);
foreach (byte myByte in buffer)
textBox1.Text += myByte.ToString("X") + " ";
sr.Dispose();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
MessageBox.Show("Your Serial Test Code is Done");
}
}
Thanks for your help in advance...