php-general Digest 27 Jul 2012 09:55:51 -0000 Issue 7899
Topics (messages 318564 through 318571):
Re: How to write and read serial or parallel port
318564 by: Ian
318565 by: Lester Caine
318566 by: Alex Nikitin
318567 by: Curtis Maurand
318568 by: Curtis Maurand
318569 by: viper
318570 by: Lester Caine
318571 by: Ian
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On 26/07/2012 11:12, viper wrote:
> hi all!
>
> is it possible to write and read data on a COM or LPT port?
> is there any function or class in PHP?
>
> anyone has already done something similar?
>
> thanks,
> viper
>
Hi,
There is a class here:
php-serial
http://code.google.com/p/php-serial/source/browse/trunk/
I will be trying this myself tonight as I need to hook up to an arduino
and retrieve some sensor readings.
Regards
Ian
--
--- End Message ---
--- Begin Message ---
viper wrote:
is it possible to write and read data on a COM or LPT port?
is there any function or class in PHP?
anyone has already done something similar?
Talking in and out of the serial port is not too difficult but is OS dependent,
so what are you wanting to run on? Most of the time you are just copying files
in and out, although one can use the control signals as simple I/O if you only
need a couple of controls.
Parallel port is a minefield on Windows as access is specifically blocked in XP
onwards. You need a modified device driver to bypass the blocks windows puts in.
I've not tried that with PHP as I'm normally accessing the parallel port direct
from other windows programs.
Linux is lot easier, and most of the examples you will find via google are
geared towards that. It works like DOS used to :)
--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
--- End Message ---
--- Begin Message ---
On Thu, Jul 26, 2012 at 6:24 AM, Lester Caine <les...@lsces.co.uk> wrote:
> viper wrote:
>>
>> is it possible to write and read data on a COM or LPT port?
>> is there any function or class in PHP?
>>
>> anyone has already done something similar?
>
>
> Talking in and out of the serial port is not too difficult but is OS
> dependent, so what are you wanting to run on? Most of the time you are just
> copying files in and out, although one can use the control signals as simple
> I/O if you only need a couple of controls.
>
> Parallel port is a minefield on Windows as access is specifically blocked in
> XP onwards. You need a modified device driver to bypass the blocks windows
> puts in. I've not tried that with PHP as I'm normally accessing the parallel
> port direct from other windows programs.
>
> Linux is lot easier, and most of the examples you will find via google are
> geared towards that. It works like DOS used to :)
>
> --
> Lester Caine - G8HFL
> -----------------------------
> Contact - http://lsces.co.uk/wiki/?page=contact
> L.S.Caine Electronic Services - http://lsces.co.uk
> EnquirySolve - http://enquirysolve.com/
> Model Engineers Digital Workshop - http://medw.co.uk
> Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
So for serial for example, you can just open the port up and work with
it like a socket; read/write binary data. As far as parallel port
goes, trickier, you may need to call out to an external program, or
write a module if you need direct interaction in php. Real question is
why in the world would you want to use PHP for this to begin with. I
mean sure you can write your own vfat implementation in PHP, etc, etc,
but it doesn't mean that it's a good idea to do so.
-- Alex
--
The trouble with programmers is that you can never tell what a
programmer is doing until it’s too late. ~Seymour Cray
--- End Message ---
--- Begin Message ---
You read and write to it like any other file. Calls on windows
will be slightly different.
$PRINTERPORT =
fopen("/dev/lpt1", "r+");
$PRINTERPORT =
fopen("lpt1", "r+");
Cheers,
Curtis
viper wrote:
> hi all!
>
> is it possible to write and read data on a COM or LPT port?
> is there any function or class in PHP?
>
> anyone
has already done something similar?
>
> thanks,
>
viper
>
> --
> +
http://vipertechnology.dyndns.org
> () ascii ribbon campaign -
against html e-mail
> /\ www.asciiribbon.org - against
proprietary attachments
> +
http://vipertechnology.dyndns.org/cotnact/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To
unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Lester Caine wrote:
> viper wrote:
>> is it possible to
write and read data on a COM or LPT port?
>> is there any
function or class in PHP?
>>
>> anyone has already
done something similar?
>
> Talking in and out of the
serial port is not too difficult but is OS
> dependent,
>
so what are you wanting to run on? Most of the time you are just
copying
> files
> in and out, although one can use the
control signals as simple I/O if you
> only
> need a
couple of controls.
>
> Parallel port is a minefield on
Windows as access is specifically blocked
> in XP
>
onwards. You need a modified device driver to bypass the blocks windows
> puts in.
> I've not tried that with PHP as I'm normally
accessing the parallel port
> direct
> from other windows
programs.
>
> Linux is lot easier, and most of the
examples you will find via google are
> geared towards that. It
works like DOS used to :)
>
There is an example of a
serial port on php.net in the fopen function documentation.
--C
--- End Message ---
--- Begin Message ---
many thanks!
i'll try all your solutions to find the best one!
On Thu, Jul 26, 2012 at 2:37 PM, Alex Nikitin <niks...@gmail.com> wrote:
> Real question is
> why in the world would you want to use PHP for this to begin with. I
> mean sure you can write your own vfat implementation in PHP, etc, etc,
> but it doesn't mean that it's a good idea to do so.
i know i can write something in c or c++ then use shell_exec, but
this's just an experiment to test PHP vs COM/LPT
On Thu, Jul 26, 2012 at 1:24 PM, Lester Caine <les...@lsces.co.uk> wrote:
> Talking in and out of the serial port is not too difficult but is OS
> dependent, so what are you wanting to run on?
i'll test both win and linux with a sort of xPlataform script :)
regards,
viper
--
+ http://vipertechnology.dyndns.org
() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - against proprietary attachments
+ http://vipertechnology.dyndns.org/cotnact/
--- End Message ---
--- Begin Message ---
Alex Nikitin wrote:
So for serial for example, you can just open the port up and work with
it like a socket; read/write binary data. As far as parallel port
goes, trickier, you may need to call out to an external program, or
write a module if you need direct interaction in php. Real question is
why in the world would you want to use PHP for this to begin with. I
mean sure you can write your own vfat implementation in PHP, etc, etc,
but it doesn't mean that it's a good idea to do so.
Well I use the parallel port to switch over channels on the PA system and
control other things such as camera selection. While the PHP web pages have
access to do it, they send a message to an old windows application and that
talks to the parallel port. It would be nice to eliminate the messaging on
smaller setups, along with the windows box, but it's worked for 15+ years ...
I did simply assume that the question was one of writing data in terms of
switching pins on and off rather than streaming files over the link :)
--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
--- End Message ---
--- Begin Message ---
On 26/07/2012 13:37, Alex Nikitin wrote:
<snip>
> Real question is
> why in the world would you want to use PHP for this to begin with.
<snip>
Hi,
I cannot speak for the OP, but personally I am doing this so I can hook
up to a web application and re-use existing code.
Regards
Ian
--
--- End Message ---