/[H9]/trunk/FlisServer/Serial.cpp
ViewVC logotype

Diff of /trunk/FlisServer/Serial.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 70 by kevin, Tue Nov 27 15:26:42 2007 UTC revision 296 by torben, Fri Dec 14 09:50:41 2007 UTC
# Line 58  void CSerial::open(CString port, int bit Line 58  void CSerial::open(CString port, int bit
58    
59  void CSerial::open()  void CSerial::open()
60  {  {
61            CString comport = "\\\\.\\";
62            comport += mPortstr;
63  // Åbner Serial porten.  // Åbner Serial porten.
64          mComport = CreateFile( mPortstr,          mComport = CreateFile( comport,
65                                                                          GENERIC_READ|GENERIC_WRITE,                                                                          GENERIC_READ|GENERIC_WRITE,
66                                                                          0,                                                                          0,
67                                                                          0,                                                                          0,
# Line 111  void CSerial::close() Line 113  void CSerial::close()
113          if (mIsopen)          if (mIsopen)
114          {          {
115                  while (getComstat().cbOutQue >0)                  while (getComstat().cbOutQue >0)
116                    {
117                          Sleep(5);                          Sleep(5);
118                    }
119                  SetCommState(mComport,&mDcbRestore);                  SetCommState(mComport,&mDcbRestore);
120                  CloseHandle(mComport);                  CloseHandle(mComport);
121                  mIsopen = false;                  mIsopen = false;
# Line 125  unsigned char CSerial::readByte() Line 129  unsigned char CSerial::readByte()
129          unsigned long size;          unsigned long size;
130    
131          if (!mIsopen)          if (!mIsopen)
132            {
133                  throw std::exception("Port not opened");                  throw std::exception("Port not opened");
134            }
135    
136          ReadFile(mComport,&out,1,&size,0);          ReadFile(mComport,&out,1,&size,0);
137  // Error check.  // Error check.
# Line 135  unsigned char CSerial::readByte() Line 141  unsigned char CSerial::readByte()
141                  CloseHandle(mComport);                  CloseHandle(mComport);
142                  throw std::exception(error.c_str());                  throw std::exception(error.c_str());
143          }          }
144            
145    
146          //printByte("Read", out);          //printByte("Read", out);
147          return out;          return out;

Legend:
Removed from v.70  
changed lines
  Added in v.296

  ViewVC Help
Powered by ViewVC 1.1.20