I have a program that is interacting with hardware via parallel port programming. i had compiled it and using its object file to interact with the hardware (a simple led). when i execute it directly on the shell it serves the purpose of glowing the LED but when i execute it using shell_exec() in php the command is executed but unable to interact with the hardware. i am totally confused.. .
This may be way off, but if you're going to use PHP to do hardware-interfacing, I'd throw some AJAX in there as well.
Basically have your javascript pass keystrokes to the server via an Ajax function. Everytime PHP gets a new request via javascript, it looks up the keystroke in an array of pre-written set of shell_exec()
commands and runs the one for that keystroke.
Have the javascript listen for key presses, and have the array of shell commands directly correlate to each possible keystroke (or combination of strokes, if you can get fancy).
I'd start off with something really simple like dots and dashes, but I bet you can get really cool stuff fast.
If your PHP script is running as different user (e.g. if you run it as Apache module, it may be user apache
), it may not have the same access to HW as when logged in as yourself. Check the permissions needed to interact with the parallel port.
I would set up some kind of socket server on the host that connected to the parallel port and provided a domain socket that PHP could talk with. Its really the only way you are going to deal with streaming I/O over a RESTful protocol.
As Anthony mentioned, a little AJAX would make this rather seamless as far as the user experience went.
This lets you use simple PHP sockets to connect, send, get a response, display it and then wash / rinse / repeat per request. A lot easier than dealing with shell_exec().
i want to display led through lamp server... lamp means linux,apache,my sql&php. plz tell me what is the php programme for led displaying throgh parallel port(db25).. how i control parallel port for led display..