dear cd,
so how does I send this string to the comm port....
"<ENQ>02FFTT1ABCDE07"
and since this string is a PLC command there will be repond from the PLC if
this is send successfull. The PLC device Receive Data indicator stated it's
received but no respond??!???!! definately need help....below is my code.
//this is where I pass the data....
m_CommPort->Write( Encoding::ASCII->GetBytes(ch) );
m_CommPort->Write( Encoding::ASCII->GetBytes ("02FFTT1ABCDE07" ) );
Below is my class funciton....
// This function writes the passed array of bytes to the
// Comm Port to be written.
System::Void Write(Byte Buffer[])
{
DWORD iBytesWritten, iRc;
if (mhRS == (HANDLE)-1)
{
throw new ApplicationException(S"Please initialize and open port before
using this method");
}
else
{
// Transmit data to COM Port
if (meMode == Mode::Overlapped)
{
// Overlapped write
if (pHandleOverlappedWrite(Buffer))
throw new ApplicationException(S"Error in overlapped write");
}
else
{
// Clears IO buffers
PurgeComm(mhRS, PURGE_RXCLEAR | PURGE_TXCLEAR);
// Convert name from String to Ansi char string
System::Text::ASCIIEncoding* encoder = new System::Text::ASCIIEncoding();
Byte __pin* abytes = &Buffer[0];
iRc = WriteFile(mhRS, (char*)abytes, Buffer->Length, &iBytesWritten, 0);
if (iRc == 0)
{
String* strErr = String::Format(S"Write Error - Bytes Written {0} of
{1}", iBytesWritten.ToString(), Buffer->Length.ToString());
throw new ApplicationException(strErr);
}
}
}
}
// This function writes the passed string to the
// Comm Port to be written.
System::Void Write(String* Buffer)
{
System::Text::ASCIIEncoding* oEncoder = new System::Text::ASCIIEncoding();
Byte aByte[] = oEncoder->GetBytes(Buffer);
this->Write(aByte);
}