hi I wondered if I can use PHP to control an external hardware connected with the parallel port or USB port ? any ideas or resources ?
You have to write a program that you can call via system calls. PHP code can't access your hardware directly.
You might want to look into php exec. PHP doesn't allow Direct access to Hardware through the API, you need to call sub-programs to do that.
This is a useful class for serial attatched devices on Linux: PHP Serial
Serial ports are often used to communicate with peripheral devices, such as: modems, POS terminals, special printers, etc..
This class can be used to communicate and configure peripherals connected to a serial port under Linux, simplifying the development of applications that need access serial devices.
As per my comment on Filip Ekberg's answer....maybe.
It depends on your OS and the level of access required - should it be bi-directional? Are you trying to use the control lines for purposes other than flow control? Do you know the details of the communications protocol?
C.
If you can write a program in C++ that communicates with that device, you can create a PHP extension: http://www.devarticles.com/c/a/Cplusplus/Developing-Custom-PHP-Extensions-Part-1/
If you intend to run this on a *NIX system, you may want to look at Plan 9 From User Space. With these libraries, you could write a C program that make your hardware appear as a part of your file system, i.e. you mount it as you would mount a USB drive, for example. Once mounted, you can use PHP's function for manipulating files to control your hardware.
If you don't know what Plan 9 is, this may not be very clear. Let me illustrate by an dummy example : your hardware is an electronic board displaying the number of logged in user via a 7 segment display. You use Plan 9 from user space to write a program that mounts 2 files :
/somewhere/input
/somewhere/output
Writing "42" (as you would do with a text file) to input will make your board display 42. Reading output will for example tell you for how long this number did not change.
This may not be the easiest way to achieve your goal, as learning to use the Plan 9 libraries is not very easy (although people on IRC are very nice and helpful), but it is in my opinion the most elegant way.
With this, you would also be able to control your hardware from any other language, for all languages I know can manipulate files.
Well, it was an LPT port and a binary, both for Lin and Win and small PHP code to call this binary:
Hi! Please check this link, http://www.starlinkindia.com/classic-model.html. we have the same machine. This machines takes the employee attendance records and can keep 65000 records with itself. I have to write a PHP code that can give me access to its file where this data is stored and some other works i want like i want to connect and disconnect this according as i want.
Thanks very much.