Hi guys,
I'm quite new to this area but've managed to get some help from online
searches
and created the following program. A bit crude & messy for now. I
apologise for that.
However, I'm unable to send any bytes using WriteFile. Kept on getting
error.
Here's the code which I'm having an issue with :
------------------------------------------------------------------
LPSTR szText;
UCHAR * cl;
unsigned long BytesWritten;
bool bResult;
cl = converted_value_str;
_tochar sztext((char *)cl);
DWORD write = sizeof(cl);
if( ! PurgeComm( h, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR |
PURGE_RXCLEAR ) )
{
printf("\nPurgeComm error!!");
}
bResult = WriteFile(h, cl, sizeof(cl) + 1, &BytesWritten, NULL);
DWORD dw1 = GetLastError();
printf("\nbResult1 = %b", bResult);
printf("\nGetLastError1 = %u", dw1);
printf("\nsizeof(cl) = %i", sizeof(cl));
printf("\nBytesWritten1 = %u", &BytesWritten);
------------------------------------------------------------------
This is the error which I've got :
Enter a command (y/n) : y
Please enter a long string: 11
Buf_Len = 2
GetLastError1 = 87
sizeof(cl) = 4
bResult1 = 0
BytesWritten1 = 9305948
Can someone advise me why I'm having this error and how I can send any
data to my serial port? Fyi, I'm using COM1. Pls help!! Need this
urgently for my project.
Thanks in adv!
Yours Sincerely,
GK