View Full Version : can i read raw data from a USB port (weight scale)

03-12-2010, 08:27 PM
hi peoples,

i'm looking for a small commandline app that is able to read data from a specified USB port.

trying to integrate a USB-connected scale to an order-processing webapp.

i'd try to do it directly through PHP or extension if i could have it access windows usb/hid drivers and read raw data from USB ports, but it doesnt look like that's possible. the win32api extension was dropped in 5.1 and its replacement (Foreign Function Interface) is still in alpha with no dev or compatibility with anything current.

i could also try converting it into a virtual com port, but few devices support that type of data transfer conversion.


03-12-2010, 08:52 PM
Are you running your own server with Apache/ PHP installed?

03-12-2010, 10:15 PM
yeah, i will run a local http server on the shipping computer just to be able to query from my webapp. as small a footprint as possible. it'll just run an ajax request to a script that needs to retrieve the reading on the scale.

03-12-2010, 11:30 PM
I think your best bet is to get a hold of a USB -> Javascript driver.
With Javascripting, you can do certain things to the local computer,
as Javascripting runs on the PC itself. You normally cannot access
any disk drives or other hardware. But, with a driver, you could access
activity on a USB port.

Because Javascripting can be embedded on your web page (PHP script),
that would be an easy way to read the buffer on the USB port (your scale).

Not sure which application or driver you might need, but this is a place to start:

Tell me more about the scale itself.
I'm wondering what the scale outputs on the USB port.
Maybe it's smart enough to be polled using something like these?


03-12-2010, 11:45 PM
ummm, javascript has no access to anything outside your browser.

i am aware that you can do this with a java applet, or flash, or silverlight (probably). you can also do it by writing an activex control you install into the browser or mozilla's XPCOM equivalent + a plugin.

but i am interested in doing this through php or php + commandline exe that can get the job done.

03-13-2010, 08:09 PM
What brand/model is the scale?

03-15-2010, 02:55 AM
not sure yet, have not checked

03-15-2010, 04:36 AM
If a scale, temperature controller, motor drive, any industrial electronic equipment
has a USB connection, they most likely also have some software ... probably with a
driver. For software connection to Visual BASIC, C++, Java, etc.

As soon as you tell me what the brand/model is the scale is, I'm going to look it up.
If they do provide software, that pretty much will answer your question.