| 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..089004cda0317b29eabf270bd80597fc263af1e4 100644
|
| --- a/tools/battor_agent/battor_agent.cc
|
| +++ b/tools/battor_agent/battor_agent.cc
|
| @@ -1,7 +1,7 @@
|
| // 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 <iostream>
|
| #include "tools/battor_agent/battor_agent.h"
|
|
|
| #include <iomanip>
|
| @@ -159,6 +159,14 @@ void BattOrAgent::RecordClockSyncMarker(const std::string& marker) {
|
| PerformAction(Action::REQUEST_CONNECTION);
|
| }
|
|
|
| +void BattOrAgent::GetVersion() {
|
| + std::cout << "START GetVersion()\n";
|
| + DCHECK(thread_checker_.CalledOnValidThread());
|
| +
|
| + command_ = Command::GET_VERSION;
|
| + PerformAction(Action::REQUEST_CONNECTION);
|
| +}
|
| +
|
| void BattOrAgent::BeginConnect() {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
|
|
| @@ -187,6 +195,10 @@ void BattOrAgent::OnConnectionOpened(bool success) {
|
| case Command::RECORD_CLOCK_SYNC_MARKER:
|
| PerformAction(Action::SEND_CURRENT_SAMPLE_REQUEST);
|
| return;
|
| + case Command::GET_VERSION:
|
| + std::cout << "OnConnectionOpened.GET_VERSION\n";
|
| + PerformAction(Action::SEND_GIT_HASH_REQUEST);
|
| + return;
|
| case Command::INVALID:
|
| NOTREACHED();
|
| }
|
| @@ -228,6 +240,10 @@ void BattOrAgent::OnBytesSent(bool success) {
|
| num_read_attempts_ = 1;
|
| PerformAction(Action::READ_CURRENT_SAMPLE);
|
| return;
|
| + case Action::SEND_GIT_HASH_REQUEST:
|
| + std::cout << "OnBytesSent SEND_GIT_HASH_REQUEST\n";
|
| + num_read_attempts_ = 1;
|
| + PerformAction(Action::READ_GIT_HASH);
|
| default:
|
| CompleteCommand(BATTOR_ERROR_UNEXPECTED_MESSAGE);
|
| }
|
| @@ -244,6 +260,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 +404,11 @@ void BattOrAgent::OnMessageRead(bool success,
|
| CompleteCommand(BATTOR_ERROR_NONE);
|
| return;
|
|
|
| + case Action::READ_GIT_HASH:
|
| + std::cout << "OnMessageRead READ_GIT_HASH\n";
|
| + CompleteCommand(BATTOR_ERROR_NONE);
|
| + return;
|
| +
|
| default:
|
| CompleteCommand(BATTOR_ERROR_UNEXPECTED_MESSAGE);
|
| }
|
| @@ -473,6 +495,16 @@ void BattOrAgent::PerformAction(Action action) {
|
| connection_->ReadMessage(BATTOR_MESSAGE_TYPE_CONTROL_ACK);
|
| return;
|
|
|
| + case Action::SEND_GIT_HASH_REQUEST:
|
| + std::cout << "PerformAction SEND_GIT_HASH_REQUEST\n";
|
| + SendControlMessage(BATTOR_CONTROL_MESSAGE_TYPE_GET_GIT_HASH, 0, 0);
|
| + return;
|
| +
|
| + case Action::READ_GIT_HASH:
|
| + std::cout << "PerformAction READ_GIT_HASH\n";
|
| + connection_->ReadMessage(BATTOR_MESSAGE_TYPE_CONTROL_ACK);
|
| + return;
|
| +
|
| case Action::INVALID:
|
| NOTREACHED();
|
| }
|
| @@ -530,6 +562,15 @@ 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:
|
| + std::cout << "Complete GET_VERSION\n";
|
| + base::ThreadTaskRunnerHandle::Get()->PostTask(
|
| + FROM_HERE, base::Bind(&Listener::OnGetVersionComplete,
|
| + base::Unretained(listener_),
|
| + 1, error));
|
| + break;
|
| case Command::INVALID:
|
| NOTREACHED();
|
| }
|
|
|