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

Side by Side Diff: tools/battor_agent/battor_finder.cc

Issue 1642763002: tools/battor_agent: Adds a tool to find connected BattOrs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 unified diff | Download patch
« no previous file with comments | « tools/battor_agent/battor_finder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "tools/battor_agent/battor_finder.h"
6
7 #include "device/serial/serial.mojom.h"
8 #include "device/serial/serial_device_enumerator.h"
9 #include "mojo/public/cpp/bindings/array.h"
10
11 namespace battor {
12
13 namespace {
14
15 // The USB display name prefix that all BattOrs have.
16 const char kBattOrDisplayNamePrefix[] = "BattOr";
17
18 } // namespace
19
20 // Returns the path of the first BattOr that we find.
21 std::string BattOrFinder::FindBattOr() {
22 scoped_ptr<device::SerialDeviceEnumerator> serial_device_enumerator =
23 device::SerialDeviceEnumerator::Create();
24
25 mojo::Array<device::serial::DeviceInfoPtr> devices =
26 serial_device_enumerator->GetDevices();
27
28 for (size_t i = 0; i < devices.size(); i++) {
29 std::string display_name = devices[i]->display_name.get();
30
31 if (display_name.find(kBattOrDisplayNamePrefix) != std::string::npos) {
32 return devices[i]->path;
33 }
34 }
35
36 return std::string();
37 }
38
39 } // namespace battor
OLDNEW
« no previous file with comments | « tools/battor_agent/battor_finder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698