--- trunk/H7 Server/Serial.cpp 2007/02/01 10:03:52 38 +++ trunk/H7 Server/Serial.cpp 2007/02/01 13:49:01 39 @@ -57,6 +57,7 @@ void CSerial::open() { +// Åbner Serial porten. mComport = CreateFile( mPortstr, GENERIC_READ|GENERIC_WRITE, 0, @@ -65,6 +66,7 @@ FILE_ATTRIBUTE_NORMAL, 0); +// Error check. if (mComport == INVALID_HANDLE_VALUE) { throw std::exception(writeLastError().c_str()); @@ -74,6 +76,7 @@ dcb.DCBlength = sizeof(DCB); mDcbRestore.DCBlength = sizeof(DCB); +// Error check. if (!GetCommState(mComport,&dcb) || !GetCommState(mComport,&mDcbRestore)) { std::string error = writeLastError(); @@ -81,6 +84,7 @@ throw std::exception(error.c_str()); } +// Definerer Serial Conf. dcb.BaudRate = mBitrate; dcb.ByteSize = 8; dcb.Parity = NOPARITY; @@ -90,6 +94,7 @@ dcb.fParity = false; dcb.fDsrSensitivity = false; +// Error check. if (!SetCommState(mComport,&dcb)) { std::string error = writeLastError(); @@ -122,6 +127,7 @@ throw std::exception("Port not opened"); ReadFile(mComport,&out,1,&size,0); +// Error check. if (size != 1) { std::string error = writeLastError();