Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: tools/battor_agent/battor_agent.cc

Issue 2390893002: [BattOr] Make BattOr able to return firmware version. (Closed)
Patch Set: [BattOr] Make BattOr able to return firmware version. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/battor_agent/battor_agent.h ('k') | tools/battor_agent/battor_agent_bin.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/battor_agent/battor_agent.cc
diff --git a/tools/battor_agent/battor_agent.cc b/tools/battor_agent/battor_agent.cc
index 6fc6ea17983b09ed662e617b9906fc6c3dbc2f94..095dc9a04131df5da2cf8910a1f1685a180d6678 100644
--- a/tools/battor_agent/battor_agent.cc
+++ b/tools/battor_agent/battor_agent.cc
@@ -1,7 +1,6 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
#include "tools/battor_agent/battor_agent.h"
#include <iomanip>
@@ -159,6 +158,13 @@ void BattOrAgent::RecordClockSyncMarker(const std::string& marker) {
PerformAction(Action::REQUEST_CONNECTION);
}
+void BattOrAgent::GetVersion() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ command_ = Command::GET_VERSION;
+ PerformAction(Action::REQUEST_CONNECTION);
+}
+
void BattOrAgent::BeginConnect() {
DCHECK(thread_checker_.CalledOnValidThread());
@@ -187,6 +193,9 @@ void BattOrAgent::OnConnectionOpened(bool success) {
case Command::RECORD_CLOCK_SYNC_MARKER:
PerformAction(Action::SEND_CURRENT_SAMPLE_REQUEST);
return;
+ case Command::GET_VERSION:
+ PerformAction(Action::SEND_EEPROM_REQUEST);
+ return;
case Command::INVALID:
NOTREACHED();
}
@@ -245,6 +254,9 @@ void BattOrAgent::OnMessageRead(bool success,
if (!success) {
switch (last_action_) {
case Action::READ_EEPROM:
+ if (command_ == Command::GET_VERSION) {
+ CompleteCommand(BATTOR_ERROR_NONE);
charliea (OOO until 10-5) 2016/10/05 15:19:28 This should be the error case, not the happy case.
+ }
case Action::READ_CALIBRATION_FRAME:
case Action::READ_DATA_FRAME:
case Action::READ_CURRENT_SAMPLE:
@@ -315,6 +327,7 @@ void BattOrAgent::OnMessageRead(bool success,
case Action::READ_EEPROM: {
battor_eeprom_ = ParseEEPROM(type, *bytes);
if (!battor_eeprom_) {
+ // Here is where the error is being thrown......................................
CompleteCommand(BATTOR_ERROR_UNEXPECTED_MESSAGE);
return;
}
@@ -530,6 +543,13 @@ void BattOrAgent::CompleteCommand(BattOrError error) {
FROM_HERE, base::Bind(&Listener::OnRecordClockSyncMarkerComplete,
base::Unretained(listener_), error));
break;
+// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+// Need to get proper version number.
+ case Command::GET_VERSION:
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(&Listener::OnGetVersionComplete,
+ base::Unretained(listener_), 1, error));
+ break;
case Command::INVALID:
NOTREACHED();
}
« no previous file with comments | « tools/battor_agent/battor_agent.h ('k') | tools/battor_agent/battor_agent_bin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698