When I execute this code (visual studio, C#):
//Read module type
commando[0] = 254;
commando[1] = 55;
port.Write(commando, 0, commando.Length);
int length = port.BytesToRead;
byte[] buf = new byte[length];
port.Read(buf, 0, length);
Console.WriteLine("Received data: " + buf);
I don't get the expected answer from the LCD.
Putting text on the screen and changing the font types etc, is no problem but receiving the Module type is./
What am I missing??
Trouble with Read Module Type in C#
Trouble with Read Module Type in C#
With kind regards,
Paul Joosten
BMO Offshore Measurements Systems BV
Rotterdam, the Netherlands
Paul Joosten
BMO Offshore Measurements Systems BV
Rotterdam, the Netherlands
Re: Trouble with Read Module Type in C#
Hi Paul,
I assume you are getting something along the lines of 'System.Byte[]' being wrtten to your console.
Try this:
//Read module type
byte[] commando = new byte[2];
commando[0] = 254;
commando[1] = 55;
port.Write(commando, 0, commando.Length);
int length = port.BytesToRead;
byte[] buf = new byte[length];
port.Read(buf, 0, length);
Console.WriteLine("Received data: " + buf[0]);
Note the change I made above in red.
This should work for you. You will see the response written on the console.
If you have any other questions or concerns please feel free to ask.
Thank you for posting on your forums.
Martino
I assume you are getting something along the lines of 'System.Byte[]' being wrtten to your console.
Try this:
//Read module type
byte[] commando = new byte[2];
commando[0] = 254;
commando[1] = 55;
port.Write(commando, 0, commando.Length);
int length = port.BytesToRead;
byte[] buf = new byte[length];
port.Read(buf, 0, length);
Console.WriteLine("Received data: " + buf[0]);
Note the change I made above in red.
This should work for you. You will see the response written on the console.
If you have any other questions or concerns please feel free to ask.
Thank you for posting on your forums.
Martino
Martino DeLeon
Matrix Orbital
Technical Support Representative
Matrix Orbital
Technical Support Representative
Re: Trouble with Read Module Type in C#
Hi Martino,
Thanks for your reply.
The problem was that I had to wait 50 milliseconds for the display.
So I added this line:
comport.Write(commando2Bytes, 0, commando2Bytes.Length);
int milliseconds = 50;
Thread.Sleep(milliseconds);
regards
Paul
Thanks for your reply.
The problem was that I had to wait 50 milliseconds for the display.
So I added this line:
comport.Write(commando2Bytes, 0, commando2Bytes.Length);
int milliseconds = 50;
Thread.Sleep(milliseconds);
regards
Paul
Last edited by PaulBMO on Tue Apr 08, 2014 7:39 am, edited 1 time in total.
With kind regards,
Paul Joosten
BMO Offshore Measurements Systems BV
Rotterdam, the Netherlands
Paul Joosten
BMO Offshore Measurements Systems BV
Rotterdam, the Netherlands
Re: Trouble with Read Module Type in C#
Hi Paul,
That's great that you found a solution.
Again thank you for posting on our forums.
If you have any other questions or concerns please feel free to ask.
Thank you
Martino
That's great that you found a solution.
Again thank you for posting on our forums.
If you have any other questions or concerns please feel free to ask.
Thank you
Martino
Martino DeLeon
Matrix Orbital
Technical Support Representative
Matrix Orbital
Technical Support Representative