WebAPI/WebSerial: Difference between revisions
No edit summary |
|||
Line 9: | Line 9: | ||
== Suggested API == | == Suggested API == | ||
Serial communication APIs are generally pretty straightforward. Chrome's API is actually quite a good reference API, and there are more provided below. Here is a draft of the suggested API. | Serial communication APIs are generally pretty straightforward. Chrome's API is actually quite a good reference API, and there are more provided below. Here is a (very early) draft of the suggested API. | ||
* getPorts() | * getPorts() | ||
* open() | * open() |
Revision as of 00:45, 11 October 2013
WebSerial is a suggested API that would provide a way for websites to to read and write from a serial device through Javascript.
The idea behind it is to bridge the web and the physical world, and communicate with devices such as Arduinos, 3D printers, and other Serial devices. This is currently only available to desktop apps, or to websites through the use of insecure and outdated technologies (Java Applets, NPAPI plugins).
Chrome already has an implementation available for Chrome Apps, but by being available only for packaged chrome apps, it's moving further away from the idea of the open web.
Security Implications
One needs to consider the security implications of giving access to hardware and connected devices to websites. The solution should not be any different than the geolocation and camera APIs, as in asking the user to give access to each particular website, but it should be investigated nonetheless.
Suggested API
Serial communication APIs are generally pretty straightforward. Chrome's API is actually quite a good reference API, and there are more provided below. Here is a (very early) draft of the suggested API.
- getPorts()
- open()
- close()
- read()
- write()
- flush()
- getControlSignals()
- setControlSignals()
Implementation
The WebSerial API could be implemented using the serial library by wjwwood, also used in ROS. It's a very good, open-source, stable C++ library with a clear documentation, and it's MIT-licensed.