Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serial communication from JavaScript?

Is it possible to communicate over a machine's serial port through JavaScript?

I have to write a short program that sends data to a microcontroller over the serial port that has a GUI and is cross-platform compatible, and I really don't want to use Java's Swing.

like image 857
Nick Heiner Avatar asked Apr 12 '11 20:04

Nick Heiner


2 Answers

JavaScript itself doesn't have any built in functionality to allow you to access the serial port. However, various JavaScript engines (v8, rhino, etc) allow you to write your own custom native objects.

You might want to check out node.js, which is a JavaScript library for v8 that's focused on writing server-side code (rather than web browser client code). It seems that someone's already written a serialport package for that:

https://github.com/voodootikigod/node-serialport

like image 175
Jason LeBrun Avatar answered Sep 18 '22 05:09

Jason LeBrun


This is an old question, but in case this helps anyone else, Chrome Apps have access to a serial API - http://developer.chrome.com/apps/serial.html - which might help.

It's Chrome specific (obviously..), but Chrome is available cross-platform so might answer the question.

like image 44
Mark Avatar answered Sep 21 '22 05:09

Mark