|
너무 늦지 않았으면 좋겠내요
시리얼 포트 컴포넌트 구조도 알아야 합니다 어느정도
이해도 하셔야 하구요
void __fastcall TFrm_Main::Message_send()
{
// SendMsg[] byte 타입으로 서언했음
AnsiString sMsg;
int Crc = 0;
SendMsg[0] = 0xAB;
SendMsg[1] = 0x01;
SendMsg[2] = StrToInt(Edt_RoomNo->Text);
sMsg = Mem_Message->Text;
for (int i = 4; i < 204 ;i++)
{
if (sMsg.Length() < i-4 ) { SendMsg[i] = 0x00; } // null
else { SendMsg[i] = sMsg[i-8]; }
}
SendIndex = 1;
SendCount = 209;
// 이부분은 몇바이트씩 처리할지 생각하시면 됩니다
// 1바이트 씩 던지면 이렇게 하시고요
// 처음 1바이트만 던지면 아래 CTSChange 이벤트가 발생합니다.
// 그럼 거기서 자동 또 계속 던지면 되고요
SendBuf[0] = SendMsg[0];
Cpt_Port->Write(SendMsg,1);
}
//---------------------------------------------------------------------------
void __fastcall TFrm_Main::Cpt_PortCTSChange(TObject *Sender, bool OnOff)
{
if (!OnOff)
{
if (SendIndex <= SendCount)
{
SendBuf[0] = SendMsg[SendIndex];
Cpt_Port->Write(SendBuf,1);
SendIndex++;
}
}
}
//---------------------------------------------------------------------------
|