public const byte CALL = 0x24;
public const byte OK = 0x00;
public const byte SUCC = 0x2A;
public const byte Err = 0xF0;
public const byte PASS = 0xaa;
public const byte FAIL = 0x55;
...
byte[] buffer ={ CALL, 0x02, 0x02, 0x22, 0x22 };
serialPort.Write(buffer, 0, 1);
int temp = serialPort.ReadByte();
if (temp == OK)
{
//this.result.BackColor = System.Drawing.Color.FromArgb(250, 250, 0);
serialPort.Write(buffer, 1, 4);
temp = serialPort.ReadByte();
if (temp == SUCC)
{
temp = serialPort.ReadByte();
if (temp == PASS)
this.result.BackColor = System.Drawing.Color.FromArgb(0, 255, 0);
else
if (temp == FAIL)
this.result.BackColor = System.Drawing.Color.FromArgb(255, 0, 0);
} }
用delphi里的TComm怎麼寫?謝謝
public const byte OK = 0x00;
public const byte SUCC = 0x2A;
public const byte Err = 0xF0;
public const byte PASS = 0xaa;
public const byte FAIL = 0x55;
...
byte[] buffer ={ CALL, 0x02, 0x02, 0x22, 0x22 };
serialPort.Write(buffer, 0, 1);
int temp = serialPort.ReadByte();
if (temp == OK)
{
//this.result.BackColor = System.Drawing.Color.FromArgb(250, 250, 0);
serialPort.Write(buffer, 1, 4);
temp = serialPort.ReadByte();
if (temp == SUCC)
{
temp = serialPort.ReadByte();
if (temp == PASS)
this.result.BackColor = System.Drawing.Color.FromArgb(0, 255, 0);
else
if (temp == FAIL)
this.result.BackColor = System.Drawing.Color.FromArgb(255, 0, 0);
} }
用delphi里的TComm怎麼寫?謝謝
我不知道serialPort.Write(buffer, 1, 4);
temp = serialPort.ReadByte();
所實現的在delphi里用哪個?