OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // File-level comment to appease parser. Eventually this will not be necessary. | |
6 | |
7 [nodoc] namespace experimental.serial { | |
8 | |
9 callback GetPortsCallback = void (DOMString[] ports); | |
10 | |
11 dictionary OpenInfo { | |
12 // The id of the opened connection. | |
13 long connectionId; | |
14 }; | |
15 | |
16 callback OpenCallback = void (OpenInfo openInfo); | |
17 | |
18 callback CloseCallback = void (boolean result); | |
19 | |
20 dictionary ReadInfo { | |
21 // The number of bytes received, or a negative number if an error occurred. | |
22 long bytesRead; | |
23 | |
24 // The data received. Warning: will probably become a blob or other | |
25 // appropriate binary-friendly type. | |
26 // TODO(miket): [instanceOf=ArrayBuffer]object data; | |
27 long[] data; | |
28 }; | |
29 | |
30 callback ReadCallback = void (ReadInfo readInfo); | |
31 | |
32 dictionary WriteInfo { | |
33 // The number of bytes written. | |
34 long bytesWritten; | |
35 }; | |
36 | |
37 callback WriteCallback = void (WriteInfo writeInfo); | |
38 | |
39 interface Functions { | |
40 // Returns names of valid ports on this machine, each of which is likely to | |
41 // be valid to pass as the port argument to open(). The list is regenerated | |
42 // each time this method is called, as port validity is dynamic. | |
43 // | |
44 // |callback| : Called with the list of ports. | |
45 static void getPorts(GetPortsCallback callback); | |
46 | |
47 // Opens a connection to the given serial port. | |
48 // |port| : The name of the serial port to open. | |
49 // |callback| : Called when the connection has been opened. | |
50 static void open(DOMString port, | |
51 OpenCallback callback); | |
52 | |
53 // Closes an open connection. | |
54 // |connectionId| : The id of the opened connection. | |
55 // |callback| : Called when the connection has been closed. | |
56 static void close(long connectionId, | |
57 CloseCallback callback); | |
58 | |
59 // Reads a byte from the given connection. | |
60 // |connectionId| : The id of the connection. | |
61 // |callback| : Called when the byte has been read or the read blocked. | |
62 static void read(long connectionId, | |
63 ReadCallback callback); | |
64 | |
65 // Writes a string to the given connection. | |
66 // |connectionId| : The id of the connection. | |
67 // |data| : The string to write. | |
68 // |callback| : Called when the string has been written. | |
69 // | |
70 // TODO(miket): [instanceOf=ArrayBuffer]object data; | |
71 static void write(long connectionId, | |
72 long[] data, | |
73 WriteCallback callback); | |
74 }; | |
75 | |
76 }; | |
OLD | NEW |