dongshanni1611 2011-12-04 15:33
浏览 89

我不能使用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...
";
        fprintf($f,"Hello world
");
        echo "Reading from port...
";
        $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.

  • 写回答

1条回答 默认 最新

  • douju1365 2011-12-04 16:26
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 BV260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)