LACHEZAR
September 10th, 2003, 07:48 AM
I try to write communication program using
Serial Port & WIN32 API .
Something like - WINDOWS \ Accessories \ Hyper Terminal component.
I use that program for my tests. I have no problem to send information ! But I have some difficulties to receive information from Hyper Terminal to my program ?
- problem concerning synchronization - I need to read more about the serial communication as a strategy .
- problem concerning symbol convertion - my buffer is
BYTE type ... do I need to convert it to char type ?
I'm not sure , if I need to organize some reseivning cycle - what must be my approach ?
{
BYTE ReadData[11];
char ReadData[11];
DWORD ReadBytes = 10;
BOOL RetVal;
CString string;
ReadData[0] = 48L;
...............................
ReadData[9] = 48L;
RetVal = ReadFile(CommInfo.ComDev, ReadData, ReadBytes, &ReadBytes,
NULL);
if (!RetVal)
{
string.Format(_T("FAIL to RECEIVE data !"));
AfxMessageBox(string);
return(1);
}
ReadData[10] = '\0';
string.Format(_T("%s"), &ReadData[0]);
AfxMessageBox(string);
return 0;
}
Thank You !
Serial Port & WIN32 API .
Something like - WINDOWS \ Accessories \ Hyper Terminal component.
I use that program for my tests. I have no problem to send information ! But I have some difficulties to receive information from Hyper Terminal to my program ?
- problem concerning synchronization - I need to read more about the serial communication as a strategy .
- problem concerning symbol convertion - my buffer is
BYTE type ... do I need to convert it to char type ?
I'm not sure , if I need to organize some reseivning cycle - what must be my approach ?
{
BYTE ReadData[11];
char ReadData[11];
DWORD ReadBytes = 10;
BOOL RetVal;
CString string;
ReadData[0] = 48L;
...............................
ReadData[9] = 48L;
RetVal = ReadFile(CommInfo.ComDev, ReadData, ReadBytes, &ReadBytes,
NULL);
if (!RetVal)
{
string.Format(_T("FAIL to RECEIVE data !"));
AfxMessageBox(string);
return(1);
}
ReadData[10] = '\0';
string.Format(_T("%s"), &ReadData[0]);
AfxMessageBox(string);
return 0;
}
Thank You !