|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-04-23 22:33 UTC] mattficken@php.net
[2020-09-07 12:52 UTC] cmb@php.net
-Type: Bug
+Type: Documentation Problem
[2020-09-07 12:52 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 05:00:01 2025 UTC |
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"