Bug #66943 [NEW]: Can't open COM10 or higher serial ports
From: mattficken
Operating system: Windows
PHP version: Irrelevant
Package: Streams related
Bug Type: Bug
Bug description:Can't open COM10 or higher serial ports
Description:
------------
PHP on Windows can't open (using fopen()) serial ports greater than
COM9:, fe fopen("COM10:" or fopen("COM11:" fail.
This occurs regardless of the mode passed to fopen. "r+b" is the correct
mode for serial on Windows. "r+" allows reading and writing. "b" sets it
to binary mode, important because: Windows converts non-ASCII (>127)
bytes if the stream is in text mode.
I am using Serial over USB (FTDI driver) to communicate with a
microcontroller (Arduino).
In Serial over USB (not real serial) on Windows you can rename COM
ports, so users can work around this problem by renaming COM ports to
unused ports like COM7 or COM8, etc... for instructions, see my PR below
for the PhpSerial class.
I have modified the PhpSerial class to work on Windows (for both read
and write), see https://github.com/Xowap/PHP-Serial/pull/3 as
an
example of how to use serial ports from PHP.
I suspect the cause is in the realpath() parser, checking for COM*: with
a one integer but not two (not COM**: )
Test script:
---------------
// connect Serial-over-USB device to Windows PC, such as an Arduino Uno
// (which uses an FTDI controller, get the FTDI driver for
Windows
// from Sourceforge or Arduino)
fopen("COM10:", "r+b");
Expected result:
----------------
fopen() returns a resource handle
Actual result:
--------------
"failed to open stream: invalid argument"
--
Edit bug report at https://bugs.php.net/bug.php?id=66943&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66943&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66943&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66943&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66943&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66943&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66943&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66943&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66943&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66943&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66943&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66943&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66943&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66943&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66943&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66943&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66943&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66943&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66943&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66943&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66943&r=mysqlcfg
Thread (2 messages)
- mattficken@php.net