/[H7]/branches/linux-serial/H7Serial.cpp
ViewVC logotype

Diff of /branches/linux-serial/H7Serial.cpp

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

revision 43 by torben, Sun Feb 4 20:11:41 2007 UTC revision 44 by torben, Sun Feb 4 21:22:44 2007 UTC
# Line 1  Line 1 
1    
2    #ifdef _WINDOWS
3  #include "StdAfx.h"  #include "StdAfx.h"
4  #include ".\h7serial.h"  #endif
5    
6    #include "H7Serial.h"
7    #include <stdexcept>
8    
9  CH7Serial::CH7Serial(void)  CH7Serial::CH7Serial(void)
10  : CSlipSerial()  : CSlipSerial()
# Line 27  short CH7Serial::readTarget(unsigned cha Line 32  short CH7Serial::readTarget(unsigned cha
32          std::vector<unsigned char> answer = readFrame();          std::vector<unsigned char> answer = readFrame();
33    
34          if (answer.size() == 0)          if (answer.size() == 0)
35                  throw std::exception("No reply");                  throw std::runtime_error("No reply");
36    
37          if ( (answer[0] & 0x0F) != 0x02) // tjek for ACK          if ( (answer[0] & 0x0F) != 0x02) // tjek for ACK
38                  throw std::exception("Request not acknowledged");                  throw std::runtime_error("Request not acknowledged");
39    
40          if ( (answer[0] & 0xF0) != hi_target)          if ( (answer[0] & 0xF0) != hi_target)
41                  throw std::exception("Incorrect reply");                  throw std::runtime_error("Incorrect reply");
42    
43          if (answer.size() == 2)          if (answer.size() == 2)
44                  retval = answer[1];                  retval = answer[1];
# Line 57  void CH7Serial::writeTarget(unsigned cha Line 62  void CH7Serial::writeTarget(unsigned cha
62          std::vector<unsigned char> answer = readFrame();          std::vector<unsigned char> answer = readFrame();
63    
64          if (answer.size() == 0)          if (answer.size() == 0)
65                  throw std::exception("No reply");                  throw std::runtime_error("No reply");
66    
67          if ( (answer[0] & 0x0F) != 0x02) // tjek for ACK          if ( (answer[0] & 0x0F) != 0x02) // tjek for ACK
68                  throw std::exception("Request not acknowledged");                  throw std::runtime_error("Request not acknowledged");
69    
70          if ( (answer[0] & 0xF0) != hi_target)          if ( (answer[0] & 0xF0) != hi_target)
71                  throw std::exception("Incorrect reply");                  throw std::runtime_error("Incorrect reply");
72  }  }
73    
74    

Legend:
Removed from v.43  
changed lines
  Added in v.44

  ViewVC Help
Powered by ViewVC 1.1.20