Robots in the browser. Just like node-serialport but for browser apps.
Nodebots are awesome but HTML5 apps have access to a lot of APIs that make sense for robotics like the GamepadAPI, WebRTC Video and Data, Web Speech API, etc. Also you get a nice GUI and its easier to run. I have also made a fork of Johnny-Five to work with Browserify as well by modifying it's dependancy Firmata to use browser-serialport.
A Serial Monitor (like the one in the Arduino IDE) is available in the chrome web store. Source is available in the demo directory.
I made a Johnny Five Demo that uses browser-serialport too. More features coming to that soon though.
You will not be able to add this to your normal website.
This library only works in a Chrome Packaged App as this is the only way to get access to the serial ports API in the browser.
If you want help making your first Chrome App, read the "Create Your First App" tutorial.
There is currently no Firefox extension support but that might come soon if possible.
npm install browser-serialport
The library tries to emulate the node-serialport library with some minor differences. If you find some breaking inconsistencies, please submit an issue. I've tested using Browserify for browser module loading. Please let me know if it doesn't work for others.
var SerialPort = require("browser-serialport").SerialPort;
var sp = new SerialPort(port, {
baudrate: 9600,
buffersize: 1
}, true);
sp.on("open", function() {
console.log("Connection is ready.");
//Send a string
sp.writeString("Hello robot\n");
//You can also send buffers
var buf = new Buffer("Buffers are handy", "utf8");
sp.write(buf);
});
sp.on("error", function(err) {
console.log("Error", err);
});
//You can listen for data as a buffer.
sp.on("data", function(buf) {
console.log("Data", buf);
});
You can also list the available serialports.
var SerialPortLib = require("browser-serialport");
SerialPortLib.list(function(error, portsArray) {
if (!error) {
console.log("Ports available", portsArray);
}
});