// Copyright (c) 2019 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. // GENERATED FROM THE API DEFINITION IN // extensions/common/api/serial.idl // DO NOT EDIT. #ifndef EXTENSIONS_COMMON_API_SERIAL_H__ #define EXTENSIONS_COMMON_API_SERIAL_H__ #include #include #include #include #include #include "base/logging.h" #include "base/values.h" namespace extensions { namespace api { namespace serial { // // Types // struct DeviceInfo { DeviceInfo(); ~DeviceInfo(); DeviceInfo(DeviceInfo&& rhs); DeviceInfo& operator=(DeviceInfo&& rhs); // Populates a DeviceInfo object from a base::Value. Returns whether |out| was // successfully populated. static bool Populate(const base::Value& value, DeviceInfo* out); // Creates a DeviceInfo object from a base::Value, or NULL on failure. static std::unique_ptr FromValue(const base::Value& value); // Returns a new base::DictionaryValue representing the serialized form of // this DeviceInfo object. std::unique_ptr ToValue() const; // The device's system path. This should be passed as the path // argument to chrome.serial.connect in order to connect to this // device. std::string path; // A PCI or USB vendor ID if one can be determined for the underlying device. std::unique_ptr vendor_id; // A USB product ID if one can be determined for the underlying device. std::unique_ptr product_id; // A human-readable display name for the underlying device if one can be queried // from the host driver. std::unique_ptr display_name; private: DISALLOW_COPY_AND_ASSIGN(DeviceInfo); }; enum DataBits { DATA_BITS_NONE, DATA_BITS_SEVEN, DATA_BITS_EIGHT, DATA_BITS_LAST = DATA_BITS_EIGHT, }; const char* ToString(DataBits as_enum); DataBits ParseDataBits(const std::string& as_string); enum ParityBit { PARITY_BIT_NONE, PARITY_BIT_NO, PARITY_BIT_ODD, PARITY_BIT_EVEN, PARITY_BIT_LAST = PARITY_BIT_EVEN, }; const char* ToString(ParityBit as_enum); ParityBit ParseParityBit(const std::string& as_string); enum StopBits { STOP_BITS_NONE, STOP_BITS_ONE, STOP_BITS_TWO, STOP_BITS_LAST = STOP_BITS_TWO, }; const char* ToString(StopBits as_enum); StopBits ParseStopBits(const std::string& as_string); struct ConnectionOptions { ConnectionOptions(); ~ConnectionOptions(); ConnectionOptions(ConnectionOptions&& rhs); ConnectionOptions& operator=(ConnectionOptions&& rhs); // Populates a ConnectionOptions object from a base::Value. Returns whether // |out| was successfully populated. static bool Populate(const base::Value& value, ConnectionOptions* out); // Creates a ConnectionOptions object from a base::Value, or NULL on failure. static std::unique_ptr FromValue(const base::Value& value); // Returns a new base::DictionaryValue representing the serialized form of // this ConnectionOptions object. std::unique_ptr ToValue() const; // Flag indicating whether or not the connection should be left open when the // application is suspended (see Manage App // Lifecycle). The default value is "false." When the application is loaded, // any serial connections previously opened with persistent=true can be fetched // with getConnections. std::unique_ptr persistent; // An application-defined string to associate with the connection. std::unique_ptr name; // The size of the buffer used to receive data. The default value is 4096. std::unique_ptr buffer_size; // The requested bitrate of the connection to be opened. For compatibility with // the widest range of hardware, this number should match one of // commonly-available bitrates, such as 110, 300, 1200, 2400, 4800, 9600, 14400, // 19200, 38400, 57600, 115200. There is no guarantee, of course, that the // device connected to the serial port will support the requested bitrate, even // if the port itself supports that bitrate. 9600 will be passed by // default. std::unique_ptr bitrate; // "eight" will be passed by default. DataBits data_bits; // "no" will be passed by default. ParityBit parity_bit; // "one" will be passed by default. StopBits stop_bits; // Flag indicating whether or not to enable RTS/CTS hardware flow control. // Defaults to false. std::unique_ptr cts_flow_control; // The maximum amount of time (in milliseconds) to wait for new data before // raising an onReceiveError event with a "timeout" error. If zero, // receive timeout errors will not be raised for the connection. Defaults to 0. std::unique_ptr receive_timeout; // The maximum amount of time (in milliseconds) to wait for a send // operation to complete before calling the callback with a "timeout" error. If // zero, send timeout errors will not be triggered. Defaults to 0. std::unique_ptr send_timeout; private: DISALLOW_COPY_AND_ASSIGN(ConnectionOptions); }; struct ConnectionInfo { ConnectionInfo(); ~ConnectionInfo(); ConnectionInfo(ConnectionInfo&& rhs); ConnectionInfo& operator=(ConnectionInfo&& rhs); // Populates a ConnectionInfo object from a base::Value. Returns whether |out| // was successfully populated. static bool Populate(const base::Value& value, ConnectionInfo* out); // Creates a ConnectionInfo object from a base::Value, or NULL on failure. static std::unique_ptr FromValue(const base::Value& value); // Returns a new base::DictionaryValue representing the serialized form of // this ConnectionInfo object. std::unique_ptr ToValue() const; // The id of the serial port connection. int connection_id; // Flag indicating whether the connection is blocked from firing onReceive // events. bool paused; // See ConnectionOptions.persistent bool persistent; // See ConnectionOptions.name std::string name; // See ConnectionOptions.bufferSize int buffer_size; // See ConnectionOptions.receiveTimeout int receive_timeout; // See ConnectionOptions.sendTimeout int send_timeout; // See ConnectionOptions.bitrate. This field may be omitted or // inaccurate if a non-standard bitrate is in use, or if an error occurred while // querying the underlying device. std::unique_ptr bitrate; // See ConnectionOptions.dataBits. This field may be omitted if an // error occurred while querying the underlying device. DataBits data_bits; // See ConnectionOptions.parityBit. This field may be omitted if an // error occurred while querying the underlying device. ParityBit parity_bit; // See ConnectionOptions.stopBits. This field may be omitted if an // error occurred while querying the underlying device. StopBits stop_bits; // See ConnectionOptions.ctsFlowControl. This field may be omitted // if an error occurred while querying the underlying device. std::unique_ptr cts_flow_control; private: DISALLOW_COPY_AND_ASSIGN(ConnectionInfo); }; enum SendError { SEND_ERROR_NONE, SEND_ERROR_DISCONNECTED, SEND_ERROR_PENDING, SEND_ERROR_TIMEOUT, SEND_ERROR_SYSTEM_ERROR, SEND_ERROR_LAST = SEND_ERROR_SYSTEM_ERROR, }; const char* ToString(SendError as_enum); SendError ParseSendError(const std::string& as_string); struct SendInfo { SendInfo(); ~SendInfo(); SendInfo(SendInfo&& rhs); SendInfo& operator=(SendInfo&& rhs); // Populates a SendInfo object from a base::Value. Returns whether |out| was // successfully populated. static bool Populate(const base::Value& value, SendInfo* out); // Creates a SendInfo object from a base::Value, or NULL on failure. static std::unique_ptr FromValue(const base::Value& value); // Returns a new base::DictionaryValue representing the serialized form of // this SendInfo object. std::unique_ptr ToValue() const; // The number of bytes sent. int bytes_sent; // An error code if an error occurred. SendError error; private: DISALLOW_COPY_AND_ASSIGN(SendInfo); }; struct HostControlSignals { HostControlSignals(); ~HostControlSignals(); HostControlSignals(HostControlSignals&& rhs); HostControlSignals& operator=(HostControlSignals&& rhs); // Populates a HostControlSignals object from a base::Value. Returns whether // |out| was successfully populated. static bool Populate(const base::Value& value, HostControlSignals* out); // Creates a HostControlSignals object from a base::Value, or NULL on failure. static std::unique_ptr FromValue(const base::Value& value); // Returns a new base::DictionaryValue representing the serialized form of // this HostControlSignals object. std::unique_ptr ToValue() const; // DTR (Data Terminal Ready). std::unique_ptr dtr; // RTS (Request To Send). std::unique_ptr rts; private: DISALLOW_COPY_AND_ASSIGN(HostControlSignals); }; struct DeviceControlSignals { DeviceControlSignals(); ~DeviceControlSignals(); DeviceControlSignals(DeviceControlSignals&& rhs); DeviceControlSignals& operator=(DeviceControlSignals&& rhs); // Populates a DeviceControlSignals object from a base::Value. Returns whether // |out| was successfully populated. static bool Populate(const base::Value& value, DeviceControlSignals* out); // Creates a DeviceControlSignals object from a base::Value, or NULL on // failure. static std::unique_ptr FromValue(const base::Value& value); // Returns a new base::DictionaryValue representing the serialized form of // this DeviceControlSignals object. std::unique_ptr ToValue() const; // DCD (Data Carrier Detect) or RLSD (Receive Line Signal/ Detect). bool dcd; // CTS (Clear To Send). bool cts; // RI (Ring Indicator). bool ri; // DSR (Data Set Ready). bool dsr; private: DISALLOW_COPY_AND_ASSIGN(DeviceControlSignals); }; struct ReceiveInfo { ReceiveInfo(); ~ReceiveInfo(); ReceiveInfo(ReceiveInfo&& rhs); ReceiveInfo& operator=(ReceiveInfo&& rhs); // Populates a ReceiveInfo object from a base::Value. Returns whether |out| // was successfully populated. static bool Populate(const base::Value& value, ReceiveInfo* out); // Creates a ReceiveInfo object from a base::Value, or NULL on failure. static std::unique_ptr FromValue(const base::Value& value); // Returns a new base::DictionaryValue representing the serialized form of // this ReceiveInfo object. std::unique_ptr ToValue() const; // The connection identifier. int connection_id; // The data received. std::vector data; private: DISALLOW_COPY_AND_ASSIGN(ReceiveInfo); }; enum ReceiveError { RECEIVE_ERROR_NONE, RECEIVE_ERROR_DISCONNECTED, RECEIVE_ERROR_TIMEOUT, RECEIVE_ERROR_DEVICE_LOST, RECEIVE_ERROR_BREAK, RECEIVE_ERROR_FRAME_ERROR, RECEIVE_ERROR_OVERRUN, RECEIVE_ERROR_BUFFER_OVERFLOW, RECEIVE_ERROR_PARITY_ERROR, RECEIVE_ERROR_SYSTEM_ERROR, RECEIVE_ERROR_LAST = RECEIVE_ERROR_SYSTEM_ERROR, }; const char* ToString(ReceiveError as_enum); ReceiveError ParseReceiveError(const std::string& as_string); struct ReceiveErrorInfo { ReceiveErrorInfo(); ~ReceiveErrorInfo(); ReceiveErrorInfo(ReceiveErrorInfo&& rhs); ReceiveErrorInfo& operator=(ReceiveErrorInfo&& rhs); // Populates a ReceiveErrorInfo object from a base::Value. Returns whether // |out| was successfully populated. static bool Populate(const base::Value& value, ReceiveErrorInfo* out); // Creates a ReceiveErrorInfo object from a base::Value, or NULL on failure. static std::unique_ptr FromValue(const base::Value& value); // Returns a new base::DictionaryValue representing the serialized form of // this ReceiveErrorInfo object. std::unique_ptr ToValue() const; // The connection identifier. int connection_id; // An error code indicating what went wrong. ReceiveError error; private: DISALLOW_COPY_AND_ASSIGN(ReceiveErrorInfo); }; // // Functions // namespace GetDevices { namespace Results { std::unique_ptr Create(const std::vector& ports); } // namespace Results } // namespace GetDevices namespace Connect { struct Params { static std::unique_ptr Create(const base::ListValue& args); ~Params(); // The system path of the serial port to open. std::string path; // Port configuration options. std::unique_ptr options; private: Params(); DISALLOW_COPY_AND_ASSIGN(Params); }; namespace Results { std::unique_ptr Create(const ConnectionInfo& connection_info); } // namespace Results } // namespace Connect namespace Update { struct Params { static std::unique_ptr Create(const base::ListValue& args); ~Params(); // The id of the opened connection. int connection_id; // Port configuration options. ConnectionOptions options; private: Params(); DISALLOW_COPY_AND_ASSIGN(Params); }; namespace Results { std::unique_ptr Create(bool result); } // namespace Results } // namespace Update namespace Disconnect { struct Params { static std::unique_ptr Create(const base::ListValue& args); ~Params(); // The id of the opened connection. int connection_id; private: Params(); DISALLOW_COPY_AND_ASSIGN(Params); }; namespace Results { std::unique_ptr Create(bool result); } // namespace Results } // namespace Disconnect namespace SetPaused { struct Params { static std::unique_ptr Create(const base::ListValue& args); ~Params(); // The id of the opened connection. int connection_id; // Flag to indicate whether to pause or unpause. bool paused; private: Params(); DISALLOW_COPY_AND_ASSIGN(Params); }; namespace Results { std::unique_ptr Create(); } // namespace Results } // namespace SetPaused namespace GetInfo { struct Params { static std::unique_ptr Create(const base::ListValue& args); ~Params(); // The id of the opened connection. int connection_id; private: Params(); DISALLOW_COPY_AND_ASSIGN(Params); }; namespace Results { std::unique_ptr Create(const ConnectionInfo& connection_info); } // namespace Results } // namespace GetInfo namespace GetConnections { namespace Results { std::unique_ptr Create(const std::vector& connection_infos); } // namespace Results } // namespace GetConnections namespace Send { struct Params { static std::unique_ptr Create(const base::ListValue& args); ~Params(); // The id of the connection. int connection_id; // The data to send. std::vector data; private: Params(); DISALLOW_COPY_AND_ASSIGN(Params); }; namespace Results { std::unique_ptr Create(const SendInfo& send_info); } // namespace Results } // namespace Send namespace Flush { struct Params { static std::unique_ptr Create(const base::ListValue& args); ~Params(); int connection_id; private: Params(); DISALLOW_COPY_AND_ASSIGN(Params); }; namespace Results { std::unique_ptr Create(bool result); } // namespace Results } // namespace Flush namespace GetControlSignals { struct Params { static std::unique_ptr Create(const base::ListValue& args); ~Params(); // The id of the connection. int connection_id; private: Params(); DISALLOW_COPY_AND_ASSIGN(Params); }; namespace Results { std::unique_ptr Create(const DeviceControlSignals& signals); } // namespace Results } // namespace GetControlSignals namespace SetControlSignals { struct Params { static std::unique_ptr Create(const base::ListValue& args); ~Params(); // The id of the connection. int connection_id; // The set of signal changes to send to the device. HostControlSignals signals; private: Params(); DISALLOW_COPY_AND_ASSIGN(Params); }; namespace Results { std::unique_ptr Create(bool result); } // namespace Results } // namespace SetControlSignals namespace SetBreak { struct Params { static std::unique_ptr Create(const base::ListValue& args); ~Params(); // The id of the connection. int connection_id; private: Params(); DISALLOW_COPY_AND_ASSIGN(Params); }; namespace Results { std::unique_ptr Create(bool result); } // namespace Results } // namespace SetBreak namespace ClearBreak { struct Params { static std::unique_ptr Create(const base::ListValue& args); ~Params(); // The id of the connection. int connection_id; private: Params(); DISALLOW_COPY_AND_ASSIGN(Params); }; namespace Results { std::unique_ptr Create(bool result); } // namespace Results } // namespace ClearBreak // // Events // namespace OnReceive { extern const char kEventName[]; // "serial.onReceive" // Event data. std::unique_ptr Create(const ReceiveInfo& info); } // namespace OnReceive namespace OnReceiveError { extern const char kEventName[]; // "serial.onReceiveError" std::unique_ptr Create(const ReceiveErrorInfo& info); } // namespace OnReceiveError } // namespace serial } // namespace api } // namespace extensions #endif // EXTENSIONS_COMMON_API_SERIAL_H__