Page 1 of 1

Reading USB data

Posted: Mon Jul 18, 2011 4:54 am
by Tiooso
I have a computer (XP) with Apache and php.
Connected to this pc with a USB cable I have a machine that is sending chip numbers and time data into the USB cable. This machine is taking income times for competitions (running, cycling, cross country skiing).
A MySQL database is holding the information about chip numbers, competitors and starting time.
I maintain competitors with web pages and php scripts. Result list shall be made with this system.
I want a script to receive the info from the USB cable and insert the info into a table in my MySQL database.

1. How do I get my php script to receive the info from the USB cable?

Tiooso

Re: Reading USB data

Posted: Mon Jul 18, 2011 5:06 am
by Peter Kelly
I think you would need to look at a windows server IIS web server for what your looking for. I dont believe it can be done by Apache and PHP.

Re: Reading USB data

Posted: Mon Jul 18, 2011 2:06 pm
by McInfo
This serial device class might be useful.

If the data is meant to stream for more than a few seconds, I suggest not using a web server. Instead, write a command-line application.

If the data is stored in files on the device, I suggest simply using filesystem functions like fopen() or file_get_contents().

Re: Reading USB data

Posted: Mon Jul 18, 2011 8:07 pm
by beetree
McInfo wrote:This serial device class might be useful.

If the data is meant to stream for more than a few seconds, I suggest not using a web server. Instead, write a command-line application.

If the data is stored in files on the device, I suggest simply using filesystem functions like fopen() or file_get_contents().
Also, you probably want to consider user-rights. You might not want to have the user that runs the webserver to have access to the USB-port. Hence, set up a different user with access to the USB-port and write a command-line script that this user runs and inserts the data into the MySQL server. Then fetch the data with the PHP-script run by the webserver.