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

Quicklinks


Using ActiveComport Toolkit with ASP 2.x

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 ASP environments.

This document describes how ActiveComport can be integrated into ASP projects.

Step 1: Download and install ActiveComport

Download ActiveComport from the ActiveXperts Download Site and start the installation. The installation guides you through the installation process.

Step 2: Create a new Web Site

First, create a new directory on the IIS Server's file system. This directory will hold the ASP later on.

From the 'Start menu', click on 'Administrative Tools' and click on 'Internet Information Services (IIS) Manager'. Right-click on the 'Web Sites' container and choose 'New->Web Site':

ASP

(Click on the picture to enlarge)

The 'Web Site Creation Wizard' is shown, guiding you thorugh the process of creating a new web site. Provide all necessary information:

  • Description - a friendly description of the new site;
  • IP / Port / Host Header - choose your preferred way to distinguish between other web sites on the server;
  • Path - select the directory that will store the ASP file(s);
  • Web Site Access Permissions - in the Web Site Access Permissions dialog, enable 'Read' and 'Run scripts (such as ASP)';

You're now able to write an ASP script to send/receive e-mail using ActiveComport.

Step 3: Create the ActiveComport object in ASP

Create a new ASP script called DEFAULT.ASP in the directory that was created in Step2, using your favorite editor. On top of the ASP code, insert the following lines to declare and create the ActiveComport object:

   <object runat=server progid="ActiveXperts.ComPort" id=objComPort></object>

Step 4: Test a small piece of ASP

Now, test if your new web site is working well with ActiveComport using your browser. If you are using Microsoft Internet Explorer, it is recommended to disable friendly error message because this default setting doesn't show any ASP error message, making it hard to debug if there are any problems:

  • Choose' Internet Options' from the 'Tools' menu;
  • Select the 'Advanced' tab;
  • In the 'Browsing' folder, de-select the 'Show friendly HTTP error messages' option;
  • Click 'OK' to close the dialog.

Now, use the following piece of code in your DEFAULT.ASP page:

   <object runat=server progid="ActiveXperts.ComPort" id=objComPort ></object>
   <html>
   <head>
      <title>ActiveComport Demo</title>
   </head>
   <body>
      ActiveComport version: <% = objComport.Version %><br>
      ActiveComport expiration date: <% = objComport.ExpirationDate %>
   </body>
   </html>

And test it with your favorite browser. The result should be like this:

ASP

(Click on the picture to enlarge)

Step 5: Send an AT command to a connected modem

You can now send and/or receive data to/from the serial port.

The following ASP code shows how to query a modem:

<html>
    <body>
    <font face="sans-serif" size="2">
    <hr size="1" color="707070">
    <b><font size="4">ActiveXperts ActiveComport ASP Sample</font></b>
    <br>
    <br>
    <b>Query a modem connected to your webserver ( via Serial Port, USB or Bluetooth ).</b>
    <br>
    <br>
    <hr size="1" color="707070">
    <br>
    <form action="default.asp" method="post">
    <table>
        <tr>
            <td width="100">Device:</td>
            <td>
                <select size="1" name="NUM_PORTID">
                    <option selected>COM1</option>
                    <option>COM2</option>
                    <option>COM3</option>
                    <option>COM4</option>
                </select>
            </td>
        </tr>
        <tr>
            <td>Baudrate:</td>
            <td>
                <select size="1" name="NUM_BAUDRATE" >
                    <option selected>Default</option>
                    <option>110</option>
                    <option>300</option> 
                    <option>600</option>
                    <option>1200</option>
                    <option>2400</option> 
                    <option>4800</option>
                    <option>9600</option>
                    <option>14400</option> 
                    <option>19200</option>
                    <option>38400</option>
                    <option>56000</option>
                    <option>57600</option>
                    <option>115200</option>
                </select>
            </td>
        </tr>
        <tr>
            <td>Command1:</td>
            <td><input size=25 type=text name="STR_CMD1" value="ATZ"></td>
        </tr>
        <tr>
            <td>Command2:</td>
            <td><input size=25 type=text name="STR_CMD2" value="ATE0"></td>
        </tr>
        <tr>
            <td>Command3:</td>
            <td><input size=25 type=text name="STR_CMD3" value="ATI"></td>
        </tr>
    </table>
    <br>
    <br>
    <input type="submit" value="Submit Commands" name="BUTTON_SUBMIT">
    <br>
    <br>
</form>
</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.