|  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
Avg. Score:4.4 ± 1.3
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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
44 + 16 = ?
Subscribe to this entry?

 [2014-04-20 02:24 UTC] cobra91 at gmx dot de
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:

//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)


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

echo $bytes_written;



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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-04-23 22:42 UTC]
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:
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun May 31 21:01:25 2020 UTC