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.

Answers:

Answer

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

Answer

There's a cross platform plugin for serial port communication called jUART.

Answer

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.

Answer

Yes, it's possible using an ActiveX(I did it). You can make an activeX and use JavaScript to invoke it. If you prefer, you can make a .net dll and register it using regasm. Take a look at this link

You also can write an activeX using VB6 and register it. Both works fine. Ps.: if you are using ActiveX, the JavaScript code will run just on IE.

Answer

If you have a DLL library (this includes e.g. most Windows APIs) that allows you to communicate over serial port you can invoke it from Firefox chrome code (or content code with universalxpconnect privileges) by using ctypes.

Answer

What you could do is to use a Java applet that connects to the local computer's Java application that reads the serial port. The applet would then transfer the data to a JavaScript class or something that can hold the information. Then additional JavaScript code can be used to access the data. It's a complicated solution but should work.

Another way is to create a POJO service.

Answer

No.

I'd recommend wx-widgets for the task.

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.