Solved

Serial communication-MSComm control in VC++

Posted on 2000-03-14
4
432 Views
Last Modified: 2013-11-20
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
Comment
Question by:karthik1979
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 3

Expert Comment

by:stefanr
ID: 2618733
Does the data contain embedded null characters ('\0')? The mscomm class does not handle those; instead it terminates the string returned there.
0
 

Author Comment

by:karthik1979
ID: 2620393
out of 5 bytes 1 and 5th byte are same .they resemble a special character which appear as letter I in bold
0
 

Accepted Solution

by:
orozco earned 100 total points
ID: 2878602

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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question