I asked a previous question about a PHP call no longer working on when Win10 upgraded to Win 11. It now strangely writes to a file rather than to the set COM port (may be a win11 apache/php issue, see my other question?).
The code that used to work was:
<?php
`mode com3: BAUD=38400 PARITY=N data=8 stop=1 xon=off`;
file_put_contents(com3, chr(1).chr(255).chr(1).chr(4).chr(64).chr(5));
?>
This used to work fine but now writes to a file called com3 :(
fyi: The ` backtick quotes in PHP executes the command in it - and this still works on Win11.
- Question is how can I do this direct from Console/CMD prompt. This already works e.g.:
C:\> mode com3: BAUD=38400 PARITY=N data=8 stop=1 xon=off
And can apparently send a command using:
C:\> set /p x="hello" <nul >\\.\COM3
But instead of sending "hello" I want to send the same as would have using the PHP code: "chr(1).chr(255).chr(1).chr(4).chr(64).chr(5))"
Anyone have a good idea how I can send this code from the CMD. As I will make another script to automate this.
Any advice appreciated?
i.e. in php I would do something like:
<?php
$scall = chr(1).chr(255).chr(1).chr(4).chr(64).chr(5);
`mode com3: BAUD=38400 PARITY=N data=8 stop=1 xon=off`;
`set /p x="$scall" <nul >\\.\COM3`;
?>
Appreciate if someone knows how I would change this PHP script, to be able to send those number values? (It may already be fine ;)
fyi: On 232 analyser or some USB Serial COM port software - I would send the code in "DEC", with "1,255,1,4,64,5," And this works too... If helps to set what values would send in CMD prompt.
Thanks for the help.