By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,225 Members | 2,223 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,225 IT Pros & Developers. It's quick & easy.

Transmit binary byte on serial port ?

P: n/a
we have a project to transmit and receive data on serial port (i modify it
from VCTERM on MSDN). To transmit text byte I use :
void CMainFrame::TxString(CString str)
{
CString s;
VARIANT vCommOut;
vCommOut.vt = VT_BSTR;
vCommOut.bstrVal = str.AllocSysString();
mCommCtrl.SetOutBufferCount(0);
mCommCtrl.SetOutput(vCommOut);
SysFreeString(vCommOut.bstrVal);

while(mCommCtrl.GetOutBufferCount()>0)
DoEvents();
}

it run OK, unless the byte that has value 0x00.

to resolve that, I use :
void CMainFrame::TxByte(unsigned char ch)
{
VARIANT vCommOut;
vCommOut.vt = VT_UI1;
vCommOut.bVal = ch;
mCommCtrl.SetOutBufferCount(0);
mCommCtrl.SetOutput(vCommOut);

while(mCommCtrl.GetOutBufferCount()>0)
DoEvents();
}

when I run it, system gives error message "invalid value" at line:
mCommCtrl.SetOutput(vCommOut);

Please give me a solution to transmit binary byte.
Thank regard !
Nov 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.