"CreateFile FailedCode:bool Serial::connect() { if (mConnected) { printf("You are already connected, please disconnect first\n"); return false; } COMMTIMEOUTS cto; DCB dcb; char parity, stop_bits; int speed; if (mFd != INVALID_HANDLE_VALUE && !CloseHandle(mFd)){ printf("Can't close comm port"); return false; } mFd = CreateFileA(mDevice, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if(mFd == INVALID_HANDLE_VALUE) { printf("CreateFile on %s failed with error code: %d \n" , mDevice , GetLastError( ) ); char port[64]; strcpy(port, "\\\\.\\"); strcat(port, mDevice); mFd = CreateFileA(port, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if(mFd == INVALID_HANDLE_VALUE){ printf("CreateFile on %s failed with error code: %d \n" , port , GetLastError( ) ); printf("CreateFile Failed \n"); return false; } }
CreateFile on C:\Documents an=failed with error code: 2
CreateFile on \\.\C:\Documents an=failed with error code: 2"
Why did it not show the full path?




Reply With Quote
