Jump to content

Archived

This topic is now archived and is closed to further replies.

IreneLing

PHP connect to serial port

Recommended Posts

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 .

Share this post


Link to post
Share on other sites

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/

 

Share this post


Link to post
Share on other sites

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 .

 

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
Share on other sites

Should be this one

Untitled-3.jpg

 

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....

Share this post


Link to post
Share on other sites

Thank you gizmola , I changed the php_dio file , but it still the same version .

 

Did you restart apache?

 

Share this post


Link to post
Share on other sites

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 .

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.