Controlling Serial Port using Web Application

6

I need to communicate my system with the serial port of the Client computer, the detail is that with PHP I can use fopen , but I do not want to access the server's serial port, but the client's port.

I thought about using a plugin, either in Java or in Flash, someone has an idea how I can make this communication.

NOTE: The communication will be with a fiscal printer that works on the serial port.

    
asked by anonymous 14.11.2014 / 12:05

2 answers

4

I've had to do this kind of work in several applications.

The solutions found were to use Java applets or install a small service on the client machine that opens a port and responds to HTTP requests, so we could make Ajax requests using JavaScript to this port on localhost. This service can be done in a language that communicates directly with the serial port of the client machine.

I've seen some applications that use ActiveX, but were restricted to Internet Explorer.

    
14.11.2014 / 15:47
2

In addition to the excellent solution mentioned by the colleague, using Java Applet, only to include: Google Chrome provides API to communicate with the Serial Port.

var writeSerial=function(str) {
  chrome.serial.send(connectionId, convertStringToArrayBuffer(str), onSend);
}
// Convert string to ArrayBuffer
var convertStringToArrayBuffer=function(str) {
  var buf=new ArrayBuffer(str.length);
  var bufView=new Uint8Array(buf);
  for (var i=0; i<str.length; i++) {
    bufView[i]=str.charCodeAt(i);
  }
  return buf;
}

link

Source: link

    
14.11.2014 / 19:47