简体   繁体   English

我不能使用dio_extension php

[英]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. 我已经下载了dio extension-> php_dio.dll(版本5.2.6.6),并将其放在扩展名dir php中,然后将extension = php_dio.dll放入php.ini中,然后重新启动apache。

in phpinfo() shows: see here 在phpinfo()中显示: 请参见此处

I read in some forum that it's old version of dio extension. 我在某个论坛上看到它是dio扩展的旧版本。

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 但是我总是得到警告:fopen(dio.serial:// COM5)[function.fopen]:无法打开流:在该目录中没有这样的文件或目录

dio extension does not work in windows? dio扩展名在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. 如果我使用的是旧版本,则在哪里可以找到dio扩展的较新版本。

Thanks in advance. 提前致谢。

Try dio_open() . 尝试dio_open() And the latest release on the PECL servers is 0.0.4RC4 . PECL服务器上的最新版本是0.0.4RC4 What you have there is a mislabeled pre-release of 0.0.2 instead. 您所拥有的是贴0.0.2标签的0.0.2预发布版本。

If you want to pander further options (rather than checking the permission thingy mentioned last time), then socat might be. 如果您想平移其他选项(而不是检查上一次提到的权限),则可以使用socat It maps devices onto sockets. 它将设备映射到套接字。 A Windows (Cygwin) binary of that exists. 存在该Windows的(Cygwin)二进制文件。

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. 如果您不坚持使用Windows,则不会有这些问题。

Comments will not be answered. 评论将不予回答。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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