Embedded_Geek
Full Member level 6
I am unable to open serial port in WinXP using C. It is returning error even though the correct COM port has been specified. The code is given below:
Waiting for a solution/advice.
Thanks in advance,
Code:
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
void main ()
{
HANDLE hSerial;
hSerial = CreateFile("COM1",(GENERIC_READ | GENERIC_WRITE),0,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
if(hSerial==INVALID_HANDLE_VALUE){
if(GetLastError()== ERROR_FILE_NOT_FOUND){
printf("FAILED");
}
}
}
Waiting for a solution/advice.
Thanks in advance,