PHP 如何关闭RS232串口?
就是我不知道串口是否在打开,我判断如查开打,我将其关闭。 PHP如何实现?

解决方案 »

  1.   

    我就是用PHP在网页上将其打开的。在我没有关闭串口时,已经把网页关闭了。当我再一次进入到这个页面时,串口还是打开着,我如何将其关闭。PHP如何实现?
      

  2.   

    不必关闭吧,难道你的open出错了?错误信息是什么?
      

  3.   

    COM 口已经被我打开了,我如何关闭,再将其打开
      

  4.   

    出现如下提示:
    Warning: dio_open() [function.dio-open]: cannot open file COM3: with flags 2 and permissions 0: Permission denied in D:\wwwroot\test\RS232_Server2.php on line 62
    Error when open COM3PHP has encountered an Access Violation at 017573CD显然是COM口在打开着.只有我有方法判断COM口在打开着,并将其关闭就行了.再次打开就行了,或者不对开,真接用打开的COM口.
    可我不知道如何判断.得到打开COM口的文件.
      

  5.   

    如果不是同一个线程开的,大概你没有关闭的权限,打不开的话就睡觉吧:
    <?php
    error_reporting(0);
    while (1) {
    $fd = dio_open('COM3:', O_RDWR | O_NOCTTY | O_NONBLOCK) ;
    if ($fd) break;
    // echo(".");
    sleep(1);
    }
    error_reporting(E_ALL);
    ?>
      

  6.   


    是COM口没有关闭时,我已经终止程序.不是我没有关闭的权限.我觉得我现在只要获取打开的COM口文件,将其闭就行了.
      

  7.   

    这和文件一回事儿,别的程序打开的文件你能强行关闭吗?不重启PHP线程够呛吧.
      

  8.   

    php里,那总该有法把它关闭吧,
      

  9.   

    除了强杀线程,别说php了,你试试别的语言办得到吗?
      

  10.   

    php 不能关闭其它进程占有的串口
    你应该是想方法令 占有串口的进程自己关闭flags是其中一种方法
      

  11.   

    具体怎么做呢,flags有如下方法
    The flags parameter can also include any combination of the following flags: 
    O_CREAT - creates the file, if it doesn't already exist. O_EXCL - if both, O_CREAT and O_EXCL are set, dio_open() fails, if the file already exists. O_TRUNC - if the file exists, and its opened for write access, the file will be truncated to zero length. O_APPEND - write operations write data at the end of the file. O_NONBLOCK - sets non blocking mode