Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 08, 2016, 08:55:56 20:55


Login with username, password and session length


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

Posts: 125

Thank You
-Given: 69
-Receive: 75



WWW
« on: August 12, 2011, 01:24:00 13: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
***
 Muted
Offline Offline

Posts: 121

Thank You
-Given: 48
-Receive: 163


« Reply #1 on: August 12, 2011, 05:52:53 17: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: 192

Thank You
-Given: 1434
-Receive: 705



« Reply #2 on: August 12, 2011, 07:09:07 19: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: 170

Thank You
-Given: 36
-Receive: 60


Still alive...


« Reply #3 on: August 12, 2011, 11:46:49 23: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: 69
-Receive: 75



WWW
« Reply #4 on: August 13, 2011, 11:12:48 11: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: 192

Thank You
-Given: 1434
-Receive: 705



« Reply #5 on: August 13, 2011, 03:40:36 15: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: 69
-Receive: 75



WWW
« Reply #6 on: August 15, 2011, 12:49:35 12: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