MSComm and SetOutput()....how?
I'm a little confused about the use of MSComm::SetOutput(). I'd like to output one single byte, but am not sure how to do so using the proper parameter.
The prototype says to use a VARIANT, but I don't think I am correctly doing so.
Can anybody help me out? Thanks for your assistance!
Thanks,
Phil
Re: MSComm and SetOutput()....how?
Hello, maybe this is a little bit late :p
since it has been almost three years since this message was posted by PhilipG. But for the last couple days I've been having the same problem. And luckily I found this code somewhere in a Chinese website (which my web browser doesn't even able to display the chinese text, but of course the codes are writen in ANSI standard character :D)
The major problem of sending single byte using MSComm::SetOutput() function is about converting BYTE (unsigned char) data types into struct VARIANT data types..
I am using the SNAP protocol (http://www.hth.com/snap/)
so here is the codes:
CByteArray OutBuf;
COleVariant varOutput;
OutBuf.SetSize(OutPacket.NumOfBytes);
unsigned int i;
for(i=0 ; i<OutPacket.NumOfBytes ; i++)
{
OutBuf[i] = OutPacket.PacketBytes[i];
}
varOutput = OutBuf;
m_ctlSerialComm.SetOutput(varOutput);
Hope this will be usefull..
Regards,
Leo