Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 443
  • Last Modified:

Serial communication-MSComm control in VC++

I am using MSComm control in VC++. I could write a data into the port . But according to my project 5 bytes should arrive to PC. but when i say
VARIANT a;
a=m_comm.GetInput();
it is returning a bstr which contains only one byte of data of length 1. But the same is perfectly working in VB. I could'nt trace out where is the problem.
0
karthik1979
Asked:
karthik1979
1 Solution
 
stefanrCommented:
Does the data contain embedded null characters ('\0')? The mscomm class does not handle those; instead it terminates the string returned there.
0
 
karthik1979Author Commented:
out of 5 bytes 1 and 5th byte are same .they resemble a special character which appear as letter I in bold
0
 
orozcoCommented:

You have to declare your a variable as the following:

int CControlComView::ReadCharacter(_bstr_t *a)
{
  *a = m_MSComm1.GetInput();
  return a->length();
}

you don't have to declare "a" as a variant.

good luck.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now