ActiveComport Toolkit Add serial communication capabilities to any Windows or .NET application

Quicklinks


Using ActiveComport Serial Port Toolkit with HTML forms on a client PC

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 features the following:

Direct COM port support (like 'COM1'), TAPI (Windows Telephony Device) support (like 'Standard 56000 bps Modem'), support for RS-232/RS422/RS485, up to 256 simultaneous ports, support for all types of Hayes compatible modems, support for serial cable, USB cable or Bluetooth connections, support for GSM/GPRS modems, support for Virtual COM ports (i.e. COM ports redirected through the network), hardware flow control (RTS/CTS, DTR/DSR), software flowcontrol (XON/XOFF), configurable baudrate/parity/stopbits, full buffered data transfer, text/binary data transfer.

ActiveComport can be well integrated into HTML/Javascript environments.

This document describes how the ActiveComport Toolkit can be integrated into HTML projects.

Step 1: Installation of ActiveComport

When using HTML, there are two ways to install the ActiveComport Toolkit on a client PC:

  • Automatically using HTML code;
  • Using the ActiveComport Toolkit InstallShield installation.

Automatic installation using HTML code

You can install the ActiveComport Toolkit automatically using the following HTML code on top of the HTML page:

<head>
  <object id="objComport" codeBase="http://www.activexperts.com/files/serial-port-component/acomport.dll"
		  classid="CLSID:07ECB42B-322A-40B9-A8A9-3815AF3C4F60" viewastext></object>
</head>

The ActiveComport Toolkit will be installated automatically. The user will be asked to confirm the installation, because the DLL is coming from an untrusted site (www.activexperts.com).

There are two ways to avoid prompting:

  • Add the ActiveX/COM location to the user's trusted sites. You can manage trusted manually (by using the Internet Explorer), through a logon script (by appyling the registry change from the logon script) or by using Active Directory Group Policies;
  • OR use a trusted location for the DLL. For instance your Intranet site, because most probably this site has already been added to the list of trusted sites for all users.

Manual installation using the ActiveComport Toolkit installation procedure

On each client PC, 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 HTML

You must use Javascript to declare and create the objects.

Use the following Javascript code to declare and create the object:

var objComport;
 
objComport  = new ActiveXObject ( "ActiveXperts.ComPort" );

Step 3: Send an AT command to a connected Hayes compatible modem

You can now send and/or receive data to and/or from a serial device.

The following HTML code shows how to query a modem:

<html>
	<head>
		<object id="objComport" height="30" width="200" classid="CLSID:07ECB42B-322A-40B9-A8A9-3815AF3C4F60" viewastext>
		</object>
	</head>
	<body onload="ListDevices()">
		<script language="JavaScript">

    function Send ()
    {
      objComport.Device              = comboDevice.options [ comboDevice.selectedIndex].text
      objComport.Speed               = 9600
      objComport.ComTimeout          = 500
      objComport.LogFile             = "C:\ComLog.txt"
      objComport.HardwareFlowControl = objComport.asFLOWCONTROL_DEFAULT

      objComport.Open()

      textResult.value = "Result: " + objComport.LastError + " (" + objComport.GetErrorDescription ( objComport.LastError ) + ")";

      if( objComport.IsOpened == -1 )
      {
         objComport.WriteString( textCommand.value );

         textResponse.value = ""

         while( objComport.LastError == 0 )
         {
            textResponse.value += objComport.ReadString () + "\n";
         }
      }
     
      objComport.Close ()
    }

    function ListDevices ()
    {	
      nCount  = objComport.GetDeviceCount ();

      for ( i = 0 ; i < nCount ; i++ )
      {
        comboDevice.options [ i ] = new Option ( objComport.GetDevice ( i ), "" );
      }

      for ( i = 1 ; i < 9 ; i++ )
      {
        comboDevice.options [ i + nCount - 1 ] = new Option ( "COM" + i , "" );
      }
    }

		</script>
		<font face="sans-serif" size="2">
			<hr size="1" color="#707070">
			<b><font size="4">ActiveXperts ActiveComport HTML Sample</font></b><br>
			<b>
				<br>
				Query a modem connected to your PC (COM port, USB or Bluetooth).<br>
				<br>
				<br>
				<hr size="1" color="#707070">
				<br>
				<table border="0" bgcolor="#f0f0f0" ID="Table1">
					<tr>
						<td width="120" valign="top">Device Name:</td>
						<td width="450">
							<select size="1" name="comboDevice" ID="Select1">
							</select>
						</td>
					</tr>
					<tr>
						<td valign="top">Command:</td>
						<td>
							<input size="50" type="text" name="textCommand" value="ATI" ID="Text1"><br>
							<br>
						</td>
					</tr>
					<tr>
						<td valign="top">Response:<br>
						</td>
						<td>
							<textarea rows="10" name="textResponse" cols="63" ID="Textarea1"></textarea>
						</td>
					</tr>
					<tr>
						<td vAlign="top">Result:</td>
						<td>
							<textarea rows="1" name="textResult" cols="63" id="Textarea2"></textarea>
						</td>
					</tr>
				</table>
				<br>
				<input type="button" onclick="Send()" value="Submit">  <b>IMPORTANT:</b>
				Please press the button <b>only once</b>, and allow some time for the 
			command to be processed </font>
		<br>
	</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/serial-port-component.