Hello,

I would like to send a specific string of commands to a USB device connected to my computer. Is there a PHP function that allows this?

Thanks,

Choky

Recommended Answers

All 7 Replies

Serial communication has to be done fairly low level using Windows API's.

You can buy a wrapper component called ActiveComport (USB is just a much much faster RS232) here which gives you an interface you can manipulate in scripting languages.

I beleive on Linux it's simpler because everythings a file, so you just read and write your bits to the file that represents your USB port or device, if I find any leads in that direction I'll post them.

Thanks! But if it is possible to access USB devices then any webpage can just control your peripherals and cause a mess, no?
Secondly, can PHP give orders to ActiveComport? and if so, what functions can be used? I would like to use PHP for a new POS (point of sale) software I am developing for my shop. The problem is sending orders to the cash drawer/printer using php.

Serial communication has to be done fairly low level using Windows API's.

You can buy a wrapper component called ActiveComport (USB is just a much much faster RS232) here which gives you an interface you can manipulate in scripting languages.

I beleive on Linux it's simpler because everythings a file, so you just read and write your bits to the file that represents your USB port or device, if I find any leads in that direction I'll post them.

Any webpage cannot control your USB port, PHP is not just for web pages although that's where it is most commonly used. ActiveComport is a component that you will have to register with the windows registry on the machine on which you are executing your PHP script. I'm afraid I am not an authority on PHP as I have used it very little, and the site I gave does not mention PHP specifically. But if VBScript can use it I would be very surprised if PHP couldn't.

Ooh nice, I could find some uses for that, thinking send/receive SMS text messages thru PDA phone.

Choky,
I take it your cash drawer has a USB interface, does it not have any software with it, perhaps the vendor or manufacturer have a development KIT ?

This is the printer I will use: http://www.orient-technologies.com/products/pdf/BTP-2002CP.pdf .
The cash drawer connects directly to the printer so when it gets a command to print, it tells the drawer to open. So really what I need is just communication with the printer.


Ooh nice, I could find some uses for that, thinking send/receive SMS text messages thru PDA phone.

Choky,
I take it your cash drawer has a USB interface, does it not have any software with it, perhaps the vendor or manufacturer have a development KIT ?

Sorry, I'm really lost here.

Why do you want to mess about with low level stuff like communicating with a printer?

I take it this PHP POS software is going to run on a pc, on which the printer is installed as a device right?

so you just want to create a receipt document from your sales data and just put it in the print queue right ? let your OS worry about talking to the printer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.