| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 // Generated from namespace: serial |
| 6 |
| 7 part of chrome; |
| 8 |
| 9 /** |
| 10 * Types |
| 11 */ |
| 12 |
| 13 class SerialOpenOptions extends ChromeObject { |
| 14 /* |
| 15 * Public constructor |
| 16 */ |
| 17 SerialOpenOptions({int bitrate}) { |
| 18 if (?bitrate) |
| 19 this.bitrate = bitrate; |
| 20 } |
| 21 |
| 22 /* |
| 23 * Private constructor |
| 24 */ |
| 25 SerialOpenOptions._proxy(_jsObject) : super._proxy(_jsObject); |
| 26 |
| 27 /* |
| 28 * Public accessors |
| 29 */ |
| 30 /// The requested bitrate of the connection to be opened. For compatibility |
| 31 /// with the widest range of hardware, this number should match one of |
| 32 /// commonly-available bitrates, such as 110, 300, 1200, 2400, 4800, 9600, |
| 33 /// 14400, 19200, 38400, 57600, 115200. There is no guarantee, of course, that |
| 34 /// the device connected to the serial port will support the requested bitrate
, |
| 35 /// even if the port itself supports that bitrate. |
| 36 int get bitrate => JS('int', '#.bitrate', this._jsObject); |
| 37 |
| 38 void set bitrate(int bitrate) { |
| 39 JS('void', '#.bitrate = #', this._jsObject, bitrate); |
| 40 } |
| 41 |
| 42 } |
| 43 |
| 44 class SerialOpenInfo extends ChromeObject { |
| 45 /* |
| 46 * Public constructor |
| 47 */ |
| 48 SerialOpenInfo({int connectionId}) { |
| 49 if (?connectionId) |
| 50 this.connectionId = connectionId; |
| 51 } |
| 52 |
| 53 /* |
| 54 * Private constructor |
| 55 */ |
| 56 SerialOpenInfo._proxy(_jsObject) : super._proxy(_jsObject); |
| 57 |
| 58 /* |
| 59 * Public accessors |
| 60 */ |
| 61 /// The id of the opened connection. |
| 62 int get connectionId => JS('int', '#.connectionId', this._jsObject); |
| 63 |
| 64 void set connectionId(int connectionId) { |
| 65 JS('void', '#.connectionId = #', this._jsObject, connectionId); |
| 66 } |
| 67 |
| 68 } |
| 69 |
| 70 class SerialReadInfo extends ChromeObject { |
| 71 /* |
| 72 * Public constructor |
| 73 */ |
| 74 SerialReadInfo({int bytesRead, String data}) { |
| 75 if (?bytesRead) |
| 76 this.bytesRead = bytesRead; |
| 77 if (?data) |
| 78 this.data = data; |
| 79 } |
| 80 |
| 81 /* |
| 82 * Private constructor |
| 83 */ |
| 84 SerialReadInfo._proxy(_jsObject) : super._proxy(_jsObject); |
| 85 |
| 86 /* |
| 87 * Public accessors |
| 88 */ |
| 89 /// The number of bytes received, or a negative number if an error occurred. |
| 90 /// This number will be smaller than the number of bytes requested in the |
| 91 /// original read call if the call would need to block to read that number of |
| 92 /// bytes. |
| 93 int get bytesRead => JS('int', '#.bytesRead', this._jsObject); |
| 94 |
| 95 void set bytesRead(int bytesRead) { |
| 96 JS('void', '#.bytesRead = #', this._jsObject, bytesRead); |
| 97 } |
| 98 |
| 99 /// The data received. |
| 100 String get data => JS('String', '#.data', this._jsObject); |
| 101 |
| 102 void set data(String data) { |
| 103 JS('void', '#.data = #', this._jsObject, data); |
| 104 } |
| 105 |
| 106 } |
| 107 |
| 108 class SerialWriteInfo extends ChromeObject { |
| 109 /* |
| 110 * Public constructor |
| 111 */ |
| 112 SerialWriteInfo({int bytesWritten}) { |
| 113 if (?bytesWritten) |
| 114 this.bytesWritten = bytesWritten; |
| 115 } |
| 116 |
| 117 /* |
| 118 * Private constructor |
| 119 */ |
| 120 SerialWriteInfo._proxy(_jsObject) : super._proxy(_jsObject); |
| 121 |
| 122 /* |
| 123 * Public accessors |
| 124 */ |
| 125 /// The number of bytes written. |
| 126 int get bytesWritten => JS('int', '#.bytesWritten', this._jsObject); |
| 127 |
| 128 void set bytesWritten(int bytesWritten) { |
| 129 JS('void', '#.bytesWritten = #', this._jsObject, bytesWritten); |
| 130 } |
| 131 |
| 132 } |
| 133 |
| 134 class SerialControlSignalOptions extends ChromeObject { |
| 135 /* |
| 136 * Public constructor |
| 137 */ |
| 138 SerialControlSignalOptions({bool dtr, bool rts, bool dcd, bool cts}) { |
| 139 if (?dtr) |
| 140 this.dtr = dtr; |
| 141 if (?rts) |
| 142 this.rts = rts; |
| 143 if (?dcd) |
| 144 this.dcd = dcd; |
| 145 if (?cts) |
| 146 this.cts = cts; |
| 147 } |
| 148 |
| 149 /* |
| 150 * Private constructor |
| 151 */ |
| 152 SerialControlSignalOptions._proxy(_jsObject) : super._proxy(_jsObject); |
| 153 |
| 154 /* |
| 155 * Public accessors |
| 156 */ |
| 157 /// Serial control signals that your machine can send. Missing fields will be |
| 158 /// set to false. |
| 159 bool get dtr => JS('bool', '#.dtr', this._jsObject); |
| 160 |
| 161 void set dtr(bool dtr) { |
| 162 JS('void', '#.dtr = #', this._jsObject, dtr); |
| 163 } |
| 164 |
| 165 bool get rts => JS('bool', '#.rts', this._jsObject); |
| 166 |
| 167 void set rts(bool rts) { |
| 168 JS('void', '#.rts = #', this._jsObject, rts); |
| 169 } |
| 170 |
| 171 /// Serial control signals that your machine can receive. If a get operation |
| 172 /// fails, success will be false, and these fields will be absent.<br/><br/> |
| 173 /// DCD (Data Carrier Detect) is equivalent to RLSD (Receive Line Signal |
| 174 /// Detect) on some platforms. |
| 175 bool get dcd => JS('bool', '#.dcd', this._jsObject); |
| 176 |
| 177 void set dcd(bool dcd) { |
| 178 JS('void', '#.dcd = #', this._jsObject, dcd); |
| 179 } |
| 180 |
| 181 bool get cts => JS('bool', '#.cts', this._jsObject); |
| 182 |
| 183 void set cts(bool cts) { |
| 184 JS('void', '#.cts = #', this._jsObject, cts); |
| 185 } |
| 186 |
| 187 } |
| 188 |
| 189 /** |
| 190 * Functions |
| 191 */ |
| 192 |
| 193 class API_serial { |
| 194 /* |
| 195 * API connection |
| 196 */ |
| 197 Object _jsObject; |
| 198 |
| 199 /* |
| 200 * Functions |
| 201 */ |
| 202 /// Returns names of valid ports on this machine, each of which is likely to b
e |
| 203 /// valid to pass as the port argument to open(). The list is regenerated each |
| 204 /// time this method is called, as port validity is dynamic. |
| 205 void getPorts(void callback(List<String> ports)) => JS('void', '#.getPorts(#)'
, this._jsObject, convertDartClosureToJS(callback, 1)); |
| 206 |
| 207 /// Opens a connection to the given serial port. |
| 208 void open(String port, void callback(SerialOpenInfo openInfo), [SerialOpenOpti
ons options]) { |
| 209 void __proxy_callback(openInfo) { |
| 210 if (?callback) { |
| 211 callback(new SerialOpenInfo._proxy(openInfo)); |
| 212 } |
| 213 } |
| 214 JS('void', '#.open(#, #, #)', this._jsObject, port, convertArgument(options)
, convertDartClosureToJS(__proxy_callback, 1)); |
| 215 } |
| 216 |
| 217 /// Closes an open connection. |
| 218 void close(int connectionId, void callback(bool result)) => JS('void', '#.clos
e(#, #)', this._jsObject, connectionId, convertDartClosureToJS(callback, 1)); |
| 219 |
| 220 /// Reads a byte from the given connection. |
| 221 void read(int connectionId, int bytesToRead, void callback(SerialReadInfo read
Info)) { |
| 222 void __proxy_callback(readInfo) { |
| 223 if (?callback) { |
| 224 callback(new SerialReadInfo._proxy(readInfo)); |
| 225 } |
| 226 } |
| 227 JS('void', '#.read(#, #, #)', this._jsObject, connectionId, bytesToRead, con
vertDartClosureToJS(__proxy_callback, 1)); |
| 228 } |
| 229 |
| 230 /// Writes a string to the given connection. |
| 231 void write(int connectionId, String data, void callback(SerialWriteInfo writeI
nfo)) { |
| 232 void __proxy_callback(writeInfo) { |
| 233 if (?callback) { |
| 234 callback(new SerialWriteInfo._proxy(writeInfo)); |
| 235 } |
| 236 } |
| 237 JS('void', '#.write(#, #, #)', this._jsObject, connectionId, data, convertDa
rtClosureToJS(__proxy_callback, 1)); |
| 238 } |
| 239 |
| 240 /// Flushes all bytes in the given connection's input and output buffers. |
| 241 void flush(int connectionId, void callback(bool result)) => JS('void', '#.flus
h(#, #)', this._jsObject, connectionId, convertDartClosureToJS(callback, 1)); |
| 242 |
| 243 void getControlSignals(int connectionId, void callback(SerialControlSignalOpti
ons options)) { |
| 244 void __proxy_callback(options) { |
| 245 if (?callback) { |
| 246 callback(new SerialControlSignalOptions._proxy(options)); |
| 247 } |
| 248 } |
| 249 JS('void', '#.getControlSignals(#, #)', this._jsObject, connectionId, conver
tDartClosureToJS(__proxy_callback, 1)); |
| 250 } |
| 251 |
| 252 void setControlSignals(int connectionId, SerialControlSignalOptions options, v
oid callback(bool result)) => JS('void', '#.setControlSignals(#, #, #)', this._j
sObject, connectionId, convertArgument(options), convertDartClosureToJS(callback
, 1)); |
| 253 |
| 254 API_serial(this._jsObject) { |
| 255 } |
| 256 } |
| OLD | NEW |