Solved

serial communication using php in linux

Posted on 2006-06-22
5
443 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
Comment Utility
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
Comment Utility
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
Comment Utility
What use is it to just repeat my answer kaliyugkaarjun ?
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

772 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

10 Experts available now in Live!

Get 1:1 Help Now