Php Serial Port Communication Linux Distros
How to create a virtual serial/COM port in Linux I was hoping to have my hardware finished by now so I could get on with testing the software over Easter. The hardware does not work yet but I would still like to test the software. Apr 30, 2012 php serial communication in linux. Arduino Forum Using Arduino Programming Questions php serial communication in. 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(find the attachment).On opening example.php through firefox the code is.
I am building an online POS and trying to establish low level communication with an Epson tm-t88iv thermal printer. there is no direct printing of files, only hexadecimals or ascii can be sent to the hardware in a specific format for it to print. all of this done in a linux enviroment (both ubuntu 13.10 and 12.04).
Now the problem is that I can't establish communication with the printer. I have tried using Jzebra and other java to javascript libraries but with no luck, so I changed to a more familiar environment and tried using the php serial class with a status check code but nothing happens.
which returns an empty string. Also the printer is not receiving the hexadecimals (it is set on a hex-dump state, to print every hex it receives).
I am not sure even if its a coding or hardware problem. I tried installing cutecom to talk with serial port but I don't get any answers either. I also tried doing some stty commands directly from shell but got nothing either.
If someone can please shed a light on why this is happening or if he has any similar experience, it would be great.
thanks!
p.d: i am connecting using a prolific pl2303 serial to usb cable and its correctly installed as far as i am aware.
Kumar VBrowse other questions tagged phplinuxserial-portlow-level or ask your own question.
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
... 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
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.
4 Answers
I did this once with Debian to control an Arduino board with a PHP script and initially ran into the same problem.
Linux Serial Port
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:
You will then need to restart your xampp server.
See the following for reference:
Neal
nealio82nealio82Could 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.
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 StrattonCredit 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
.