blink-devメーリングリストに「Intent to Implement: Serial API」として「Serial API」の実装に着手する旨の投稿がされている。
この「Serial API」はW3CのWICGで議論がされており、ブラウザからシリアルポートにアクセス可能にする。3DプリンタやArdbinoなど、様々なデバイスと接続できるようになる。
パーミッションの要求については、すでに実装されている「Web Bluetooth」「WebUSB API」とおなじになるようだ。
sample
仕様では、Ardinoからデータを読み込む例が示されている
//Request the list of ports from the user SerialPort.requestPorts().then(ports => { //Pick the first matching port var serial, kind = "Arduino", key = "manufacturer", //find the Arduinos! arduinos = ports.filter(port => port.get(key).search(kind) > -1); if (arduinos.length) { serial = new SerialPort(arduinos[0].path); serial.in.read(readData) } function readData(){ while(let data = yield serial.read()) { console.log(data); } } }) .catch(console.error);