Showing the changes to interface/src/SerialInterface.cpp (1 of 43 files). Show all
Unified · Split
| @@ -167,14 +167,14 @@ void SerialInterface::readData() { · 166 unmodified lines | |||
| 167 | 167 | ||
| 168 | int initialSamples = totalSamples; | 168 | int initialSamples = totalSamples; |
| 169 | 169 | ||
| 170 | while (read(serialFd, &bufchar, 1) > 0) { | 170 | while (read(serialFd, &bufchar, 1) > 0) { |
| 171 | //std::cout << bufchar[0]; | 171 | //printLof("%c", bufchar[0]); |
| 172 | serialBuffer[serialBufferPos] = bufchar[0]; | 172 | serialBuffer[serialBufferPos] = bufchar[0]; |
| 173 | serialBufferPos++; | 173 | serialBufferPos++; |
| 174 | // Have we reached end of a line of input? | 174 | // Have we reached end of a line of input? |
| 175 | if ((bufchar[0] == '\n') || (serialBufferPos >= MAX_BUFFER)) { | 175 | if ((bufchar[0] == '\n') || (serialBufferPos >= MAX_BUFFER)) { |
| 176 | std::string serialLine(serialBuffer, serialBufferPos-1); | 176 | std::string serialLine(serialBuffer, serialBufferPos-1); |
| 177 | //std::cout << serialLine << "\n"; | 177 | //printLog("%s\n", serialLine.c_str()); |
| 178 | int spot; | 178 | int spot; |
| 179 | //int channel = 0; | 179 | //int channel = 0; |
| 180 | std::string val; | 180 | std::string val; |
| @@ -182,7 +182,7 @@ void SerialInterface::readData() { · 1 unmodified line | |||
| 182 | spot = serialLine.find_first_of(" ", 0); | 182 | spot = serialLine.find_first_of(" ", 0); |
| 183 | if (spot != std::string::npos) { | 183 | if (spot != std::string::npos) { |
| 184 | val = serialLine.substr(0,spot); | 184 | val = serialLine.substr(0,spot); |
| 185 | //std::cout << val << "\n"; | 185 | //printLog("%s\n", val.c_str()); |
| 186 | if (i < NUM_CHANNELS) lastMeasured[i] = atoi(val.c_str()); | 186 | if (i < NUM_CHANNELS) lastMeasured[i] = atoi(val.c_str()); |
| 187 | else samplesAveraged = atoi(val.c_str()); | 187 | else samplesAveraged = atoi(val.c_str()); |
| 188 | } else LED = atoi(serialLine.c_str()); | 188 | } else LED = atoi(serialLine.c_str()); |
| @@ -208,8 +208,7 @@ void SerialInterface::readData() { · 19 unmodified lines | |||
| 208 | } | 208 | } |
| 209 | if (totalSamples == GRAVITY_SAMPLES) { | 209 | if (totalSamples == GRAVITY_SAMPLES) { |
| 210 | gravity = glm::normalize(gravity); | 210 | gravity = glm::normalize(gravity); |
| 211 | std::cout << "gravity: " << gravity.x << "," << | 211 | printLof("gravity: %f,%f,%f\n", gravity.x, gravity.y, gravity.z); |
| 212 | gravity.y << "," << gravity.z << "\n"; | ||
| 213 | } | 212 | } |
| 214 | 213 | ||
| 215 | totalSamples++; | 214 | totalSamples++; |
| @@ -222,7 +221,7 @@ void SerialInterface::readData() { · 6 unmodified lines | |||
| 222 | gettimeofday(&now, NULL); | 221 | gettimeofday(&now, NULL); |
| 223 | 222 | ||
| 224 | if (diffclock(&lastGoodRead, &now) > NO_READ_MAXIMUM_MSECS) { | 223 | if (diffclock(&lastGoodRead, &now) > NO_READ_MAXIMUM_MSECS) { |
| 225 | std::cout << "No data - Shutting down SerialInterface.\n"; | 224 | printLog("No data - Shutting down SerialInterface.\n"); |
| 226 | resetSerial(); | 225 | resetSerial(); |
| 227 | } | 226 | } |
| 228 | } else { | 227 | } else { |