/[H7]/trunk/H7 Server/H7Serial.cpp
ViewVC logotype

Diff of /trunk/H7 Server/H7Serial.cpp

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

revision 32 by torben, Wed Jan 31 08:47:47 2007 UTC revision 33 by hedin, Wed Jan 31 17:22:59 2007 UTC
# Line 17  CH7Serial::~CH7Serial(void) Line 17  CH7Serial::~CH7Serial(void)
17    
18  short CH7Serial::readTarget(unsigned char target)  short CH7Serial::readTarget(unsigned char target)
19  {  {
20            serialLock.Lock();
21          short retval;          short retval;
22          unsigned char frame[1];          unsigned char frame[1];
23          unsigned char hi_target = (target & 0x0F) << 4;          unsigned char hi_target = (target & 0x0F) << 4;
# Line 32  short CH7Serial::readTarget(unsigned cha Line 33  short CH7Serial::readTarget(unsigned cha
33          if ( (answer[0] & 0x0F) != 0x02) // tjek for ACK          if ( (answer[0] & 0x0F) != 0x02) // tjek for ACK
34                  throw std::exception("Request not acknowledged");                  throw std::exception("Request not acknowledged");
35    
36          if ( (answer[0] & 0xF0) != hi_target)  //      if ( (answer[0] & 0xF0) != hi_target)
37                  throw std::exception("Incorrect reply");  //              throw std::exception("Incorrect reply");
38    
39    
40          if (answer.size() == 2)          if (answer.size() == 2)
41                  retval = answer[1];                  retval = answer[1];
# Line 42  short CH7Serial::readTarget(unsigned cha Line 44  short CH7Serial::readTarget(unsigned cha
44          else          else
45                  retval = -1;                  retval = -1;
46    
47            serialLock.Unlock();
48          return retval;          return retval;
49  }  }
50    
51  void CH7Serial::writeTarget(unsigned char target, unsigned char data)  void CH7Serial::writeTarget(unsigned char target, unsigned char data)
52  {  {
53            serialLock.Lock();
54          unsigned char frame[2];          unsigned char frame[2];
55          unsigned char hi_target = (target & 0x0F) << 4;          unsigned char hi_target = (target & 0x0F) << 4;
56          frame[0] = hi_target | 0x01;          frame[0] = hi_target | 0x01;
# Line 64  void CH7Serial::writeTarget(unsigned cha Line 68  void CH7Serial::writeTarget(unsigned cha
68    
69          if ( (answer[0] & 0xF0) != hi_target)          if ( (answer[0] & 0xF0) != hi_target)
70                  throw std::exception("Incorrect reply");                  throw std::exception("Incorrect reply");
71            
72            serialLock.Unlock();
73  }  }
74    
75    

Legend:
Removed from v.32  
changed lines
  Added in v.33

  ViewVC Help
Powered by ViewVC 1.1.20