| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "tools/battor_agent/battor_agent.h" | 5 #include "tools/battor_agent/battor_agent.h" |
| 6 | 6 |
| 7 #include <iomanip> | 7 #include <iomanip> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 void BattOrAgent::OnBytesSent(bool success) { | 163 void BattOrAgent::OnBytesSent(bool success) { |
| 164 DCHECK(thread_checker_.CalledOnValidThread()); | 164 DCHECK(thread_checker_.CalledOnValidThread()); |
| 165 | 165 |
| 166 if (!success) { | 166 if (!success) { |
| 167 CompleteCommand(BATTOR_ERROR_SEND_ERROR); | 167 CompleteCommand(BATTOR_ERROR_SEND_ERROR); |
| 168 return; | 168 return; |
| 169 } | 169 } |
| 170 | 170 |
| 171 switch (last_action_) { | 171 switch (last_action_) { |
| 172 case Action::SEND_RESET: | 172 case Action::SEND_RESET: |
| 173 // TODO(charliea): Ideally, we'd just like to send an init, and the BattOr |
| 174 // firmware can handle whether a reset is necessary or not, sending an |
| 175 // init ack regardless. This reset can be removed once this is true. |
| 176 // https://github.com/aschulm/battor/issues/30 tracks this. |
| 177 |
| 173 // Wait for the reset to happen before sending the init message. | 178 // Wait for the reset to happen before sending the init message. |
| 174 PerformDelayedAction(Action::SEND_INIT, base::TimeDelta::FromSeconds( | 179 PerformDelayedAction(Action::SEND_INIT, base::TimeDelta::FromSeconds( |
| 175 kBattOrResetTimeSeconds)); | 180 kBattOrResetTimeSeconds)); |
| 176 return; | 181 return; |
| 177 case Action::SEND_INIT: | 182 case Action::SEND_INIT: |
| 178 PerformAction(Action::READ_INIT_ACK); | 183 PerformAction(Action::READ_INIT_ACK); |
| 179 return; | 184 return; |
| 180 case Action::SEND_SET_GAIN: | 185 case Action::SEND_SET_GAIN: |
| 181 PerformAction(Action::READ_SET_GAIN_ACK); | 186 PerformAction(Action::READ_SET_GAIN_ACK); |
| 182 return; | 187 return; |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 BattOrSample sample = converter.ToSample(samples_[i], i); | 459 BattOrSample sample = converter.ToSample(samples_[i], i); |
| 455 trace_stream << std::setprecision(2) << sample.time_ms << " " | 460 trace_stream << std::setprecision(2) << sample.time_ms << " " |
| 456 << std::setprecision(1) << sample.current_mA << " " | 461 << std::setprecision(1) << sample.current_mA << " " |
| 457 << sample.voltage_mV << std::endl; | 462 << sample.voltage_mV << std::endl; |
| 458 } | 463 } |
| 459 | 464 |
| 460 return trace_stream.str(); | 465 return trace_stream.str(); |
| 461 } | 466 } |
| 462 | 467 |
| 463 } // namespace battor | 468 } // namespace battor |
| OLD | NEW |