/[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 44 by torben, Sun Feb 4 21:22:44 2007 UTC revision 49 by torben, Mon Feb 5 07:06:43 2007 UTC
# Line 1  Line 1 
1    
 #ifdef _WINDOWS  
2  #include "StdAfx.h"  #include "StdAfx.h"
 #endif  
3    
4  #include "H7Serial.h"  #include "H7Serial.h"
5  #include <stdexcept>  #include <stdexcept>
6    #include <iostream>
7    
8  CH7Serial::CH7Serial(void)  CH7Serial::CH7Serial(void)
9  : CSlipSerial()  : CSlipSerial()
# Line 22  CH7Serial::~CH7Serial(void) Line 21  CH7Serial::~CH7Serial(void)
21    
22  short CH7Serial::readTarget(unsigned char target)  short CH7Serial::readTarget(unsigned char target)
23  {  {
24            using namespace std;
25            cout << "read start" << endl;
26          short retval;          short retval;
27          unsigned char frame[1];          unsigned char frame[1];
28          unsigned char hi_target = (target & 0x0F) << 4;          unsigned char hi_target = (target & 0x0F) << 4;
29          frame[0] = hi_target | 0x00;          frame[0] = hi_target | 0x00;
30    
31          writeFrame(frame,1);          writeFrame(frame,1);
32            cout << "read mid" << endl;
33          Sleep(50); //be nice and wait a little          Sleep(50); //be nice and wait a little
34          std::vector<unsigned char> answer = readFrame();          std::vector<unsigned char> answer = readFrame();
35            cout << "read done" << endl;
36    
37          if (answer.size() == 0)          if (answer.size() == 0)
38                  throw std::runtime_error("No reply");                  throw std::runtime_error("No reply");
# Line 52  short CH7Serial::readTarget(unsigned cha Line 55  short CH7Serial::readTarget(unsigned cha
55    
56  void CH7Serial::writeTarget(unsigned char target, unsigned char data)  void CH7Serial::writeTarget(unsigned char target, unsigned char data)
57  {  {
58            using namespace std;
59          unsigned char frame[2];          unsigned char frame[2];
60          unsigned char hi_target = (target & 0x0F) << 4;          unsigned char hi_target = (target & 0x0F) << 4;
61          frame[0] = hi_target | 0x01;          frame[0] = hi_target | 0x01;
62          frame[1] = data;          frame[1] = data;
63            cout << "write start" << endl;
64    
65          writeFrame(frame,2);          writeFrame(frame,2);
66            cout << "write mid" << endl;
67          Sleep(50); //be nice and wait a little          Sleep(50); //be nice and wait a little
68          std::vector<unsigned char> answer = readFrame();          std::vector<unsigned char> answer = readFrame();
69            
70            cout << "write stop" << endl;
71          if (answer.size() == 0)          if (answer.size() == 0)
72                  throw std::runtime_error("No reply");                  throw std::runtime_error("No reply");
73    

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

  ViewVC Help
Powered by ViewVC 1.1.20