Download ActiveComport Serial Port Toolkit 3.1  (3008 KB - .exe file)
Download Manual  (118 KB - .htm file)
Using ActiveComport Serial Control with PHP
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.
Step 1: Download and install ActiveComport
Download the ActiveComport Toolkit from the ActiveXperts Download Site and start the installation.
The installation guides you through the installation process.
Step 2: Create the ActiveComport object in PHP
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" );
Step 3: Send AT commands from a PHP script
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.
The ActiveComport tool is COM port development component (SDK). This control can be used by any Windows development platform,
including Visual Basic .NET, Visual CSharp .NET,
ASP .NET (VB,CS),
ASP,
Visual Basic,
Visual Studio/Visual C++,
Borland Delphi and
C++ Builder,
PHP,
VBA (Visual Basic for Applications),
ColdFusion,
HTML,
VBScript and any other ActiveX/COM compliant platform. The ActiveComport Toolkit is an ActiveXperts Software B.V. Product.
|