
User Guide
- 42
–
String Textcom= "GLG";
int Command_CRC;
Timer1->Enabled = false;
Cmd33->Enabled = false;
Command = Textcom.c_str();
Command_CRC = CalcCRC8(0, Command, 3); // Calculate CRC8 for the
command “GLG”
Screen->Cursor = crHourGlass;
// Show hourglass
cursor
Application->ProcessMessages();
while (Tries--)
{
ComPort->FlushInBuffer();
ComPort->FlushOutBuffer();
ComPort->PutString(Textcom);
// send the
command “GLG”
ComPort->PutChar(Asc[Command_CRC>>4]);
// send the
CRC8 in hex string
ComPort->PutChar(Asc[Command_CRC & (0xF)]);
// send the CRC8
in hex string
ComPort->PutChar('\r');
a=0;
UnitResponse = "";
TimeOut = false;
TimeOutTimer = 1;
while (TimeOutTimer) Application->ProcessMessages();
if (a == '\r')
{
a = 0;
if (CompareCRC())
// Check if the data is
received correctly
{
if ( strcmp(RdPtr, "Err") == 0) {
MessageDlg("Command is wrong", mtError, TMsgDlgButtons() <<
mbCancel, NULL);
Screen->Cursor = crDefault;
Cmd33->Enabled = true;
Timer1->Enabled = true;
Application->ProcessMessages();