Quicklinks
ActiveComport is a software development kit (SDK) that enables the user to communicate to a device over a serial interface.
Such a device can be: a weight indicator, a modem, a scanner, or any other device that is equiped with a serial port. It can even be another PC, connected via a NULL modem cable.
ActiveComport can be well integrated into PHP environments. This document describes how ActiveComport can be integrated into PHP projects.
Download the ActiveComport Toolkit from the ActiveXperts Download Site and start the installation. The installation guides you through the installation process.
You must use PHP script to declare and create the ActiveComport object.
Use the following PHP code to create the Comport object:
$objComport = new COM ( "ActiveXperts.Comport" );
You can now send and/or receive serial data.
The following PHP code shows how to initialize a modem with some AT commands:
<html>
<head>
<META HTTP-EQUIV="CONTENT-Type" CONTENT="text/html;CHARSET=utf-8" >
<title>ActiveXperts ActiveComport PHP Sample</title>
</head>
<body>
<font face="sans-serif" size="2">
<hr size="1" color="#707070">
<font size="4">ActiveXperts ActiveComport PHP Sample</font>
<br>
<br>
<b>Initialize a Hayes compatible modem with some AT commands.</b>
<br>
<br>
<hr size="1" color="#707070" >
<br>
<?php
$objComport = new COM ( "ActiveXperts.Comport" );
$objComport->Logfile = "C:\\PhpSerialLog.txt";
$objComport->Device = "COM1";
$objComport->Baudrate = 9600;
$objComport->ComTimeout = 1000;
$objComport->Open ();
if ( $objComport->LastError == 0 )
{
Echo "Sending 'ATZ'...<BR>";
Echo "<BR>";
$objComport->WriteString ( "ATZ" );
while ( $objComport->LastError == 0 )
{
Echo $objComport->ReadString ();
Echo "<BR>";
}
Echo "Sending 'ATI'...<BR>";
Echo "<BR>";
$objComport->WriteString ( "ATI" );
while ( $objComport->LastError == 0 )
{
Echo $objComport->ReadString ();
Echo "<BR>";
}
Echo "Sending 'AT&C0'...<BR>";
Echo "<BR>";
$objComport->WriteString ( "AT&C0" );
while ( $objComport->LastError == 0 )
{
Echo $objComport->ReadString ();
Echo "<BR>";
}
}
else
{
$ErrorNum = $objComport->LastError;
$ErrorDes = $objComport->GetErrorDescription ( $ErrorNum );
Echo "Error sending commands: #$ErrorNum ($ErrorDes).";
}
Echo "Ready.";
$objComport->Close ();
?>
<br>
<br>
<hr size="1" color="#707070">
<font size="1" face="Verdana">This demo uses ActiveXperts ActiveComport</font>
</body>
</html>
There are many working samples included with the product. You can also find them on the ActiveXperts FTP site: ftp.activexperts-labs.com/samples/activecomport.