Subject: Help wanted, Writing to the LPT Port.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Actually, php-db is a list for (wait for it!) PHP used with DB (databases) so you've got the wrong list, you meant to send it to PHP-general.

Anyway to answer your question, you can send an 8 bit printer port a series of ASCII characters (0-255) which correspond to your values, so say chr(35) == 00100011 and chr(140) = 10011000. You can also use hex codes, which is easier to "see" the bit values. To do this, add 0x before the hex digits, for example 0xFF = 11111111, 0x3A = 00111010. Read a tutorial on "hexadecimal notation" if you are unsure how hex digits map to binary and decimal.

See http://www.phpdig.net/ref/rn58re1156.html, http://en.wikipedia.org/wiki/Hexadecimal

So to do this in Linux say you would use the system's lpr queue to send characters to the printer port. And in windows you'd send it to the lpt1 port or other printer port (select one of the $command depending on OS) :

<?php
$character=chr(0xBB); // Equivalent to binary 10111011
$command="echo ".$character." | lpr -Pepson1"; // Send command to Unix OS lpr command
$command="type ".$character." > lpt1 "; // or ... Send command to windows LPT1 port
exec($command); // Send the command string directly to the operating system
?>



HTH Cheers - Neil



At 21:44 21/04/2005 +0000, you wrote:
Message-ID: <20050421073855.88279.qmail@xxxxxxxxxxxxx>
To: php-db@xxxxxxxxxxxxx
Reply-To: "JB" <helpdesk1@xxxxxxxx>
From: "JB" <helpdesk1@xxxxxxxx>
Date: Thu, 21 Apr 2005 09:38:50 +0200
Subject: Help wanted, Writing to the LPT Port.

Hello,

I want to write a switch board in PHP. So that it is possible to write data
1 or 0 to the D0 - D7. So that It is possible to switch a relais wich I
connected to the LPT port of my webserver.

I could not find any examples or documentation on this theme.

Could somebody help me with this problem?

P.S. I am sure that it is possible because it is also possible to print with
PHP. So why should we not be able to write a specific value to the LPT port.
I saw 1 example with a serial port. So.........

Kind regards,

J Bosch


========================================================
CaptionKit http://www.captionkit.com : Production tools
for accessible subtitled internet media, transcripts
and searchable video. Supports Real Player, Quicktime
and Windows Media Player.

VideoChat with friends online, get Freshly Toasted every
day at http://www.fresh-toast.net : NetMeeting solutions
for a connected world.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux