Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

receiving bytes instead of characters with MSComm

Status
Not open for further replies.

zaknwfp

Technical User
Jul 30, 2004
5
US
I have been trying to receive raw bytes on serial port using MScomm with visual C++6.0 but I don't know how to get the decimal or hex value from the function getInput(). I can get the string out of the function but then it becomes a character. For example if I receive 0x35, it becomes 5. Here is part of the code

if (m_comm.GetCommEvent()==2 )
{
VARIANT in_dat;
in_dat = m_comm.GetInput();

CString strInput(in_dat.bstrVal);

m_edit2 = strInput;// + m_edit2;

UpdateData(FALSE);
}
Can somebody help me with this please?
 
Code:
char buffer[100];
char *str_ptr;
int result;

str_ptr=buffer;

do *(str_ptr++) = m_comm.GetInput();
while(...);

*str_ptr=0;
sscanf(buffer, "%d", &result);
 
Thanks a bunch mingis,its a big help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top