Hey,
This may be real basic and Im just drawing a blank. How would you process a byte of info recieved over a serial port. I am writing a char*, recieving 1 (4 bytes) char at a time. I would like to return the entire read back as a char*. Here is that part of the code.
char *Read()
{
DWORD myReadEvent;
DWORD bytesRead;
char myReadByte;
char *myIncomingMessage = "";
if(!SetupPort(1200, myReadCom))
cout << "Error setting up the port." << endl;
else
{
if(!SetCommMask(myReadCom, EV_RXCHAR))
cout << "Could not set read mask." << endl;
if(WaitCommEvent(myReadCom, &myReadEvent, NULL))
{
do
{
if(ReadFile(myReadCom, &myReadByte, 1, &bytesRead, NULL))
//strncat_s(myIncomingMessage, sizeof(myIncomingMessage), myReadByte, 1);
cout << "Byte Read. Process it. << endl;
else
cout << "Read message error." << endl;
}
while(bytesRead);
}
}
return myIncomingMessage;
}
void Write(char *myWriteByte)
{
DWORD bytesWritten;
if(!SetupPort(1200, myWriteCom))
cout << "Error setting up the port." << endl;
WriteFile(myWriteCom, myWriteByte, 1, &bytesWritten, NULL);
return;
}
Thanks.