This article explains how to configure PHP in order to send and receive data over a serial port on a unix system or a windows system. Prerequisites PHP installed on your computer. Read Serial Port with PHP Post date: Category: Author: Comments: Tags:,, Read Serial Port with PHP 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. 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. Php Serial Port Communication WindowsNo 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. Tips download lagu hp nokia. Akhir Kata Pasti kamu terkejut bukan? Ternyata cara download lagu di HP android itu sangat mudah, cukup beberapa langkah sederhana. Kembali lagi, ini semua berkat terbaik. 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. Php Fopen Com Port WindowsI 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. Cat /dev/ttyUSB0 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
November 2018
Categories |