IreneLing Posted September 23, 2011 Share Posted September 23, 2011 I wonder if this topic is allow to be here , if it is not I'm so sorry for this post and please move or delete it. I need to use php to connect to COM port , I googled it and there are few ways to do it , such as fopen() or dio_open() using php_dio.dll etc. I tried both methods but it still can't works . The errors I get always: dio_open()[function.dio_open]:cannot open file COM36:with flags 2 and permissions 0: Invalid argument ****.... or Warning:fopen(COM36:)[function.fopen]:failed to open stream:Invalid argument in *****.... Fatal error:uncaught exception 'Exception' with message 'Unable to open port "COM36" in *****.... Can I get some help for this problem? Thanks for every reply . Quote Link to comment https://forums.phpfreaks.com/topic/247726-php-connect-to-serial-port/ Share on other sites More sharing options...
gizmola Posted September 23, 2011 Share Posted September 23, 2011 We have had this question in the past, and afaik, php-dio is the only way to get read/write serial port communication working on windows. Read the manual page carefully, as there are version requirements: http://us2.php.net/manual/en/book.dio.php This article has a wrapper and working implementation you can use as a basis for your project: http://blog.950buy.com/article/php-use-rs232-serial-communication-to-send-file/ Quote Link to comment https://forums.phpfreaks.com/topic/247726-php-connect-to-serial-port/#findComment-1272135 Share on other sites More sharing options...
IreneLing Posted September 23, 2011 Author Share Posted September 23, 2011 Thanks for your links gizmola , so should I install this package? http://pecl.php.net/package/dio I already added php_dio.dll into ext folder and add "extension=php_dio.dll" in php.ini , but it still can't works . I'm using PHP 5.2.6 , Apache 2.2.17 , Window Vista . Sorry if my question is stupid.. I'm just a newbie in php... Thanks again . Quote Link to comment https://forums.phpfreaks.com/topic/247726-php-connect-to-serial-port/#findComment-1272150 Share on other sites More sharing options...
gizmola Posted September 23, 2011 Share Posted September 23, 2011 It looks like you've met the requirements. What does phpinfo() show you for php-dio? Since the functions actually work, it looks like you have what you need. Quote Link to comment https://forums.phpfreaks.com/topic/247726-php-connect-to-serial-port/#findComment-1272160 Share on other sites More sharing options...
IreneLing Posted September 23, 2011 Author Share Posted September 23, 2011 Should be this one I already checked my port using hyperterminal , it's connected and I can access to it through the modem software (it is a GSM modem) , except PHP.... Quote Link to comment https://forums.phpfreaks.com/topic/247726-php-connect-to-serial-port/#findComment-1272177 Share on other sites More sharing options...
gizmola Posted September 24, 2011 Share Posted September 24, 2011 That is an older version. Try the one in this archive: http://museum.php.net/php5/pecl-5.2.6-Win32.zip Quote Link to comment https://forums.phpfreaks.com/topic/247726-php-connect-to-serial-port/#findComment-1272447 Share on other sites More sharing options...
IreneLing Posted September 24, 2011 Author Share Posted September 24, 2011 Thank you gizmola , I changed the php_dio file , but it still the same version . Quote Link to comment https://forums.phpfreaks.com/topic/247726-php-connect-to-serial-port/#findComment-1272464 Share on other sites More sharing options...
gizmola Posted September 24, 2011 Share Posted September 24, 2011 Thank you gizmola , I changed the php_dio file , but it still the same version . Did you restart apache? Quote Link to comment https://forums.phpfreaks.com/topic/247726-php-connect-to-serial-port/#findComment-1272493 Share on other sites More sharing options...
IreneLing Posted September 25, 2011 Author Share Posted September 25, 2011 Yes I restart it , but still remain the same . Anyway I just change my OS to Ubuntu,and finally successfully connected , wonder is it vista problem...? Thanks for your every reply gizmola , really thanks . Have a nice day . Quote Link to comment https://forums.phpfreaks.com/topic/247726-php-connect-to-serial-port/#findComment-1272696 Share on other sites More sharing options...
gizmola Posted September 25, 2011 Share Posted September 25, 2011 Glad to hear you got it working. Quote Link to comment https://forums.phpfreaks.com/topic/247726-php-connect-to-serial-port/#findComment-1272697 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.