Hi, I am using the following code to talk to the 'Com1': int CommPort::CreatePort(_Port port , HANDLE *hCom) { DCB dcb; bool fSuccess; char *pcCommPort; CString buffer; buffer.Format("\\\\.\\%s", port.com); pcCommPort = new char[buffer.GetLength() + 1]; for(int i = 0; i <= buffer.GetLength(); i++) *(pcCommPort + i) = buffer.GetAt(i); *hCom = CreateFile(pcCommPort, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); delete[] pcCommPort; if(*hCom == INVALID_HANDLE_VALUE) return -1; fSuccess = GetCommState(*hCom, &dcb); //Portkonfiguration mit GetCommState if(!fSuccess) return -1; dcb.BaudRate = port.dcb.BaudRate;//Konfigurationswerte des Ports dcb.ByteSize = port.dcb.ByteSize; dcb.Parity = port.dcb.Parity; dcb.StopBits = port.dcb.StopBits; dcb.fAbortOnError = true; dcb.fTXContinueOnXoff = true; fSuccess = SetCommState(*hCom, &dcb);//Portkonfiguration mit SetCommState if(!fSuccess) return -1; return 1; } So far so good. But if I try to read the port by using : bool CommPort::ReadPort(HANDLE hCom, CString *ScannText) { char buf[128]; DWORD lpNumberOfBytesRead; bool bReturn; bReturn = ReadFile(hCom, &buf, 128, &lpNumberOfBytesRead, NULL); buf[lpNumberOfBytesRead] = '\0'; *ScannText = buf; return bReturn; } I don't get the information of the port. I am able to read the port only if I connect to COM1 with hyperterminal. After connecting with hyperterminal the program runs without problems. But if I shut down my PC and start it again I will not be able to run my program. I must always start hyperterminal first. Is there anybody who can help?
Q
Q150022
@Q150022