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

Unified Diff: tools/battor_agent/battor_agent.cc

Issue 2390893002: [BattOr] Make BattOr able to return firmware version. (Closed)
Patch Set: fix compiling error 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..ebb0c49b7226f7c36dc4863905589676e87f1ca2 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>
@@ -107,7 +106,6 @@ bool ParseSampleFrame(BattOrMessageType type,
return true;
}
-
} // namespace
BattOrAgent::BattOrAgent(
@@ -159,6 +157,13 @@ void BattOrAgent::RecordClockSyncMarker(const std::string& marker) {
PerformAction(Action::REQUEST_CONNECTION);
}
+void BattOrAgent::GetFirmwareGitHash() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ command_ = Command::GET_FIRMWARE_GIT_HASH;
+ PerformAction(Action::REQUEST_CONNECTION);
+}
+
void BattOrAgent::BeginConnect() {
DCHECK(thread_checker_.CalledOnValidThread());
@@ -187,6 +192,9 @@ void BattOrAgent::OnConnectionOpened(bool success) {
case Command::RECORD_CLOCK_SYNC_MARKER:
PerformAction(Action::SEND_CURRENT_SAMPLE_REQUEST);
return;
+ case Command::GET_FIRMWARE_GIT_HASH:
+ PerformAction(Action::SEND_GIT_HASH_REQUEST);
+ return;
case Command::INVALID:
NOTREACHED();
}
@@ -228,6 +236,10 @@ void BattOrAgent::OnBytesSent(bool success) {
num_read_attempts_ = 1;
PerformAction(Action::READ_CURRENT_SAMPLE);
return;
+ case Action::SEND_GIT_HASH_REQUEST:
+ num_read_attempts_ = 1;
+ PerformAction(Action::READ_GIT_HASH);
+ return;
default:
CompleteCommand(BATTOR_ERROR_UNEXPECTED_MESSAGE);
}
@@ -244,6 +256,7 @@ void BattOrAgent::OnMessageRead(bool success,
if (!success) {
switch (last_action_) {
+ case Action::READ_GIT_HASH:
case Action::READ_EEPROM:
case Action::READ_CALIBRATION_FRAME:
case Action::READ_DATA_FRAME:
@@ -387,6 +400,15 @@ void BattOrAgent::OnMessageRead(bool success,
CompleteCommand(BATTOR_ERROR_NONE);
return;
+ case Action::READ_GIT_HASH:
+ if (type != BATTOR_MESSAGE_TYPE_CONTROL_ACK ){
+ CompleteCommand(BATTOR_ERROR_UNEXPECTED_MESSAGE);
+ return;
+ }
+ firmware_git_hash_ = std::string(bytes->begin(), bytes->end());
+ CompleteCommand(BATTOR_ERROR_NONE);
+ return;
+
default:
CompleteCommand(BATTOR_ERROR_UNEXPECTED_MESSAGE);
}
@@ -473,6 +495,15 @@ void BattOrAgent::PerformAction(Action action) {
connection_->ReadMessage(BATTOR_MESSAGE_TYPE_CONTROL_ACK);
return;
+ case Action::SEND_GIT_HASH_REQUEST:
+ SendControlMessage(
+ BATTOR_CONTROL_MESSAGE_TYPE_GET_FIRMWARE_GIT_HASH, 0, 0);
+ return;
+
+ case Action::READ_GIT_HASH:
+ connection_->ReadMessage(BATTOR_MESSAGE_TYPE_CONTROL_ACK);
+ return;
+
case Action::INVALID:
NOTREACHED();
}
@@ -530,6 +561,12 @@ void BattOrAgent::CompleteCommand(BattOrError error) {
FROM_HERE, base::Bind(&Listener::OnRecordClockSyncMarkerComplete,
base::Unretained(listener_), error));
break;
+ case Command::GET_FIRMWARE_GIT_HASH:
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(&Listener::OnGetFirmwareGitHashComplete,
+ base::Unretained(listener_),
+ firmware_git_hash_, 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