I am trying to display continuous stream of data from a serial port (COM4) on a web page. I tried to use NodeJS and successfully got my output on Command Prompt. But I am unable to figure out how to display it on a web page on localhost. Here is a piece of code I have got with me for displaying it on console.
var sys = require("sys"),
serialPort = require("serialport").SerialPort;
// Create new serialport pointer
var serial = new serialPort("COM4" , { baudrate : 9600 });
// Add data read event listener
serial.on( "data", function( chunk ) {
sys.puts(chunk);
});
serial.on( "error", function( msg ) {
sys.puts("error: " + msg );
});
Please help me with the further steps.
您可以使用websocket或socket.js侦听并发出流数据并将其呈现给客户端。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.