Solved

serial communication using php in linux

Posted on 2006-06-22
5
447 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

911 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now