0

I'm looking for a way to read/write a PC's serial com port using PHP/IIS on Windows 10. I've experimented for a few days now, but every attempt failed.

I tried to use php_dio.php, only to find out this dll misses some essential implementation on Windows. Through StackOverflow I also read that it would impossible for PHP on Windows to do this.

I can use Powershell on Windows to perform the tasks I want using scripts, but I'm not able to gets it output. Also, I fail to start this from PHP using exec or shell_exec.

So, at the moment, I'm stuck. My goal is to create a PHP-file which is able to receive requests from the web. That request would than be translated into a command which I would send to a device which is connected on my com-port. The response on the com-port would then be sent back to the server which did the request. It's just simple serial I/O, like 9600 bd, No parity etc. The setup works, but like I said, every attempt to use PHP to access the com port fails.

Is there a way?

Suggestions are appreciated. Thanks.

Tried php_dio, exec, shell_exec

Sutur
  • 9
  • 1
  • https://www.itdroplets.com/run-a-powershell-script-from-php/ – lufc Aug 04 '19 at 18:16
  • Please take a look at this https://stackoverflow.com/questions/56032763/two-shell-exec-command-with-php-button-but-still-in-the-one-powershell I've also tied to **read** serial port using php. But I was out of luck (the powershell attempt always lacks some privileges). I switched to python where it's absolutely no problem at all. – Mike Feustel Aug 04 '19 at 19:22
  • @lufc Thanks, the info on that page makes sense, but it somehow, I cannot make things work with a pool running with another user than 'DefaultAppPool'. When I run the php-page using the defaultpool, I get results from simple commands like shell_exec ("dir"). When I use a pool which is running using an administrator user, these commands fail and I get PHP warnings. I'm really puzzled why the default pool can make at least some execs, but a pool with an administrator user cannot. – Sutur Aug 05 '19 at 12:31
  • I've made a change which now allows me to exec basic powershell commands like 'dir'. At the website I changed Anonymous Authentication to use the Application pool identity. It now works like the DefaultAppPool works. But when executing this command, the php-page times out and returns error 500, just like the Default Pool: echo shell_exec ('powershell.exe -executionpolicy bypass -NoProfile -Command "Get-Process | ConvertTo-Html"'); So, I'm still no step further.. – Sutur Aug 05 '19 at 12:51

0 Answers0