I have Powershell syntax that can get data using ReadExisting(), but the problem is... that syntax must compele php condition before (and some shell_exec syntax when page load)
I trying Get COM1 Data using powershell, and its working with this code
in that image, the first ReadExisting() can't declare the output because the device in COM1 not showing new result, when the devices show the result, trying the ReadExisting() again and i get what i want.
So (what in my opinion) the logic i should implement on PHP is : - Execute $port and $port.Open() first - Execute ReadExisting() after that.
I'm trying making the php code like this
<?php
$result = shell_exec('powershell $port = New-Object System.IO.Ports.SerialPort COM1,9600,None,8,one ; Get-Variable ; $port.Open(); $port.ReadExisting() ');
echo $result
?>
<form method="post">
<input type="submit" name="test" id="test" value="RUN" /><br/>
</form>
<?php
function testfun()
{
$result2 = shell_exec('powershell $port.ReadExisting()');
echo $result2;
}
if(array_key_exists('test',$_POST)){
testfun();
}
?>
but the button not showing the result like that in the powershell. What i can see problably because i'm making two shell_exec?, and yes the $result is working (i'm already testing it and i can see the port connection variable)
it's there possible method making continues shell command with button condition? thank you!.