简体   繁体   中英

I can't use dio_extension php

I've downloaded dio extension->php_dio.dll (version 5.2.6.6) and put it in extension dir php then put extension=php_dio.dll in php.ini then restart the apache.

in phpinfo() shows: see here

I read in some forum that it's old version of dio extension.

I've tried to run this script :

<?php 
    // Create a stream context that configures the serial port
    // And enables canonical input.
    $c = stream_context_create(array('dio' => 
        array('data_rate' => 115200, 
              'data_bits' => 8, 
              'stop_bits' => 1, 
              'parity' => 0, 
              'is_canonical' => 1)));

    // Are we POSIX or Windows?  POSIX platforms do not have a
    // Standard port naming scheme so it could be /dev/ttyUSB0
    // or some long /dev/tty.serial_port_name_thingy on OSX.
    if (PATH_SEPARATOR != ";") {
        $filename = "dio.serial:///dev/ttyS0";
    } else {
        $filename = "dio.serial://COM5";
    }

    // Open the stream for read only and use it.
    $f = fopen($filename, "r+", false, $c);
    if ($f) {
        echo "Writing to port...\n";
        fprintf($f,"Hello world\n");
        echo "Reading from port...\n";
        $data = fgets($f);
        if ($data) {
            echo $data;
        }
        fclose($f);
    }
?>

but I always get Warning: fopen(dio.serial://COM5) [function.fopen]: failed to open stream: No such file or directory in

dio extension does not work in windows? or i'm using a old version?

if i'm using a old version, where can i find the newer version of dio extension.

Thanks in advance.

Try dio_open() . And the latest release on the PECL servers is 0.0.4RC4 . What you have there is a mislabeled pre-release of 0.0.2 instead.

If you want to pander further options (rather than checking the permission thingy mentioned last time), then socat might be. It maps devices onto sockets. A Windows (Cygwin) binary of that exists.

Also, while I don't want to berate anyone for personal preferences. You wouldn't have those problems if you didn't insist on using Windows.

Comments will not be answered.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM