{"action":"created","issue":{"url":"https://api.github.com/repos/WICG/serial/issues/18","repository_url":"https://api.github.com/repos/WICG/serial","labels_url":"https://api.github.com/repos/WICG/serial/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/WICG/serial/issues/18/comments","events_url":"https://api.github.com/repos/WICG/serial/issues/18/events","html_url":"https://github.com/WICG/serial/issues/18","id":22105950,"node_id":"MDU6SXNzdWUyMjEwNTk1MA==","number":18,"title":"Need prototype implementation","user":{"login":"marcoscaceres","id":870154,"node_id":"MDQ6VXNlcjg3MDE1NA==","avatar_url":"https://avatars1.githubusercontent.com/u/870154?v=4","gravatar_id":"","url":"https://api.github.com/users/marcoscaceres","html_url":"https://github.com/marcoscaceres","followers_url":"https://api.github.com/users/marcoscaceres/followers","following_url":"https://api.github.com/users/marcoscaceres/following{/other_user}","gists_url":"https://api.github.com/users/marcoscaceres/gists{/gist_id}","starred_url":"https://api.github.com/users/marcoscaceres/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcoscaceres/subscriptions","organizations_url":"https://api.github.com/users/marcoscaceres/orgs","repos_url":"https://api.github.com/users/marcoscaceres/repos","events_url":"https://api.github.com/users/marcoscaceres/events{/privacy}","received_events_url":"https://api.github.com/users/marcoscaceres/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2013-11-05T08:41:02Z","updated_at":"2018-10-26T08:58:40Z","closed_at":null,"author_association":"MEMBER","body":"Would be great to have a prototype implementation. \n\nThe setup would be something like:\n- [ ] Arduino: connected over firmata to Node.js.\n- [ ] Local server: Node + socket.io or similar.\n- [ ] Browser: web socket connection to server plus some yet-to-be determined stream library (that we can wrap to provide the same functionality as the [WHATWG Streams proposal](https://github.com/whatwg/streams)). We can then wrap everything up and pretend it’s running locally. \n\nIt should be fast enough to demonstrate the API working and provide basic read/write operations.\n"},"comment":{"url":"https://api.github.com/repos/WICG/serial/issues/comments/433338560","html_url":"https://github.com/WICG/serial/issues/18#issuecomment-433338560","issue_url":"https://api.github.com/repos/WICG/serial/issues/18","id":433338560,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMzMzODU2MA==","user":{"login":"reconbot","id":25966,"node_id":"MDQ6VXNlcjI1OTY2","avatar_url":"https://avatars2.githubusercontent.com/u/25966?v=4","gravatar_id":"","url":"https://api.github.com/users/reconbot","html_url":"https://github.com/reconbot","followers_url":"https://api.github.com/users/reconbot/followers","following_url":"https://api.github.com/users/reconbot/following{/other_user}","gists_url":"https://api.github.com/users/reconbot/gists{/gist_id}","starred_url":"https://api.github.com/users/reconbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reconbot/subscriptions","organizations_url":"https://api.github.com/users/reconbot/orgs","repos_url":"https://api.github.com/users/reconbot/repos","events_url":"https://api.github.com/users/reconbot/events{/privacy}","received_events_url":"https://api.github.com/users/reconbot/received_events","type":"User","site_admin":false},"created_at":"2018-10-26T08:58:40Z","updated_at":"2018-10-26T08:58:40Z","author_association":"CONTRIBUTOR","body":"I'm working on this here https://github.com/node-serialport/node-serialport/issues/1679 I'm hoping the next cut of serialport's binding layer can be a good candidate for the web serial api. The major difference is streams, I don't use them. You can implement any kind of stream or async iterator on top of binding layer but wanted to avoid any particular system because;\r\n\r\n1) For many years node-serialport has been tied to node streams and I find them difficult to reason about\r\n2) pull-streams/databags, whatwg streams, async iterators, highlandjs, observables, etc - we have many competing ways to do data over time, some of them I love, some of them I've never used, everyone has their favorite. There's no need to pick one.\r\n\r\nI went with a composable core a year or two ago. Now I'm rewriting it to reflect the discussions we had here.\r\n\r\nIt's bound to change a little as I bring the 3 major platforms inline with the abstract, but I quite like where it landed. I'm looking for feedback on the api design, particular around the read behavior. I used to throw a disconnected error that you were supposed to swallow, but instead now allow for resolving 0 bytes, as a pending read during close doesn't need to error. (Writes on the other hand should error as they're intentional things that are failing.) \r\n\r\nNaming is also hard.\r\n\r\nAnyway, let me know what you think.\r\nhttps://github.com/node-serialport/node-serialport/issues/1679#issuecomment-433332647\r\n\r\n```ts\r\nexport interface PortInfo {\r\n    readonly path: string;\r\n    readonly locationId?: string;\r\n    readonly manufacturer?: string;\r\n    readonly pnpId?: string;\r\n    readonly productId?: string;\r\n    readonly serialNumber?: string;\r\n    readonly vendorId?: string;\r\n}\r\nexport interface LocalState {\r\n    readonly baudRate: number;\r\n    readonly brk: boolean;\r\n    readonly dataBits: 5 | 6 | 7 | 8;\r\n    readonly dtr: boolean;\r\n    readonly lock: boolean;\r\n    readonly parity: 'none' | 'even' | 'mark' | 'odd' | 'space';\r\n    readonly rts: boolean;\r\n    readonly rtscts: boolean;\r\n    readonly stopBits: 1 | 1.5 | 2;\r\n}\r\n\r\nexport interface ConstructorOptions extends PortInfo, LocalState {\r\n    readonly descriptor: number;\r\n}\r\nexport interface OpenOptions extends LocalState {\r\n    readonly path: string;\r\n}\r\n\r\nexport interface RemoteState {\r\n    readonly cts: boolean;\r\n    readonly dcd: boolean;\r\n    readonly dsr: boolean;\r\n}\r\n/**\r\n * You never have to use `Binding` objects directly. SerialPort uses them to access the underlying hardware.\r\n */\r\nexport declare class AbstractBinding implements PortInfo, LocalState {\r\n    locationId?: string;\r\n    manufacturer?: string;\r\n    path: string;\r\n    pnpId?: string;\r\n    productId?: string;\r\n    serialNumber?: string;\r\n    vendorId?: string;\r\n    baudRate: number;\r\n    brk: boolean;\r\n    dataBits: 5 | 6 | 7 | 8;\r\n    dtr: boolean;\r\n    lock: boolean;\r\n    parity: 'none' | 'even' | 'mark' | 'odd' | 'space';\r\n    rts: boolean;\r\n    rtscts: boolean;\r\n    stopBits: 1 | 1.5 | 2;\r\n    descriptor: number;\r\n    hasClosed: boolean;\r\n    /**\r\n     * Retrieves a list of available serial ports with metadata. The `comName` must be guaranteed, and all other fields should be undefined if unavailable. The `path` is either the path or an identifier (eg `COM1`) used to open the serialport.\r\n     */\r\n    static list(): Promise<ReadonlyArray<PortInfo>>;\r\n    /**\r\n     * Opens a connection to the serial port referenced by the path.\r\n     */\r\n    static open<T>(this: T, options: OpenOptions): Promise<T>;\r\n    constructor(opt: ConstructorOptions);\r\n    /**\r\n     * Closes an open connection\r\n     */\r\n    close(): Promise<void>;\r\n    /**\r\n     * Drain waits until all output data is transmitted to the serial port. An in progress write should be completed before this returns.\r\n     */\r\n    drain(): Promise<void>;\r\n    /**\r\n     * Flush (discard) data received but not read, and written but not transmitted.\r\n     */\r\n    flush(): Promise<void>;\r\n    /**\r\n     * Get the remote state flags (CTS, DSR, DCD) on the open port.\r\n     */\r\n    getRemoteState(): Promise<RemoteState>;\r\n    /**\r\n     * Request a number of bytes from the SerialPort. This function is similar to Node's [`fs.read`](http://nodejs.org/api/fs.html#fs_fs_read_fd_buffer_offset_length_position_callback) except it will always read at least one byte while the port is open. In progress reads must resolve with any available data when the port is closed, if there is no data when a port is closed read 0 bytes.\r\n     */\r\n    read(buffer: Buffer, offset: number, length: number): Promise<number>;\r\n    /**\r\n     * Set local state on an open port including updating baudRate and control flags. The state is represented on the object as well as resolved in the promise.\r\n     */\r\n    setLocalState(options: Partial<LocalState>): Promise<LocalState>;\r\n    /**\r\n     * Write bytes to the SerialPort. Only call when there is no pending write operation. In progress writes must error when the port is closed.\r\n     */\r\n    write(buffer: Buffer): Promise<void>;\r\n}\r\n```"}}
{"actor":{"display_login":"reconbot"}}