Re: PHP to read a COM port??

From: Date: Mon, 06 Nov 2000 18:02:50 +0000
Subject: Re: PHP to read a COM port??
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-23934@lists.php.net to get a copy of this message
Hi Perry.. Thanks for your mail, for you and everyone else just a small word how everything works with a barcode scanner: Basically this barcode scanner (and 99% of all other serial barcode scanners) work like this: To setup the barcode scanner you use the manual which consists of special barcodes with which you can change the parameters in the barcode (scanning speed/type of barcodes etc..) by scanning these barcodes these parameters are changed.. When setup the way you want you scan the barcode and this data is send to the computer via the serial cable.. You can view these results via a standard modem program like minicom in unix or hyperteminal in windows.. (Most scanners connect to the computer at a speed of 9600 baud) If you would be able to send data to the modem, the respones that come back (O.K, NO CARRIER. NO DIALTONE) basically are the same data as which the scanners sends back.. (Only he sends the contents of the barcode) So if you would be able to send commands to a modem and read the results back via PHP, you would have enough code to read the barcode.. I first thought about using a old windows machine with barcode software which writes all scanned barcodes to a file on a directory on my linux machine which is shared with Samba.. :-) And then I run PHP every few minutes to look if there are new files to be processed.. :-) I am not that experienced with unix, but I always hear that do everything with file pointers.. This is how I thought of the idea to use the PHP fopen command to directly read from the barcode scanner via /dev/ttyS0.. What I have already succeeded in is to use the PDF functions in PHP to generate a PDF file with embedded barcodes.. This PDF contains a order made through internet. These are printed out and should then be scanned with the barcode reader so the computer knows they have been processed.. :-) Here comes my problem on getting the data from the scanner... If someone has already done something like this in PHP I would like to hear it very much.. I do see that PHP has got some functions for windows NT to communicate with the serial ports.. These are not available in PHP so I will probably be right by thinking of using fopen on /dev/ttySxx.. Can anybody help..? Bye Bye David PS: Perry, thanks for replying, the easiest way to try some stuff would probably be by using a modem.. I only have no idea how you can write to the modem. > This is quite interesting. I wish I could do some testing myself, but I > don't have a barcode scanner..What other serial port devices do you think we > could mess with ? > > Regards, > > Perry Loh > Lead Developer, KlikInTouch.com > perryloh@klikintouch.com > - Just about Anywhere you go - > I have a serial barcode scanner which I would like to use with PHP to enter > Barcode data and store this with PHP > in a MySQL database.. > > This barcode scanner is serial and I would like to know if there is a > possibility to read the serial port with PHP.? > > I found the following postings on internet: > > >I recently received some barcode scanners that plug directly into a serial > port, such as tty/b01. I read that I can >disable getty, make a node and > open the tty as an input file, but I don't know how to identify the > file/pointer/??? to >open the file. Can anyone help with a simple C language > program? thanks > > And this is the answer > >I got this one from a consultant...when reading directly from a port for a > barcode scanner/decoder, simply fopen >the device name, such as ttyb16, but > remember to fopen in the "rb" mode. "b" denotes binary. Use stty to set the > >speed and parameters of the port. > > Is something like this possible with PHP..? > My question, if I setup the above (with fopen(/dev/tty01) ??) what should I > do to let PHP stop reading the Serial port and continue after a barcode is > scanned.? (If I don't do anything he will probably just wait for more data) > > Barcodes begin with a * character and also end with one.. Is is possible to > do some kind of while loop till I detect the * character for a second time? > > If I anyone has experience on reading a serial port under unix I would > greatly appreciate help. I am used to windows and what I understand is that > you can use file pointers to all kinds of devices under Linux/Unix.. > > Thanks in advance.. > (PS: Please also send a copy to my email when replying) > > David > > > >

« previous php.general (#23934) next »