E
espro88
Guest
Hi everyone,
I'm having some trouble sending a string and hex command to a serial port using C#. I need to send a string to a display and then save that string with a hex command. The hex command to change the start up command is FE 40. Although, I am able to successfully print the string on the display, I don't know how to save it. When starting the display that string should show up on the start-up screen. Should I convert the string to hex before sending it with the hex command? I'm new to C# so any help would be appreciated. This is what I have so far.
// write to screen
private void btnWrite_Click(object sender, EventArgs e)
{
string str = tbLine1.Text + tbLine2.Text + tbLine3.Text + tbLine4.Text;
byte[] splash_str = Encoding.ASCII.GetBytes(str);
byte[] change_screen = new byte[2] { 0xFE, 0x40 };
try
{
sp.Write(splash_str, 0, splash_str.Length);
//sp.Write(str);
sp.Write(change_screen, 0, change_screen.Length);
}
catch (Exception E) { MessageBox.Show(E.ToString(), "Error"); }
}
Continue reading...
I'm having some trouble sending a string and hex command to a serial port using C#. I need to send a string to a display and then save that string with a hex command. The hex command to change the start up command is FE 40. Although, I am able to successfully print the string on the display, I don't know how to save it. When starting the display that string should show up on the start-up screen. Should I convert the string to hex before sending it with the hex command? I'm new to C# so any help would be appreciated. This is what I have so far.
// write to screen
private void btnWrite_Click(object sender, EventArgs e)
{
string str = tbLine1.Text + tbLine2.Text + tbLine3.Text + tbLine4.Text;
byte[] splash_str = Encoding.ASCII.GetBytes(str);
byte[] change_screen = new byte[2] { 0xFE, 0x40 };
try
{
sp.Write(splash_str, 0, splash_str.Length);
//sp.Write(str);
sp.Write(change_screen, 0, change_screen.Length);
}
catch (Exception E) { MessageBox.Show(E.ToString(), "Error"); }
}
Continue reading...