<?php |
You can run mode from Ms DOS command prompt. For example:
C:\> mode com4:/status
The above DOS command display the status of the COM port.
Syntax of mode (display a list of mode commands & options)
C:\> mode/?
Open COM4 in write mode (for Microsoft Windows only)
$fp =fopen("com4", "w"); |
or your can use $fp =fopen("com4", "r+"); for read & write
Open USB serial port for read and write (for Linux)
$fp =fopen('/dev/ttyUSB0',r+'); |
Open first serial port in read & write (for Linux)
$fp = fopen('/dev/ttyS0','r+'); |
To terminate string with Carriage Return
fwrite($fp, "string to send\r"); |
To terminate string with New Line & Carriage Return
fwrite($fp, "string to send\n\r"); |
Close the serial port
fclose($fp); |
There are many people using php_serial.class. Unfortunately it is not working in my computer. Please let me know if some one can make the following code work.
<?php |