Hi guys, I am attempting to port some code from C# over to c++ and am having problems with the serial communications.
I have data writing successfully to the port, but I can't figure out how to read the incoming stream.
if (com_handle != INVALID_HANDLE_VALUE)
WriteFile(com_handle, sync, strlen(sync), &bytesWritten, NULL);
where I attempt to use these functions:
//write to serial function
BOOL WINAPI WriteFile(
__in HANDLE hFile,
__in LPCVOID lpBuffer,
__in DWORD nNumberOfBytesToWrite,
__out_opt LPDWORD lpNumberOfBytesWritten,
__inout_opt LPOVERLAPPED lpOverlapped
//read from serial function
BOOL WINAPI ReadFile(
_In_ HANDLE hFile,
_Out_ LPVOID lpBuffer,
_In_ DWORD nNumberOfBytesToRead,
_Out_opt_ LPDWORD lpNumberOfBytesRead,
_Inout_opt_ LPOVERLAPPED lpOverlapped
Trouble is, i have no idea what the readfile is expecting. Where is my good old c# onDatareceived event when i need it... :)
Also, the data comes in as a string, which makes it even more difficult... I need to read the string and store it.
Any help much appreciated!