jUART, Cross platform browser plugin for serial port communication from JavaScript
![Gitter](https://badges.gitter.im/Join Chat.svg)
Digital Object Identifiers (DOI):
Browsers: Chrome, Firefox, Safari, IE(IE version is not released yet)
OS: Windows, Linux and Mac
Copy the /bin/Windows/npjUART.dll into your browser's plugin directory.
Take FireFox for example:
Copy /bin/Windows/npjUART.dll
to C:\Program Files (x86)\Mozilla Firefox\plugins
For Windows 8, you need to register the DLL first. You can copy the DLL under SYSTEM32(or SYSWOW for 64 bit systems). After that there's no need to copy it to browser's folders.
Copy the ./bin/Linux/npjUART.so into your browser's plugin directory.
Take FireFox for example:
sudo cp npjUART.so ~/.mozilla/plugins/
Mac version is not released yet, I don't have a Mac to build and test the project. You need to build it yourself. Sorry :-(
var ser = plugin().Serial;
Get a Serial object
ser.open("COMA");
Open a port
ser.set_option(baud, parity, csize, flow, stop);
Set port options
ser.recv_callback(recv);
Bind callback function for recieve data.
function recv(bytes, size)
ser.send(char);
Send a byte to serial port
Here is an echo test example, which is contained in the /example directory.
<html>
<head>
<title>test page for object fbcontrol</title>
</head>
<script type="text/javascript">
var ser;
function plugin0()
{
return document.getElementById('plugin0');
}
plugin = plugin0;
function recv(bytes, size)
{
for(var i=0;i<size;++i)
{
ser.send(bytes[i]);
}
}
function pluginLoaded()
{
ser = plugin().Serial;// Get a Serial object
ser.open("COMA");// Open a port
ser.set_option(115200,0,8,0,0);// Set port options
ser.recv_callback(recv); // Callback function for recieve data
}
function pluginValid()
{
if(plugin().valid){
alert(plugin().echo("This plugin seems to be working!"));
} else {
alert("Plugin is not working :(");
}
}
</script>
<body onload="load()">
<object id="plugin0" type="application/x-juart" width="0" height="0" >
<param name="onload" value="pluginLoaded" />
</object>
<h1>jUART Serial Port Echo Test</h1><br/>
This test will echo the data you sent through serial port.
</body>
</html>
python fbgen.py
in firebreath-dev, please set "Plugin Name" to jUARTgit clone git@github.com:billhsu/jUART.git
prep2008.cmd
(or prep2005.cmd
/ prep2010.cmd
if you have VS2005/2010) Linux: ./prepmake.sh
Mac: ./prepmac.sh
cd build/
then make
https://www.gnu.org/licenses/lgpl-2.1.html
Bill Hsu