| Index: tools/dom/src/chrome/serial.dart
|
| diff --git a/tools/dom/src/chrome/serial.dart b/tools/dom/src/chrome/serial.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a1794c68f23a30c95d3a8df8b6c09365d596ef73
|
| --- /dev/null
|
| +++ b/tools/dom/src/chrome/serial.dart
|
| @@ -0,0 +1,256 @@
|
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
| +// for details. 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 namespace: serial
|
| +
|
| +part of chrome;
|
| +
|
| +/**
|
| + * Types
|
| + */
|
| +
|
| +class SerialOpenOptions extends ChromeObject {
|
| + /*
|
| + * Public constructor
|
| + */
|
| + SerialOpenOptions({int bitrate}) {
|
| + if (?bitrate)
|
| + this.bitrate = bitrate;
|
| + }
|
| +
|
| + /*
|
| + * Private constructor
|
| + */
|
| + SerialOpenOptions._proxy(_jsObject) : super._proxy(_jsObject);
|
| +
|
| + /*
|
| + * Public accessors
|
| + */
|
| + /// 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.
|
| + int get bitrate => JS('int', '#.bitrate', this._jsObject);
|
| +
|
| + void set bitrate(int bitrate) {
|
| + JS('void', '#.bitrate = #', this._jsObject, bitrate);
|
| + }
|
| +
|
| +}
|
| +
|
| +class SerialOpenInfo extends ChromeObject {
|
| + /*
|
| + * Public constructor
|
| + */
|
| + SerialOpenInfo({int connectionId}) {
|
| + if (?connectionId)
|
| + this.connectionId = connectionId;
|
| + }
|
| +
|
| + /*
|
| + * Private constructor
|
| + */
|
| + SerialOpenInfo._proxy(_jsObject) : super._proxy(_jsObject);
|
| +
|
| + /*
|
| + * Public accessors
|
| + */
|
| + /// The id of the opened connection.
|
| + int get connectionId => JS('int', '#.connectionId', this._jsObject);
|
| +
|
| + void set connectionId(int connectionId) {
|
| + JS('void', '#.connectionId = #', this._jsObject, connectionId);
|
| + }
|
| +
|
| +}
|
| +
|
| +class SerialReadInfo extends ChromeObject {
|
| + /*
|
| + * Public constructor
|
| + */
|
| + SerialReadInfo({int bytesRead, String data}) {
|
| + if (?bytesRead)
|
| + this.bytesRead = bytesRead;
|
| + if (?data)
|
| + this.data = data;
|
| + }
|
| +
|
| + /*
|
| + * Private constructor
|
| + */
|
| + SerialReadInfo._proxy(_jsObject) : super._proxy(_jsObject);
|
| +
|
| + /*
|
| + * Public accessors
|
| + */
|
| + /// The number of bytes received, or a negative number if an error occurred.
|
| + /// This number will be smaller than the number of bytes requested in the
|
| + /// original read call if the call would need to block to read that number of
|
| + /// bytes.
|
| + int get bytesRead => JS('int', '#.bytesRead', this._jsObject);
|
| +
|
| + void set bytesRead(int bytesRead) {
|
| + JS('void', '#.bytesRead = #', this._jsObject, bytesRead);
|
| + }
|
| +
|
| + /// The data received.
|
| + String get data => JS('String', '#.data', this._jsObject);
|
| +
|
| + void set data(String data) {
|
| + JS('void', '#.data = #', this._jsObject, data);
|
| + }
|
| +
|
| +}
|
| +
|
| +class SerialWriteInfo extends ChromeObject {
|
| + /*
|
| + * Public constructor
|
| + */
|
| + SerialWriteInfo({int bytesWritten}) {
|
| + if (?bytesWritten)
|
| + this.bytesWritten = bytesWritten;
|
| + }
|
| +
|
| + /*
|
| + * Private constructor
|
| + */
|
| + SerialWriteInfo._proxy(_jsObject) : super._proxy(_jsObject);
|
| +
|
| + /*
|
| + * Public accessors
|
| + */
|
| + /// The number of bytes written.
|
| + int get bytesWritten => JS('int', '#.bytesWritten', this._jsObject);
|
| +
|
| + void set bytesWritten(int bytesWritten) {
|
| + JS('void', '#.bytesWritten = #', this._jsObject, bytesWritten);
|
| + }
|
| +
|
| +}
|
| +
|
| +class SerialControlSignalOptions extends ChromeObject {
|
| + /*
|
| + * Public constructor
|
| + */
|
| + SerialControlSignalOptions({bool dtr, bool rts, bool dcd, bool cts}) {
|
| + if (?dtr)
|
| + this.dtr = dtr;
|
| + if (?rts)
|
| + this.rts = rts;
|
| + if (?dcd)
|
| + this.dcd = dcd;
|
| + if (?cts)
|
| + this.cts = cts;
|
| + }
|
| +
|
| + /*
|
| + * Private constructor
|
| + */
|
| + SerialControlSignalOptions._proxy(_jsObject) : super._proxy(_jsObject);
|
| +
|
| + /*
|
| + * Public accessors
|
| + */
|
| + /// Serial control signals that your machine can send. Missing fields will be
|
| + /// set to false.
|
| + bool get dtr => JS('bool', '#.dtr', this._jsObject);
|
| +
|
| + void set dtr(bool dtr) {
|
| + JS('void', '#.dtr = #', this._jsObject, dtr);
|
| + }
|
| +
|
| + bool get rts => JS('bool', '#.rts', this._jsObject);
|
| +
|
| + void set rts(bool rts) {
|
| + JS('void', '#.rts = #', this._jsObject, rts);
|
| + }
|
| +
|
| + /// Serial control signals that your machine can receive. If a get operation
|
| + /// fails, success will be false, and these fields will be absent.<br/><br/>
|
| + /// DCD (Data Carrier Detect) is equivalent to RLSD (Receive Line Signal
|
| + /// Detect) on some platforms.
|
| + bool get dcd => JS('bool', '#.dcd', this._jsObject);
|
| +
|
| + void set dcd(bool dcd) {
|
| + JS('void', '#.dcd = #', this._jsObject, dcd);
|
| + }
|
| +
|
| + bool get cts => JS('bool', '#.cts', this._jsObject);
|
| +
|
| + void set cts(bool cts) {
|
| + JS('void', '#.cts = #', this._jsObject, cts);
|
| + }
|
| +
|
| +}
|
| +
|
| +/**
|
| + * Functions
|
| + */
|
| +
|
| +class API_serial {
|
| + /*
|
| + * API connection
|
| + */
|
| + Object _jsObject;
|
| +
|
| + /*
|
| + * Functions
|
| + */
|
| + /// Returns names of valid ports on this machine, each of which is likely to be
|
| + /// valid to pass as the port argument to open(). The list is regenerated each
|
| + /// time this method is called, as port validity is dynamic.
|
| + void getPorts(void callback(List<String> ports)) => JS('void', '#.getPorts(#)', this._jsObject, convertDartClosureToJS(callback, 1));
|
| +
|
| + /// Opens a connection to the given serial port.
|
| + void open(String port, void callback(SerialOpenInfo openInfo), [SerialOpenOptions options]) {
|
| + void __proxy_callback(openInfo) {
|
| + if (?callback) {
|
| + callback(new SerialOpenInfo._proxy(openInfo));
|
| + }
|
| + }
|
| + JS('void', '#.open(#, #, #)', this._jsObject, port, convertArgument(options), convertDartClosureToJS(__proxy_callback, 1));
|
| + }
|
| +
|
| + /// Closes an open connection.
|
| + void close(int connectionId, void callback(bool result)) => JS('void', '#.close(#, #)', this._jsObject, connectionId, convertDartClosureToJS(callback, 1));
|
| +
|
| + /// Reads a byte from the given connection.
|
| + void read(int connectionId, int bytesToRead, void callback(SerialReadInfo readInfo)) {
|
| + void __proxy_callback(readInfo) {
|
| + if (?callback) {
|
| + callback(new SerialReadInfo._proxy(readInfo));
|
| + }
|
| + }
|
| + JS('void', '#.read(#, #, #)', this._jsObject, connectionId, bytesToRead, convertDartClosureToJS(__proxy_callback, 1));
|
| + }
|
| +
|
| + /// Writes a string to the given connection.
|
| + void write(int connectionId, String data, void callback(SerialWriteInfo writeInfo)) {
|
| + void __proxy_callback(writeInfo) {
|
| + if (?callback) {
|
| + callback(new SerialWriteInfo._proxy(writeInfo));
|
| + }
|
| + }
|
| + JS('void', '#.write(#, #, #)', this._jsObject, connectionId, data, convertDartClosureToJS(__proxy_callback, 1));
|
| + }
|
| +
|
| + /// Flushes all bytes in the given connection's input and output buffers.
|
| + void flush(int connectionId, void callback(bool result)) => JS('void', '#.flush(#, #)', this._jsObject, connectionId, convertDartClosureToJS(callback, 1));
|
| +
|
| + void getControlSignals(int connectionId, void callback(SerialControlSignalOptions options)) {
|
| + void __proxy_callback(options) {
|
| + if (?callback) {
|
| + callback(new SerialControlSignalOptions._proxy(options));
|
| + }
|
| + }
|
| + JS('void', '#.getControlSignals(#, #)', this._jsObject, connectionId, convertDartClosureToJS(__proxy_callback, 1));
|
| + }
|
| +
|
| + void setControlSignals(int connectionId, SerialControlSignalOptions options, void callback(bool result)) => JS('void', '#.setControlSignals(#, #, #)', this._jsObject, connectionId, convertArgument(options), convertDartClosureToJS(callback, 1));
|
| +
|
| + API_serial(this._jsObject) {
|
| + }
|
| +}
|
|
|