Commit 680ed5f6 authored by charliea's avatar charliea Committed by Commit bot

Revert "tools/battor_agent: Adds a tool to find connected BattOrs"

This reverts commit 5897360a.

TBR=thakis@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=581693

Review URL: https://codereview.chromium.org/1641573003

Cr-Commit-Position: refs/heads/master@{#371794}
parent 2676b7ca
...@@ -28,8 +28,6 @@ source_set("battor_agent_lib") { ...@@ -28,8 +28,6 @@ source_set("battor_agent_lib") {
"battor_connection_impl.cc", "battor_connection_impl.cc",
"battor_connection_impl.h", "battor_connection_impl.h",
"battor_error.h", "battor_error.h",
"battor_finder.cc",
"battor_finder.h",
"battor_sample_converter.cc", "battor_sample_converter.cc",
"battor_sample_converter.h", "battor_sample_converter.h",
] ]
......
include_rules = [ include_rules = [
"+device/serial", "+device/serial",
"+mojo/public",
"+net/base", "+net/base",
] ]
\ No newline at end of file
...@@ -35,8 +35,6 @@ ...@@ -35,8 +35,6 @@
'battor_connection_impl.cc', 'battor_connection_impl.cc',
'battor_connection_impl.h', 'battor_connection_impl.h',
'battor_error.h', 'battor_error.h',
'battor_finder.cc',
'battor_finder.h',
'battor_sample_converter.cc', 'battor_sample_converter.cc',
'battor_sample_converter.h', 'battor_sample_converter.h',
], ],
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "tools/battor_agent/battor_agent.h" #include "tools/battor_agent/battor_agent.h"
#include "tools/battor_agent/battor_error.h" #include "tools/battor_agent/battor_error.h"
#include "tools/battor_agent/battor_finder.h"
using std::cout; using std::cout;
using std::endl; using std::endl;
...@@ -48,11 +47,12 @@ void PrintSupportsExplicitClockSync() { ...@@ -48,11 +47,12 @@ void PrintSupportsExplicitClockSync() {
cout << battor::BattOrAgent::SupportsExplicitClockSync() << endl; cout << battor::BattOrAgent::SupportsExplicitClockSync() << endl;
} }
// Retrieves argument argnum from the argument list, or an empty string if the // Retrieves argument argnum from the argument list, printing the usage
// argument doesn't exist. // guidelines and exiting with an error code if the argument doesn't exist.
std::string GetArg(int argnum, int argc, char* argv[]) { std::string GetArg(int argnum, int argc, char* argv[]) {
if (argnum >= argc) { if (argnum >= argc) {
return std::string(); PrintUsage();
exit(1);
} }
return argv[argnum]; return argv[argnum];
...@@ -89,10 +89,6 @@ class BattOrAgentBin : public BattOrAgent::Listener { ...@@ -89,10 +89,6 @@ class BattOrAgentBin : public BattOrAgent::Listener {
// Runs the BattOr binary and returns the exit code. // Runs the BattOr binary and returns the exit code.
int Run(int argc, char* argv[]) { int Run(int argc, char* argv[]) {
std::string cmd = GetArg(1, argc, argv); std::string cmd = GetArg(1, argc, argv);
if (cmd.empty()) {
PrintUsage();
exit(1);
}
// SupportsExplicitClockSync doesn't need to use the serial connection, so // SupportsExplicitClockSync doesn't need to use the serial connection, so
// handle it separately. // handle it separately.
...@@ -102,18 +98,6 @@ class BattOrAgentBin : public BattOrAgent::Listener { ...@@ -102,18 +98,6 @@ class BattOrAgentBin : public BattOrAgent::Listener {
} }
std::string path = GetArg(2, argc, argv); std::string path = GetArg(2, argc, argv);
// If no path is specified, see if we can find a BattOr and use that.
if (path.empty())
path = BattOrFinder::FindBattOr();
// If we don't have any BattOr to use, exit.
if (path.empty()) {
cout << "Unable to find a BattOr, and no explicit BattOr path was "
"specified."
<< endl;
exit(1);
}
SetUp(path); SetUp(path);
if (cmd == "StartTracing") { if (cmd == "StartTracing") {
......
// Copyright 2016 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_finder.h"
#include "device/serial/serial.mojom.h"
#include "device/serial/serial_device_enumerator.h"
#include "mojo/public/cpp/bindings/array.h"
namespace battor {
namespace {
// The USB display name prefix that all BattOrs have.
const char kBattOrDisplayNamePrefix[] = "BattOr";
} // namespace
// Returns the path of the first BattOr that we find.
std::string BattOrFinder::FindBattOr() {
scoped_ptr<device::SerialDeviceEnumerator> serial_device_enumerator =
device::SerialDeviceEnumerator::Create();
mojo::Array<device::serial::DeviceInfoPtr> devices =
serial_device_enumerator->GetDevices();
for (size_t i = 0; i < devices.size(); i++) {
std::string display_name = devices[i]->display_name.get();
if (display_name.find(kBattOrDisplayNamePrefix) != std::string::npos) {
return devices[i]->path;
}
}
return std::string();
}
} // namespace battor
// Copyright 2016 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.
#ifndef TOOLS_BATTOR_AGENT_BATTOR_FINDER_H_
#define TOOLS_BATTOR_AGENT_BATTOR_FINDER_H_
#include <string>
#include "base/macros.h"
namespace battor {
class BattOrFinder {
public:
static std::string FindBattOr();
DISALLOW_COPY_AND_ASSIGN(BattOrFinder);
};
} // namespace battor
#endif // TOOLS_BATTOR_AGENT_BATTOR_FINDER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment