Php Serial Port Communication Linux Wine

  1. Linux Serial Port Software
  2. Php Serial Port Communication
  3. Linux Serial Port Example
  4. Open Serial Port Linux

If you use Linux and rely on a Windows only serial port application, besides virtualization, you could use Wine. If you configure it, most Windows applications will be able to detect and use the serial ports. Php serial communication in linux. I have installed xampp in fedora 13.I am trying to communicate with microcontroller through serial port using php serial class.

This is a step-by-step guide to using the serial port from a program running under Linux. The serial communication does not group transmitted data into packets. Arduino PHP Serial Linux: Communicate with a Arduino board via serial port: Search. This class can communicate with a Arduino board via serial port. This is an helper class for php-Arduino communications on Linux. After a week of googling and tests, i build this Class to communicate from php running on Linux (master) to an Arduino.

PHP Serial was written at a time where I did not know any other language thanPHP and I started to get seriously bored with its abilities.

This class can be used to communicate with a serial port under Linux or Windows. It takes the path (like '/dev/ttyS0' for linux or 'COM1' for windows) of serial device and checks whether it is valid before opening a connection to it. Once the connection is opened, it can send data to the serial port, and read answers (reading is only implemented for Linux). Hi, I am trying to use a Wine application that use a serial cable to connect with a device to be programmed. Until now I had no success and I need yor help, please.

I somehow got hold of a « Citizen C2202-PD » point-of-sale display, and I wantedto play around with it. I also managed to get the documentation of it, andcreated a convenience class to access the serial port though the Linux file.

Afterwards, I posted it to PHP Classes,and this probably is what brought it any visibility.

Example

State of the project

Interestingly enough, this piece of code that is widely untested has created alot if interest ever since it was created, and especially nowadays witheverybody toying around with Arduinos and Raspberry Pis. I receive about 1 emailevery month asking for help with the code or sending patches/suggestions.

I think that it is time for me to remove the dust off this project and to giveit a full visibility on modern tools, aka GitHub.

Bugs

There is lots of bugs. I know there is. I just don't know which are they.

Platform support

  • Linux: the initially supported platform, the one I used. Probably the lessbuggy one.
  • MacOS: although I never tried it on MacOS, it is similar to Linux and somepatches were submitted to me, so I guess it is OK
  • Windows: it seems to be working for some people, not working for someothers. Theoretically there should be a way to get it done.

Concerns

I have a few concerns regarding the behaviour of this code.

  • Inter-platform consistency. I seriously doubt that all operations go the sameway across all platforms.
  • Read operations. Reading was never needed in my project, so all the tests Idid on that matter were theoretic. I was also quite naive, so the API isprobably not optimal. What we need is to re-think reading from scratch.
  • Configuration done by calling functions. This is so Java. It would be muchbetter to be able to pass a configuration array once and for all. Furthermore,I suspect that the order of call matters, which is bad.
  • Auto-closing the device. There is an auto-close function that is registeredat PHP shutdown. This sounds quite ridiculous, something has to be done aboutthat.
  • Use exceptions. Currently there is an heavy use of the errors system to reporterrors (2007 baby), but this is seriously lame. They have to be replaced byactual exceptions.

Call for contribution

I have about 0 time to code or test this project. However, there is clearly aneed for it.

As in all open-source projects, I need people to fit this to their needs and tocontribute back their code.

What is needed, IMHO:

  • Address the concerns listed above, and find new ones.
  • Create a reproducible test environment for each OS, and prove that eachfeature works (basically, unit-testing).
  • Report of use cases, bugs, missing features, etc.

If you feel like doing any of those, do not hesitate to create an issue or apull-request, I'll gladly consider consider it :)

Licence

PHP SerialCopyright (C) 2007-2014 PHP Serial's contributors (see CONTRIBUTORS file)

This program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2 of the License, or(at your option) any later version.

This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.

You should have received a copy of the GNU General Public License alongwith this program; if not, write to the Free Software Foundation, Inc.,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Active6 years, 8 months ago

I have installed xampp in fedora 13.I am trying to communicate with microcontroller through serial port using php serial class.My code is example.php

The php script gets executed but gives the following warnings .

Warning: Specified serial port is not valid in /opt/lampp/htdocs/xampp/php_serial.class.php on line 147Warning: Unable to set the baud rate : the device is either not set or opened in /opt/lampp/htdocs/xampp/php_serial.class.php on line 241Warning: Unable to set parity : the device is either not set or opened in /opt/lampp/htdocs/xampp/php_serial.class.php on line 295

Download hp compaq recovery disk This recovery function completely erases and reformats the hard disk. The program performs a full system recovery to reinstall the operating system, programs, and drivers from the recovery CDs. However, you must reinstall any software that was not installed on the computer at the factory. Because of software licensing restrictions, HP and its partners can only provide recovery kits for a limited time. Recover or reset the computer without recovery media Read one of the following documents for system recovery or reset options that do not require a disc or USB drive.

Linux Serial Port Software

.. I have used the command : chmod 0777 /dev/ttyUSB0 to give permissions . I have also tried to add the apache user 'prudhvi' to the dialout group by using command : $ usermod -a -G dialout prudhvi

Php

But it doesnt work . When I send a command directly from the terminal using the command : echo 1 > /dev/ttyUSB0 it works and '1' is transmitted to the serial port . But using php I get the above warnings .

I have used the '$whoami' to check name of user and added that user 'prudhvi' to the dialout group . It still doesnt work . Please help me guys.

prudhvi09
prudhvi09prudhvi09

4 Answers

I did this once with Debian to control an Arduino board with a PHP script and initially ran into the same problem.

In Debian, you need to add the Apache user to the dialout group in order to allow it to make serial connection requests. I would assume the same is true for Fedora.

In Debian the command is:

However I believe Fedora names the Apache user as apache instead. I don't have a Fedora machine to test on, but I would assume the command you need to run is:

Php Serial Port Communication

You will then need to restart your xampp server.

See the following for reference:

Neal

nealio82nealio82
2,5191 gold badge12 silver badges19 bronze badges

Could you post the lines near / related to '/opt/lampp/htdocs/xampp/php_serial.class.php on line 147'?

I suspect that you are trying to set the device incorrectly (as Marc indicated). Either that or the port is already in use from other testing you are conducting at the same time. I'm not sure if the script you are running provides errors specific to ports you are trying to attach to already being in use.

PilipoPilipo

First test a hello world type php script to testyour basic installation.

Then verify the web server / php engine is running as a user which is in a group allowed to access the applicable /dev/ttyWHATEVER device file corresponding to the serial port. It would be surprising if that were true by default - you'll probably have to add it to the 'dialout' or similar group.

Add some fault checking / reporting to your code.

Chris StrattonChris Stratton
36.3k5 gold badges66 silver badges106 bronze badges

Linux Serial Port Example

Credit goes to Marc B's comment for causing me to look this up, and he's dead on: http://www.phpclasses.org/browse/file/17926.html

I believe that calling $serial->deviceSet('/dev/ttyUSB0'); will fix it, but you may have to modify the source of php_serial.class.php to work on /dev/ttyUSB instead of /dev/ttyS.

Open Serial Port Linux

zebediah49zebediah49

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