Website: http://www.easyvitools.com
Installation:
- download from website
- unzip php_ser.zip and place php_ser.dll file in PHP extension folder.
For PHP5 this is usualy: drive:\PHP_install_folder\ext\
Example: C:\PHP\ext\
- find php.ini file (usualy placed in C:\Windows folder) and open it
- fill extension_dir directive with extension folder, for example:
extension_dir= ".\ext"
- fill an extension directive to load php_ser automatically:
extension=php_ser.dll
- save and close php.ini file
- test with php_ser_test.php file (included in distribution), which lists functions
Important notice
PHP must run as CGI. To find if you are running PHP as CGI and if you are using
correct php.ini please make a file like this in your web folder:
<html> <head> <title> Local index page </title> </head> <body> <?php phpinfo(); ?> </body> </html>Load it and look for information under Server API line (should be CGI/FastCGI),
string ser_version( void )
Returns extension version as string, example 10032006.1.
void ser_open( string port, int baudrate, int databits, string parity, float stopbits, string flowcontrol )
Opens serial port.
port: a valid port name, in upper case, such as "COM3"
baudrate: valid baudrates are: 110,300,600,1200,2400,4800,9600,14400,19200,38400,56000,57600,115200
databits: valid databits are: 5,6,7,8
parity: valid parities are: None,Odd,Even,Mark,Space
stopbits: valid stopbits are: 1,1.5,2
flowcontrol: valid flowcontrols are: None,Hardware,Software
Example:
ser_open( "COM1", 115200, 8, "None", 1, "None" );
string ser_isopen( void )
Returns a string describing port properties if open, empty string if closed<.br>
Example:
$str = ser_isopen();
echo "Port: $str";
Outputs following string on web page: Port: COM3 115200 8 None 1 None.
void ser_close( void )
Closes serial port.
void ser_setDTR( bool Signal_state )
Set DTR signal as specified by Signal_state parameter, true or false.
Example:
ser_setDTR( True );
This procedure raises DTR.
void ser_setRTS( bool Signal_state )
Set RTS signal as specified by Signal_state parameter, true or false.
Example:
ser_setRTS( True );
This procedure raises RTS.
void ser_write( string data )
Writes data string to the serial ports.
Example:
ser_write( "Hello from PHP" );
This procedure sends "Hello from PHP" to serial port.
void ser_writebyte( byte data )
Writes data byte to the serial ports.
Example:
ser_write( 0 );
This procedure sends byte 0 to serial port.
string ser_inputcount( void )
Returns number of bytes available to be read in input buffer.
Example:
$nr = ser_inputcount( );
echo "$nr bytes available";
Outputs following string on web page: 17 bytes available.
string ser_read( int chars_no )
Reads data from serial port until chars_no characters are received or timeout occurs.
Example:
$str = ser_read(512);
echo "Received: $str";
Outputs following string on web page: Received: Hello from PHP.
string ser_readbyte( )
Reads one byte form serial port. Returns -1 if no data is available.
Example:
$b = ser_readbyte();
printf('Received: %X', $b);
Outputs following string on web page: Received: 0D.
Software is in continuous development, please check website for updates.
Copyright 2006, Cosmin Buhu