Hi, We are using your SKGL License class in our C# application and it works great. However, I need to be able to generate keys from my website for our customers. I’d like to port the Genera.
Read serial port with PHP ? yea some time we may face such a requirement, reading serial devices from web browsers. bit complicated right ? Yea, there are few way to accomplish this with the technologies available now.
We all know that browser is Sanbox mode and its restricted to access system hard drives or any serial devices. So How we can read the serial port using PHP (server side script executed with a client browser). Yea that bit crazy. We can check few other options available to do the things.
- Java Applet.
- Active X components.
The above two methods have its own advantages and limitations Active x only support with Windows platform, Java is cross platform so it can be used , there is also requirement like JDK should be installed on the client PC , the applet should be signed and verified. etc.
So if we can do that (install JDK on client PC) so we can install an apache server with PHP on client PC too right ? so we can develop it with PHP itself. no need of struggling with applet signed process.
Yep that is what I’m doing here, my requirement is to read the weigh machine out put on the web browser. so the PC connected to the serial port device. I’m working on linux machine so I can do the serial port reading with PHP itself , In windows there is some issue with reading serial port using PHP , it can’t be achieved quick , have to work a lot, In my case its fine too , bcoz client PC’s are Linux so I’m good to go with PHP.
If you’re using Windows , I will post another article soon with windows serial port reading using PHP and Perl mix.
ok lets check the code in PHP, also my plan to execute the code as follows.
I will put the code in a folder called serialport inside /var/htm/ so I can access it like localhost/serialport/index.php it will return the data , In my web page I can use an Ajax call to the above url and return the result inside text box of my web apps.
There are few things you have to keep in mind In linux the port name usually like ttyUSB0 or ttyS0
first you can connect the device with the system then test the device is working fine or not using the terminal by putting the command.
If the port name is correct it will read and display the values in the terminal. just Ctl + Z to stop that.
Now few thing while working with apache server on Linux machine , the default apache user named www-data should be in dialout group then only it can access the port. So please make sure the user already in the dialout group. else you can add that by using following command.
you can list the current group of the user with following script.
Now the code its more simple than this setup!.
The serial port data will read continuously and out put it with a space between each values so what I did is find the maximum number of time repeated value, that must be the value shown in the device. and output it.
Php Extension Serial Port Number
you can download the entire code as zip file too, in the above code I used a class php serial port that is also available with zip file. This only works with Linux not with windows. you can’t read the data of serial port using above class in windows , windows supports only writing to serial port from PHP directly .
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. It had an index.html file using jQuery to make the ajax call too the PHP file that read the serial port data and return to web page.
If you’re trying this code with remote machine make sure you added this script at top of the section.
Happy reading 🙂 🙂 🙂
Serial Port Monitor is a professional application for RS232/422/485 COM ports monitoring. It monitors, displays, logs and analyzes all serial port activity in a system.
Php Extension Serial Port Diagram
It can effectively be used for monitoring serial data exchange between serial devices and any Windows application, debugging computer connection with peripheral devices using COM port – such as modem, mini-ATS, projector, etc, for solving problems with serial (RS232/422/485) data communication control networks and devices, for software and hardware testing and much more. It can monitor any software/hardware that works with a serial port, intercept and record all serial input/output control codes (IOCTLs), tracking their full details and parameters. Serial Port Monitor supports all COM-port types: standard on-board ports, extension board ports, SERIAL-via-USB adapters.