Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 19, 2024, 08:19:39 20:19


Login with username, password and session length


Pages: [1]
Print
Author Topic: REQ: Serial Port with PHP?  (Read 13381 times)
0 Members and 1 Guest are viewing this topic.
smainj
Active Member
***
Offline Offline

Posts: 125

Thank You
-Given: 70
-Receive: 75



WWW
« on: August 12, 2011, 12:24:00 12:24 »

Hi
i try to read/write data from the serial port using PHP
but i can't find solution
plz anybody can help me and thank you.
Logged

zorx
Active Member
***
Offline Offline

Posts: 120

Thank You
-Given: 48
-Receive: 163


« Reply #1 on: August 12, 2011, 04:52:53 16:52 »

I think that googling will give you enough hints.
One of them:
http://code.google.com/p/php-serial/

Regards
Logged
titi
Active Member
***
Offline Offline

Posts: 229

Thank You
-Given: 3696
-Receive: 834



« Reply #2 on: August 12, 2011, 06:09:07 18:09 »

Hi smainj,

to complete the message of zorx, unfortunatly there is no download available at this time.

So by using SVN, this is the last source in attachment, i have not tested, but normally should be functional.

Best regards
Logged
DarkClover
Active Member
***
Offline Offline

Posts: 169

Thank You
-Given: 37
-Receive: 60


Still alive...


« Reply #3 on: August 12, 2011, 10:46:49 22:46 »

May I ask what you need PHP in connection with the serial port for ?

If you want to monitor, you can use any MySQL DB and a sniffer
Program ?
Logged

Not thinking means to believe what others say!
TRY & ERROR... the fundamental principle our existence is based on
smainj
Active Member
***
Offline Offline

Posts: 125

Thank You
-Given: 70
-Receive: 75



WWW
« Reply #4 on: August 13, 2011, 10:12:48 10:12 »

May I ask what you need PHP in connection with the serial port for ?

If you want to monitor, you can use any MySQL DB and a sniffer
Program ?
i will read temperature from many DS18B20 ,save them to databasse and plot the data


Posted on: August 13, 2011, 11:03:49 11:03 - Automerged

Hi smainj,

to complete the message of zorx, unfortunatly there is no download available at this time.

So by using SVN, this is the last source in attachment, i have not tested, but normally should be functional.

Best regards
thank you for your help, with this file i can send data but i can't read
Logged

titi
Active Member
***
Offline Offline

Posts: 229

Thank You
-Given: 3696
-Receive: 834



« Reply #5 on: August 13, 2011, 02:40:36 14:40 »

Hi,

I have found a PHP instruction to read RS232 in library Direct IO. http://www.php.net/manual/en/book.dio.php

Here is an example:
Code:
<?php
 
exec
('mode com1: baud=9600 data=8 stop=1 parity=n xon=on');
 
// execute 'help mode' in command line of Windows for help
 
$fd dio_open('com1:'O_RDWR);
 
while (
1) {
 
  
$data dio_read($fd256);
 
  if (
$data) {
      echo 
$data;
   }
 }
 
?>


You can found more explications in : http://www.php.net/manual/en/function.dio-tcsetattr.php#51509

Best regards.
Logged
smainj
Active Member
***
Offline Offline

Posts: 125

Thank You
-Given: 70
-Receive: 75



WWW
« Reply #6 on: August 15, 2011, 11:49:35 11:49 »

thanks for your help
working code

<?php
    // Use this code to write directly to the COM1 serial port
    // First, you want to set the mode of the port. You need to set
    // it only once; it will remain the same until you reboot.
    // Note: the backticks on the following line will execute the
    // DOS 'mode' command from within PHP
    `mode com1: BAUD=9600 PARITY=N data=8 stop=1 xon=off`;
    $fp = fopen ("COM1:", "w+");
    if (!$fp) {
        echo "Uh-oh. Port not opened.";
    } else {               
        $string  =   "Send"  ;       
        echo $string;
        fputs ($fp, $string );       
        sleep(5);
        $buffer = fgets($fp);
        echo $buffer ;
        fclose ($fp);
    }
?>
Logged

Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC