111 |
if (mIsopen) |
if (mIsopen) |
112 |
{ |
{ |
113 |
while (getComstat().cbOutQue >0) |
while (getComstat().cbOutQue >0) |
114 |
|
{ |
115 |
Sleep(5); |
Sleep(5); |
116 |
|
} |
117 |
SetCommState(mComport,&mDcbRestore); |
SetCommState(mComport,&mDcbRestore); |
118 |
CloseHandle(mComport); |
CloseHandle(mComport); |
119 |
mIsopen = false; |
mIsopen = false; |
127 |
unsigned long size; |
unsigned long size; |
128 |
|
|
129 |
if (!mIsopen) |
if (!mIsopen) |
130 |
|
{ |
131 |
throw std::exception("Port not opened"); |
throw std::exception("Port not opened"); |
132 |
|
} |
133 |
|
|
134 |
ReadFile(mComport,&out,1,&size,0); |
ReadFile(mComport,&out,1,&size,0); |
135 |
// Error check. |
// Error check. |
139 |
CloseHandle(mComport); |
CloseHandle(mComport); |
140 |
throw std::exception(error.c_str()); |
throw std::exception(error.c_str()); |
141 |
} |
} |
142 |
|
|
143 |
|
|
144 |
//printByte("Read", out); |
//printByte("Read", out); |
145 |
return out; |
return out; |