[PHP] How to write and read serial or parallel port
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
Re: [PHP] How to write and read serial or parallel port
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
Re: [PHP] How to write and read serial or parallel port
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to write and read serial or parallel port
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
Re: [PHP] How to write and read serial or parallel port
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
Re: [PHP] How to write and read serial or parallel port
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/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to write and read serial or parallel port
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php