Check the return value of
ReadFile
. Is it returns FALSE, then call
GetLastError
to have details about the error. Also check the number of bytes really read '
cp.dwBytesTransferred
).
Form this code:
bResult=ReadFile( hPort,
&cp.Byte,
1,
&cp.dwBytesTransferred,
NULL
);
you ask to read only 1 byte. So it is not possible to receive "OK", nor "AT". You should at least replace
1
y
2
.
You may need also to wait a little bit after you sent "AT", to let your device do its processing. After the wait, you can read:
TransxPortGSM();
Sleep(1000);
ReadxPortGSM();