Serial communication-MSComm control in VC++

Posted on 2000-03-14
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
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.
Question by:karthik1979

Expert Comment

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

Author Comment

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

Accepted Solution

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.

Expert Comment

ID: 3771279

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to create frequencies of a variable from SAS dataset? 10 121
mixString challenge 36 111
Detect CR LF to each line 12 153
noX challenge 17 92
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: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now