Jump to content

PHP connect to serial port


IreneLing

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 .

Link to comment
https://forums.phpfreaks.com/topic/247726-php-connect-to-serial-port/
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/

 

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 .

 

Archived

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

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