php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67098 dio_open() fails on COMxx:
Submitted: 2014-04-20 02:24 UTC Modified: 2014-04-23 23:15 UTC
Votes:7
Avg. Score:4.4 ± 1.4
Reproduced:6 of 6 (100.0%)
Same Version:5 (83.3%)
Same OS:2 (33.3%)
From: cobra91 at gmx dot de Assigned:
Status: Open Package: dio (PECL)
PHP Version: Irrelevant OS: Windows7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cobra91 at gmx dot de
New email:
PHP Version: OS:

 

 [2014-04-20 02:24 UTC] cobra91 at gmx dot de
Description:
------------
I set up my USB Serial Device as COMx (COM1-COM9) and everything works fine.
But if I change it to a number with more than one digit, it shows me a warning which says 'Invalid Argument'.

Test script:
---------------
<?php

//both exec work
//exec('mode com6: baud=115200 data=8 stop=1 parity=n xon=off dtr=off rts=off');
exec('mode com11: baud=115200 data=8 stop=1 parity=n xon=off dtr=off rts=off');

//$fd = dio_open('com6:', O_RDWR); //<--works
$fd = dio_open('com11:', O_RDWR); //<-- dont work (invalid argument)

$command="\x11\x0E\x1B\x44\x4C\x1B\x47\x44\x00\x00\x00\x00\x3F\x01\xEF\x00\x9F\x00";
$len=17;

$bytes_written = dio_write($fd,$command,$len);

echo $bytes_written;

dio_close($fd);

?>

Expected result:
----------------
Using com6 -> the script echos 17

using com11 -> the script should echo 17

Actual result:
--------------
Using com6 -> the script echos 17

using com11 -> 
Warning: dio_open(): cannot open file com11: with flags 2 and permissions 0: Invalid argument in ...
Warning: dio_write() expects parameter 1 to be resource, boolean given in ...
Warning: dio_close() expects parameter 1 to be resource, boolean given in

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-04-23 22:42 UTC] mattficken@php.net
This sounds like my bug #66943 (with fopen).

Would you try:
dio_open('\\\\.\COM11', o_RDWR);
 [2014-04-23 23:15 UTC] cobra91 at gmx dot de
$fd = dio_open('\\\\.\COM11', O_RDWR); <-- works
This sounds like a workaround and not a solution.
 [2016-01-07 19:04 UTC] Saemichlaus at gmx dot ch
I've been developing a desktop serial monitor in C++ for Windows. I established the serial connection by calling the CreateFile() function, which takes the same string for a file path as your question is about.
And in fact, "COMx" works fine with a one digit port number. When addressing ports larger than COM9 in Windows you will have to specify the port with the syntax "\\.\COMxxx" ("\\\\.\\COMxxx" when respecting escape sequence resolving). This more detailed syntax also works with COM1-COM9, so you can safely go with this syntax for any port number contained in a variable.

For as far as I know, this is at least a Windows thing. Microsoft Support has an article about this: https://support.microsoft.com/en-us/kb/115831
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Oct 23 02:01:31 2019 UTC