|
-
Jan 8th, 2002, 01:07 PM
#1
Thread Starter
Addicted Member
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
-
Jun 21st, 2005, 09:18 PM
#2
New Member
Re: MSComm and SetOutput()....how?
Hello, maybe this is a little bit late 
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 )
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|