Php Serial Port Windows

Active9 months ago
  1. Php Serial Port Communication
  2. Php Serial Port Windows 7
  3. Php Serial Port Windows Server
  4. Php Serial Port
  5. Php Fopen Com Port Windows
  6. Php Access Serial Port Windows

PHP Serial I somehow got hold of a « Citizen C2202-PD » point-of-sale display, and I wanted to play around with it. I also managed to get the documentation of it, and created a convenience class to access the serial port though the Linux file. Read serial port data using Perl is very easy compare to PHP in Windows OS. The PHP serial port reading has some complication in Windows Os. In Linux serial port reading is very simple using PHP, but on Windows it makes more difficult that is why I choose Perl. Unlike Flash or JavaScript, PHP is not sandboxed and might therefore look like an acceptable choice when trying to communicate over RS-232 (serial port).

  • Gorilla PHPMake SerialPort. The PHP extension for communicate other device via serial-port(COM). This module is able to run on POSIX system and Windows.
  • Serial port access in PHP with Windows (XP and higher). Is not as easy as it should be. Each solution has its limitations. Here are some ideas.
  • How to read serial port through PHP on windows? No free libs are avialble to read serial port through PHP on windows. XOJO does the trick but is very costly affari.
  • Read serial port with PHP is so simple in Linux machine for windows will write another article soon. Just download the read serial port with php script just below. And extract it to your /var/www/html/ folder.

I am looking for a way to communicate with RS232 serial COM port on windows. I have found 2 solutions on the net, one which is not totally free (introduces deliberate delays on the function) and another with limited capability on Windows. The latter can only write to a COM port on Windows, not read.

I can't look at the code of the first solution since it is compiled into a .dll (makes sense, otherwise people can just edit the delay and not purchase it..) and the second one seems only to use fopen() to open the port and later fwrite() to it for writing, just like one would do to a stream. But apparently freading it returns nothing.

I know it's possible as the first solution did it, although it does require Apache to use php-cgi module instead of php5module.

Any ideas?

dsolimano
7,6473 gold badges41 silver badges57 bronze badges
syazsyaz
1,3046 gold badges29 silver badges43 bronze badges

7 Answers

Every solution above is either inefficient or too much work.

You can just use the PHP-DIO library (dio_fcntl, dio_open, dio_read, dio_write, dio_seek, ..). It's also in the PHP manual's entry for DIO:

Download the latest driver, firmware, and software for your HP LaserJet P2014 Printer.This is HP's official website to download drivers free of cost for your HP Computing and Printing products for Windows and Mac operating system. Download HP LaserJet P2014 Printer Driver For Windows 7,8,10 32 bit/64 bit ncluding USB Driver, Scanner Software, download Now Free, any desktop, laptop. HP LaserJet P2014 driver download link & installation instruction for windows xp, vista, 7, 8, 8.1, 2003, 2008 - 32bit / 64bit, Computer, laptop, MAC, PC. Hp 2014 printer driver. HP LaserJet P2014 driver is a software to control HP LaserJet P2014 printer on a PC. HP LaserJet P2014 driver is available for free download on this website page. HP LaserJet P2014 is a fast mono laser printing machine that comes as a great printing companion for. HP LaserJet P2014 Driver: HP LaserJet P2014 Driver is a hostbased driver.It offers basic print for your HP printer. If a prior version software is currently installed, it.

This PECL package isn't available by default. To get it for Windows if you have PHP 5.2.x greater than 5.2.6, you can download it as part of a ZIP:

Both of these links were found in http://www.deveblog.com/index.php/download-pecl-extensions-for-windows/

Here is the build from Linux, just get it and do the phpize/configure/make/make install thing.

I don't know whether it should be used in an Apache session, but go for it.

user633183
77.9k22 gold badges152 silver badges192 bronze badges
Dustin OpreaDustin Oprea
5,3336 gold badges46 silver badges77 bronze badges

The easiest way to tackle this would be to write a program in another language (such as C++) and then execute it from your php script with system(). Doing Comm I/O in C++ is trivial.

This assumes you have enough access to the server to configure it to allow the executable to be run by php, etc.

SoapBoxSoapBox
18.2k3 gold badges41 silver badges82 bronze badges

You need to set up the com port using a DOS-like command.

For example, the following line executes the command through php:

To display the results you can use:

Port

Create the resource id:

Write to port:

Read from port:

Maybe someone can help me with the fgets problem. It stacks there for exactly one minute if TO=on, or stacks there forever if TO=off. It seems to be a 'MODE COM' option so maybe a DOS expert can help.

Php Serial Port Communication

Perhaps instead of fgets, one should use fgetc, since fgets capture through to the newline, while fgetc captures a single character. If a new line isn't encountered, it may block until there is one or until the buffer is flushed. The one minute delay may be windows flushing its buffer on an interval.

David Refoua
1,9851 gold badge23 silver badges39 bronze badges
Giorgos Pap

Another possible way would be to use the Win32 API through something like w32api_register_function() or ffi and then use serial communications calls to get it to work under Windows.

lpfavreaulpfavreau
8,5783 gold badges26 silver badges35 bronze badges

I had the same problem and already considered writing my own php extension when I came across this solution which is popular with Arduino developers - 'serproxy' (found it at many places, ie. http://www.lspace.nildram.co.uk/freeware.html ) sets up a tcp stack to/from the serial ports and allowed me to use the php socket functions to communicate with it.

MichaelMichael

Another option is to use an object via ActiveX on windows. There are several, mostly commercial serial objects for COM on windows. You can also expose a .Net based object and register it for COM use as well. Of course, this does presume you have control on the server to register a COM control, as you would need a serial interface.

Php Serial Port Windows 7

Another issue is resource contention if this is for use via the Web. If this is for a serial printer, for instance, then a print queue manager would be your best option over direct communication.

Php Serial Port Windows Server

Tracker1Tracker1

Php Serial Port

14.7k9 gold badges68 silver badges99 bronze badges

Php Fopen Com Port Windows

If you want to deal with sms using com port then here is the most famous php serial communication class by Rémy Sanchez with google sample code. Here is a thread which includes that topic.

Community

Php Access Serial Port Windows

adiadi
10.1k4 gold badges20 silver badges35 bronze badges

Not the answer you're looking for? Browse other questions tagged phpserial-portcommunication or ask your own question.