Solved

serial communication using php in linux

Posted on 2006-06-22
5
454 Views
Last Modified: 2012-05-05
i am new in linux environment . i want to write data on serial port using PHP the code i have written is

<?php

$fp = fopen ("/dev/ttyS0", "w");

echo fput ($fp,128);

?>

but the error has ocured that
Warning: fopen("/dev/ttyS0", "w") - Permission denied and Fatal error: Call to undefined function: fput()  kindly help me out
0
Comment
Question by:abdul_baig
  • 2
5 Comments
 
LVL 29

Accepted Solution

by:
TeRReF earned 250 total points
ID: 16957762
The user the webserver runs under needs to have rights to access /dev/ttyS0. You can achieve this with chmod.
It's not fput(), but fputs().
0
 
LVL 8

Assisted Solution

by:kaliyugkaarjun
kaliyugkaarjun earned 250 total points
ID: 16958539
1: $fp = fopen ("/dev/ttyS0", "w");
If you have logged in the system as root user then you will not have such permission problem..

Otherwise ..u have to login as a root user..
change the file permissions to have write access..
Just do one thing..change the file permissions to 333 using
chmod 333 /dev/ttyS0
2: echo fput ($fp,128);
Try using fputs($fp,128) or fwrite($fp,128)

This will work
0
 
LVL 29

Expert Comment

by:TeRReF
ID: 16959212
What use is it to just repeat my answer kaliyugkaarjun ?
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP Query return divisible by 3 3 26
Wordpress Security 29 48
PHP Curl to output a url 7 48
Generate PDF from MySQL using PHP 3 24
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question