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

Unified Diff: tools/battor_agent/battor_protocol_types.h

Issue 1524873002: Creates a BattOrConnection for communicating with the BattOr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing dep Created 5 years 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_error.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/battor_agent/battor_protocol_types.h
diff --git a/tools/battor_agent/battor_protocol_types.h b/tools/battor_agent/battor_protocol_types.h
new file mode 100644
index 0000000000000000000000000000000000000000..dbd3bf4c49ae85639492d8afa16d53d984e88cb6
--- /dev/null
+++ b/tools/battor_agent/battor_protocol_types.h
@@ -0,0 +1,80 @@
+// 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.
+
+#ifndef TOOLS_BATTOR_AGENT_BATTOR_PROTOCOL_H_
+#define TOOLS_BATTOR_AGENT_BATTOR_PROTOCOL_H_
+
+namespace battor {
+
+// Control characters in the BattOr protocol.
+enum BattOrControlByte : uint8_t {
+ // Indicates the start of a message in the protocol. All other instances of
+ // this byte must be escaped (with BATTOR_SPECIAL_BYTE_ESCAPE).
+ BATTOR_CONTROL_BYTE_START = 0x00,
+ // Indicates the end of a message in the protocol. All other instances of
+ // this byte must be escaped (with BATTOR_SPECIAL_BYTE_ESCAPE).
+ BATTOR_CONTROL_BYTE_END = 0x01,
+ // Indicates that the next byte should not be interpreted as a special
+ // character, but should instead be interpreted as itself.
+ BATTOR_CONTROL_BYTE_ESCAPE = 0x02,
+};
+
+// Types of BattOr messages that can be sent.
+enum BattOrMessageType : uint8_t {
+ // Indicates a control message sent from the client to the BattOr to tell the
+ // BattOr to do something.
+ BATTOR_MESSAGE_TYPE_CONTROL = 0x03,
+ // Indicates a control message ack sent from the BattOr back to the client to
+ // signal that the BattOr received the control message.
+ BATTOR_MESSAGE_TYPE_CONTROL_ACK,
+ // Indicates that the message contains Voltage and current measurements.
+ BATTOR_MESSAGE_TYPE_SAMPLES,
+ // TODO(charliea): Figure out what this is.
+ BATTOR_MESSAGE_TYPE_PRINT,
+};
+
+// Types of BattOr control messages that can be sent.
+enum BattOrControlMessageType : uint8_t {
+ // Tells the BattOr to initialize itself.
+ BATTOR_CONTROL_MESSAGE_TYPE_INIT = 0x00,
+ // Sets the current measurement's gain.
+ BATTOR_CONTROL_MESSAGE_TYPE_SET_GAIN,
+ // Tells the BattOr to start taking samples and sending them over the
+ // connection.
+ BATTOR_CONTROL_MESSAGE_TYPE_START_SAMPLING_UART,
+ // Tells the BattOr to start taking samples and storing them on its SD card.
+ BATTOR_CONTROL_MESSAGE_TYPE_START_SAMPLING_SD,
+ // Tells the BattOr to start streaming the samples stored on its SD card over
+ // the connection.
+ BATTOR_CONTROL_MESSAGE_TYPE_READ_SD_UART,
+ // Tells the BattOr to send its EEPROM contents over the serial connection.
+ BATTOR_CONTROL_MESSAGE_TYPE_READ_EEPROM,
+ // Tells the BattOr to reset itself.
+ BATTOR_CONTROL_MESSAGE_TYPE_RESET,
+ // Tells the BattOr to run a self test.
+ BATTOR_CONTROL_MESSAGE_TYPE_SELF_TEST,
+};
+
+// See: BattOrMessageType::BATTOR_MESSAGE_TYPE_CONTROL above.
+//
+// This struct is packed to ensure that this binary and the firmware are
+// byte-compatible.
+struct BattOrControlMessage {
+ BattOrControlMessageType type;
+ uint16_t param1;
+ uint16_t param2;
+} __attribute__((packed));
+
+// See: BattOrMessageType::BATTOR_MESSAGE_TYPE_CONTROL_ACK above.
+struct BattOrControlMessageAck {
+ BattOrControlMessageType type;
+ uint8_t param;
+} __attribute__((packed));
+
+// The gain level for the BattOr to use.
+enum BattOrGain : uint8_t { BATTOR_GAIN_LOW = 0, BATTOR_GAIN_HIGH };
+
+} // namespace battor
+
+#endif // TOOLS_BATTOR_AGENT_BATTOR_PROTOCOL_H_
« no previous file with comments | « tools/battor_agent/battor_error.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698