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

Side by Side Diff: tools/battor_agent/battor_agent.h

Issue 2390893002: [BattOr] Make BattOr able to return firmware version. (Closed)
Patch Set: First functional 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/battor_agent/battor_agent.cc » ('j') | tools/battor_agent/battor_agent.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef TOOLS_BATTOR_AGENT_BATTOR_AGENT_H_ 5 #ifndef TOOLS_BATTOR_AGENT_BATTOR_AGENT_H_
6 #define TOOLS_BATTOR_AGENT_BATTOR_AGENT_H_ 6 #define TOOLS_BATTOR_AGENT_BATTOR_AGENT_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/cancelable_callback.h" 10 #include "base/cancelable_callback.h"
(...skipping 25 matching lines...) Expand all
36 public base::SupportsWeakPtr<BattOrAgent> { 36 public base::SupportsWeakPtr<BattOrAgent> {
37 public: 37 public:
38 // The listener interface that must be implemented in order to interact with 38 // The listener interface that must be implemented in order to interact with
39 // the BattOrAgent. 39 // the BattOrAgent.
40 class Listener { 40 class Listener {
41 public: 41 public:
42 virtual void OnStartTracingComplete(BattOrError error) = 0; 42 virtual void OnStartTracingComplete(BattOrError error) = 0;
43 virtual void OnStopTracingComplete(const std::string& trace, 43 virtual void OnStopTracingComplete(const std::string& trace,
44 BattOrError error) = 0; 44 BattOrError error) = 0;
45 virtual void OnRecordClockSyncMarkerComplete(BattOrError error) = 0; 45 virtual void OnRecordClockSyncMarkerComplete(BattOrError error) = 0;
46 virtual void OnGetVersionComplete(const char* version,
charliea (OOO until 10-5) 2016/10/18 23:46:29 Probably should use a const std::string& here?
rnephew (Reviews Here) 2016/10/19 18:23:48 Done.
47 BattOrError error) = 0;
46 }; 48 };
47 49
48 BattOrAgent( 50 BattOrAgent(
49 const std::string& path, 51 const std::string& path,
50 Listener* listener, 52 Listener* listener,
51 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, 53 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner,
52 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner); 54 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner);
53 virtual ~BattOrAgent(); 55 virtual ~BattOrAgent();
54 56
55 void StartTracing(); 57 void StartTracing();
56 void StopTracing(); 58 void StopTracing();
57 void RecordClockSyncMarker(const std::string& marker); 59 void RecordClockSyncMarker(const std::string& marker);
60 void GetVersion();
58 61
59 // Returns whether the BattOr is able to record clock sync markers in its own 62 // Returns whether the BattOr is able to record clock sync markers in its own
60 // trace log. 63 // trace log.
61 static bool SupportsExplicitClockSync() { return true; } 64 static bool SupportsExplicitClockSync() { return true; }
62 65
63 // BattOrConnection::Listener implementation. 66 // BattOrConnection::Listener implementation.
64 void OnConnectionOpened(bool success) override; 67 void OnConnectionOpened(bool success) override;
65 void OnBytesSent(bool success) override; 68 void OnBytesSent(bool success) override;
66 void OnMessageRead(bool success, 69 void OnMessageRead(bool success,
67 BattOrMessageType type, 70 BattOrMessageType type,
(...skipping 10 matching lines...) Expand all
78 // testing task runner that runs delayed tasks immediately deals poorly with 81 // testing task runner that runs delayed tasks immediately deals poorly with
79 // timeouts posted as future tasks. 82 // timeouts posted as future tasks.
80 virtual void OnActionTimeout(); 83 virtual void OnActionTimeout();
81 84
82 private: 85 private:
83 enum class Command { 86 enum class Command {
84 INVALID, 87 INVALID,
85 START_TRACING, 88 START_TRACING,
86 STOP_TRACING, 89 STOP_TRACING,
87 RECORD_CLOCK_SYNC_MARKER, 90 RECORD_CLOCK_SYNC_MARKER,
91 GET_VERSION,
88 }; 92 };
89 93
90 enum class Action { 94 enum class Action {
91 INVALID, 95 INVALID,
92 96
93 // Actions required to connect to a BattOr. 97 // Actions required to connect to a BattOr.
94 REQUEST_CONNECTION, 98 REQUEST_CONNECTION,
95 99
96 // Actions required for starting tracing. 100 // Actions required for starting tracing.
97 SEND_INIT, 101 SEND_INIT,
98 READ_INIT_ACK, 102 READ_INIT_ACK,
99 SEND_SET_GAIN, 103 SEND_SET_GAIN,
100 READ_SET_GAIN_ACK, 104 READ_SET_GAIN_ACK,
101 SEND_START_TRACING, 105 SEND_START_TRACING,
102 READ_START_TRACING_ACK, 106 READ_START_TRACING_ACK,
103 107
104 // Actions required for stopping tracing. 108 // Actions required for stopping tracing.
105 SEND_EEPROM_REQUEST, 109 SEND_EEPROM_REQUEST,
106 READ_EEPROM, 110 READ_EEPROM,
107 SEND_SAMPLES_REQUEST, 111 SEND_SAMPLES_REQUEST,
108 READ_CALIBRATION_FRAME, 112 READ_CALIBRATION_FRAME,
109 READ_DATA_FRAME, 113 READ_DATA_FRAME,
110 114
111 // Actions required for recording a clock sync marker. 115 // Actions required for recording a clock sync marker.
112 SEND_CURRENT_SAMPLE_REQUEST, 116 SEND_CURRENT_SAMPLE_REQUEST,
113 READ_CURRENT_SAMPLE, 117 READ_CURRENT_SAMPLE,
118
119 // Actions required for checking firmware version.
charliea (OOO until 10-5) 2016/10/18 23:46:29 Maybe "returning the firmware version" instead of
rnephew (Reviews Here) 2016/10/19 18:23:47 Done.
120 SEND_GIT_HASH_REQUEST,
121 READ_GIT_HASH,
114 }; 122 };
115 123
116 // Performs an action. 124 // Performs an action.
117 void PerformAction(Action action); 125 void PerformAction(Action action);
118 // Performs an action after a delay. 126 // Performs an action after a delay.
119 void PerformDelayedAction(Action action, base::TimeDelta delay); 127 void PerformDelayedAction(Action action, base::TimeDelta delay);
120 128
121 129
122 130
123 // Requests a connection to the BattOr. 131 // Requests a connection to the BattOr.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 182
175 // The number of times we've attempted to init the BattOr. 183 // The number of times we've attempted to init the BattOr.
176 uint8_t num_init_attempts_; 184 uint8_t num_init_attempts_;
177 185
178 // The number of times that we've attempted to read the last message. 186 // The number of times that we've attempted to read the last message.
179 uint8_t num_read_attempts_; 187 uint8_t num_read_attempts_;
180 188
181 // The timeout that's run when an action times out. 189 // The timeout that's run when an action times out.
182 base::CancelableClosure timeout_callback_; 190 base::CancelableClosure timeout_callback_;
183 191
192 // The git hash of the BattOr firmware.
193 char* git_hash_;
194
184 DISALLOW_COPY_AND_ASSIGN(BattOrAgent); 195 DISALLOW_COPY_AND_ASSIGN(BattOrAgent);
185 }; 196 };
186 197
187 } // namespace battor 198 } // namespace battor
188 199
189 #endif // TOOLS_BATTOR_AGENT_BATTOR_AGENT_H_ 200 #endif // TOOLS_BATTOR_AGENT_BATTOR_AGENT_H_
OLDNEW
« no previous file with comments | « no previous file | tools/battor_agent/battor_agent.cc » ('j') | tools/battor_agent/battor_agent.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698