0

I need to make a web app send a signal to a LPT port. The hardware is designed to listen for a 0V or 5V TTL signal.

Do you know any activeX, PHP class, JS, or even a piece of intermediary software, or anything which could allow me to "plug" this LPT feature to a PHP/JS application used locally in a Windows environment?

Yako
  • 3,405
  • 9
  • 41
  • 71

2 Answers2

0

i never worked with this function but php has 1 that you can probably use http://nl1.php.net/Exec

edit this is an example that i found on the internet

<?php
$cmd = "start /D C:\OpenSA\Apache /B Apache.exe -D SSL";
exec($cmd,$output,$rv);
?>
Robert Stevens
  • 488
  • 1
  • 7
  • 21
  • I found out that running `echo 1 > lpt1` from the command prompt does make the trick. `exec()`sounds promising, but I didn't get how to use it to run the `echo 1`... – Yako Oct 24 '13 at 07:50
  • this looks prommesing example: for more examples look here http://nl1.php.net/manual/en/function.exec.php – Robert Stevens Oct 24 '13 at 10:48
0

We have a browser based ticketing (as in boxoffice tickets for cinemas) system, that uses a serial port to send commands directly to a ticket printer. Here is, how it works:

  • a tiny application, for historical reasons calle "the agent" is started, and reads a config file
  • this config file only contains a workstation ID and the path to the preferred browser executable
  • The agent asks for username and password, and authenticates to the server via plain HTTP (salted hashes, nothing secret going over the wire), sending also the workstation ID from the config file
  • If authentication is granted, the server sends a configuration (e.g. "port=com1", "baud=19200", ...), a session ID and a one-time URL
  • The agent starts the browser, pointing it to this one-time URL
  • The agent then goes into a long-poll loop via HTTP, thereby relaying commands from the server to the serial port, using the settings it got before (and relaying back any input from the printer, such as "paper out")

Basically, this means, that the same session is used by two clients at once: The browser and the agent - a very easy way to share information. In fact it means, the relayed serial port and the browser share a session.

I am sure, this can easily be adapted for your use.

For historical reasons, the agent is written in TCL/TK, as at that time this was the easiest way to get cross-platform HTTP and serial port handling on Windows (9x, NT and CE families), OSX and Linux. It also could most easily be packaged into a self-containing .exe (or the respective .app, ELF executable, ...)

Today, I would use C# for the agent, as Mono is now more than good enough to give you Mac, Linux, Android and iOS

Eugen Rieck
  • 64,175
  • 10
  • 70
  • 92
  • This seems to be an interesting path. However, I don't have that much skills, and I would rather look for a simpler PHP-only solution... – Yako Oct 24 '13 at 07:46
  • There is none: A PHP script on the server can control nothing more, than what is delivered to the client's browser. And the client's browser has no built-in way to communicate directly with the LPT hardware (while the agent has - that is the point) – Eugen Rieck Oct 24 '13 at 13:46