59 api / vcom commands appendix, Basic example for setting half/full duplex mode – Hatteland Display HT B22 (Fanless) User Manual
Page 59

59
API / VCOM Commands
Appendix
IND100077-132
Basic Example for setting Half/Full Duplex Mode
Example using Microsoft® Visual Studio 2012, C# style.
Note,
COM7
has been used as port ID. It may differ depending on your system installation. In any case, simply write
COM
x
(where
x
is the number defined by the Operating System automatically) for Virtual COM Port.
using
System.IO.Ports;
namespace
CS100031_1_VCOM_Example
{
public partial class
Form1
:
Form
{
private
SerialPort
serialPort;
public
Form1()
{
InitializeComponent();
OpenComPort();
//Opens COM port with Baudrate 9600.
}
public void
OpenComPort()
{
serialPort =
new
SerialPort
(“
COM7
”, 9600,
Parity
.None, 8,
StopBits
.One);
serialPort.
Handshake
= Handshake.None;
serialPort.Open();
}
private void
btnQDUHalf_Click(
object
sender,
EventArgs
e)
//Set Half Duplex
{
byte
[] message =
new byte
[9] { 0x07, 0xFF, 0x51, 0x44, 0x55, 0x01, 0x0E, 0x00, 0xFF };
serialPort.Write(message, 0, message.Length);
}
private void
btnQDUFull_Click(
object
sender,
EventArgs
e)
//Set Full Duplex
{
byte
[] message =
new byte
[9] { 0x07, 0xFF, 0x51, 0x44, 0x55, 0x01, 0x0E, 0xFF, 0x00 };
serialPort.Write(message, 0, message.Length);
}
}
}
Visual Example: