theglen
Guest
T
Hi everyone,
i've encountered some problems during communication between PC and VersaMax using SNP. i'm using borland builder C++ 5.0. i've opened the port successsfully. i connected my PC to other PC and that PC ables to receive characters in HyperTerminal. the following are my code:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
SendAttachMessage();
Sleep(1000);
ReceiveResponseMessage();
}
void TForm1::ReceiveResponseMessage(void)
{
DWORD read_dwBytesTransferred = 0;
ReadFile(comm_port, &response_buf, 24, &read_dwBytesTransferred, 0);
}
void TForm1::SendAttachMessage(void)
{
BYTE msg_buf[24];
BYTE *msg_buf_ptr = msg_buf;
DWORD read_iBytesWritten = 0;
*msg_buf_ptr++ = 0x1b; //start message character - 1bh
*msg_buf_ptr++ = 0x41; //message type character - 41h
*msg_buf_ptr++ = 0x33; //CPU ID - "33101A"
*msg_buf_ptr++ = 0x33;
*msg_buf_ptr++ = 0x31;
*msg_buf_ptr++ = 0x30;
*msg_buf_ptr++ = 0x31;
*msg_buf_ptr++ = 0x41;
*msg_buf_ptr++ = 0x00;
*msg_buf_ptr++ = 0x00;
*msg_buf_ptr++ = 0x30; //T1 value - 10ms
*msg_buf_ptr++ = 0x41;
*msg_buf_ptr++ = 0x30;
*msg_buf_ptr++ = 0x30;
*msg_buf_ptr++ = 0x30; //Reserved, set to 30h
*msg_buf_ptr++ = 0x20; //Reserved, set to 20h
*msg_buf_ptr++ = 0x20; //Reserved, set to 20h
*msg_buf_ptr++ = 0x20; //Reserved, set to 20h
*msg_buf_ptr++ = 0x17; //End of block character - 17h
*msg_buf_ptr++ = 0x00; //Next Message Type - 00h
*msg_buf_ptr++ = 0x00; //Next Message Length - 0000h
*msg_buf_ptr++ = 0x00;
*msg_buf_ptr++ = 0x38; //BCC
*msg_buf_ptr = 0x35;
WriteFile(comm_port, &msg_buf, 24, &read_iBytesWritten, NULL);
}
i able to send my message to PLC but there is no response from PLC. what's the problem? by the way, what is CPU ID? is it same with SNP ID in the VersaPro?
thank you very much.
regards,
goh
i've encountered some problems during communication between PC and VersaMax using SNP. i'm using borland builder C++ 5.0. i've opened the port successsfully. i connected my PC to other PC and that PC ables to receive characters in HyperTerminal. the following are my code:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
SendAttachMessage();
Sleep(1000);
ReceiveResponseMessage();
}
void TForm1::ReceiveResponseMessage(void)
{
DWORD read_dwBytesTransferred = 0;
ReadFile(comm_port, &response_buf, 24, &read_dwBytesTransferred, 0);
}
void TForm1::SendAttachMessage(void)
{
BYTE msg_buf[24];
BYTE *msg_buf_ptr = msg_buf;
DWORD read_iBytesWritten = 0;
*msg_buf_ptr++ = 0x1b; //start message character - 1bh
*msg_buf_ptr++ = 0x41; //message type character - 41h
*msg_buf_ptr++ = 0x33; //CPU ID - "33101A"
*msg_buf_ptr++ = 0x33;
*msg_buf_ptr++ = 0x31;
*msg_buf_ptr++ = 0x30;
*msg_buf_ptr++ = 0x31;
*msg_buf_ptr++ = 0x41;
*msg_buf_ptr++ = 0x00;
*msg_buf_ptr++ = 0x00;
*msg_buf_ptr++ = 0x30; //T1 value - 10ms
*msg_buf_ptr++ = 0x41;
*msg_buf_ptr++ = 0x30;
*msg_buf_ptr++ = 0x30;
*msg_buf_ptr++ = 0x30; //Reserved, set to 30h
*msg_buf_ptr++ = 0x20; //Reserved, set to 20h
*msg_buf_ptr++ = 0x20; //Reserved, set to 20h
*msg_buf_ptr++ = 0x20; //Reserved, set to 20h
*msg_buf_ptr++ = 0x17; //End of block character - 17h
*msg_buf_ptr++ = 0x00; //Next Message Type - 00h
*msg_buf_ptr++ = 0x00; //Next Message Length - 0000h
*msg_buf_ptr++ = 0x00;
*msg_buf_ptr++ = 0x38; //BCC
*msg_buf_ptr = 0x35;
WriteFile(comm_port, &msg_buf, 24, &read_iBytesWritten, NULL);
}
i able to send my message to PLC but there is no response from PLC. what's the problem? by the way, what is CPU ID? is it same with SNP ID in the VersaPro?
thank you very much.
regards,
goh