Changeset 8189
- Timestamp:
- 03/20/08 17:23:11 (5 years ago)
- Location:
- lang/cplusplus/gainer++
- Files:
-
- 1 added
- 2 modified
-
Makefile (modified) (1 diff)
-
gainer-cain.cc (added)
-
gainer.cc (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/cplusplus/gainer++/Makefile
r8183 r8189 20 20 $(CXX) -o $@ $^ $(LIBS) 21 21 22 gainer-cain: gainer-cain.o $(TARGET_LIB) 23 $(CXX) -o $@ $^ $(LIBS) 22 24 23 25 clean: -
lang/cplusplus/gainer++/gainer.cc
r8185 r8189 31 31 32 32 while (not self->end_) { 33 DEBUG_PRINT("next_event...");33 //DEBUG_PRINT("next_event..."); 34 34 35 35 fd_set fds; … … 42 42 const size_t SIZE(80); 43 43 char buf[SIZE]; 44 read(self->io_, buf, SIZE); 44 char ch(' '); 45 size_t i(0); 46 while ('*' != ch and i<SIZE) { 47 read(self->io_, &ch, 1); 48 buf[i++] = ch; 49 } 50 //read(self->io_, buf, SIZE); 51 //DEBUG_PRINT(buf); 45 52 std::string s(buf); 46 53 … … 53 60 namespace Gainer { 54 61 Gainer::Gainer(const std::string &path, int config) : 55 led_(false)62 led_(false) 56 63 , config_(config) 57 64 , end_(false) … … 68 75 69 76 Gainer::~Gainer() { 77 reboot(); 70 78 end_ = true; 71 79 pthread_join(thread_, NULL); … … 101 109 102 110 void Gainer::set_led(bool flag) { command(flag ? "h" : "l"); } 103 void Gainer::reboot() { command("Q", 1); }111 void Gainer::reboot() { command("Q", 2); } 104 112 void Gainer::peek_digital_inputs() { command("R"); } 105 113 void Gainer::peek_analog_inputs() { command("I"); } … … 110 118 void Gainer::set_digital_output(int n) { 111 119 std::stringstream ss("D"); 112 for (int i(0); i< CONFIG[config_][DOUT]-1; i++) {120 for (int i(0); i< CONFIG[config_][DOUT]-1; i++) 113 121 ss << ' '; 114 }115 122 ss << n; 116 123 command(ss.str()); … … 127 134 128 135 void Gainer::process_event(std::string &event) { 129 DEBUG_PRINT("event: " << event);136 //DEBUG_PRINT("event: " << event); 130 137 switch(event[0]) { 131 138 case '!': // something wrong
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)