Control Serial Port using Web Application

Asked

Viewed 2,325 times

6

I need to communicate my system with the computer serial port Client, the detail is that with PHP I can use the fopen, but I don’t want to access the server’s serial port, but the client’s.

I thought of using a plugin, whether in Java or Flash, anyone has any idea how I can make this communication.

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

  • I don’t understand your question...

  • Interesting question, but work it out better, explaining this part of fopen. Veja [Ask].

  • Relevant (I think): http://www.phpavancado.net/node/398

  • I don’t know if it’s possible, since PHP works on the server side... Maybe with another language like javascript, which works with the client, you can access the peripherals of the client’s computer...

  • Interesting question. But I believe you will not use fopen. You could submit what will be printed as Response, which will be read by the Client Side Plugin and sent to the printer ?

  • https://github.com/Xowap/PHP-Serial

Show 1 more comment

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 the 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.

  • Addendum: The most portable hourly solution is Applets, by accessing native features of the client machine, you will need the Applet to be signed.

  • I like the idea, I will use Applets in java, as I know a lot of Java for desktop is easier for me.

4

In addition to the excellent solution cited by the colleague, using Java Applet, just to mention: Google Chrome offers API to communicate with 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;
}

https://developer.chrome.com/apps/serial

Source: https://stackoverflow.com/a/15926487/194717

Browser other questions tagged

You are not signed in. Login or sign up in order to post.