ActiveComport

 Product Overview

 How to use

 Online Samples

 Download (.exe)

 Brochure (.pdf)

 Manual (.htm)

 Release Notes

 Case Studies:
 


Support

 Knowledge Base

 Forum

 Contact Support


Purchase

 Licensing

 Pricing

 Order now


Related documents

 Case study: Using
 ActiveComport to send
 SMS's (by Sorceress
 Entertainment)


 AT commands

 Serial Communication
 Tutorials



  Download ActiveComport Serial Port Toolkit 3.1  (3008 KB - .exe file)
  Download Manual  (118 KB - .htm file)


Using ActiveComport Serial Port Toolkit with ASP .NET (C#)


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.NET environments.
This document describes how ActiveComport can be integrated into into ASP .NET (C#) projects.


Prerequisites

You must install and configure Internet Information Services (IIS) before using the ActiveComport Toolkit with ASP .NET
If you don't have IIS installed, use the following steps:
  • From the Control Panel, click 'Add/Remove Programs'. Select the 'Add/Remove Windows Components' icon from the left pane, then select 'Application Server' and click on 'Details'. You can now select both 'ASP .NET' and 'Internet Information Services (IIS)'. Click 'OK' to continue installation;
  • Make sure that ASP .NET is allowed on the web server:


    (Click on the picture to enlarge)



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 a new ASP .NET C# Project

Launch Microsoft Visual Studio (for instance 'Microsoft Visual Studio 2005') from the Start menu. Choose 'New' from the 'File' menu and click on 'Web Site'. In the 'Web Site' dialog, select ASP .NET Web Site. Select a name for the application (for instance: 'DemoApp') and a name for the solution (for instance: 'DemoSolution'). Also, select the directory where you want to store the project (for instance: 'C:\MyProjects):

    
    (Click on the picture to enlarge)



Step 3: Refer to the ActiveComport Library and create the objects

Now that a new project has been created, you must add a reference to the ActiveComport toolkit in the project to be able to use the ActiveComport object. To do so, choose 'Add Reference...' from the 'Project' menu. In the 'Add Reference' dialog that pops up, select the 'COM' tab and select the 'ActiveComport 2.2 Type Library' as shown in the following picture:

    
    (Click on the picture to enlarge)

Click 'OK' to close the 'Add Reference' dialog.

On top of your code, type the following line to use the ActiveComport namespace:
   using ACOMPORTLib;
In your Main function, declare and create the following object:
   public ComPort m_objComport;

   m_objComport = new ComPort();


Step 4: Send an AT command to a Hayes compatible modem

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

The following code shows how to query a modem:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using ACOMPORTLib;

namespace WebApplication
{
	/// <summary>
	/// Summary description for WebForm1.
	/// </summary>
	public class WebForm1 : System.Web.UI.Page
	{
		public ComPort m_objComport;
		protected System.Web.UI.HtmlControls.HtmlInputText textCommand;
		protected System.Web.UI.HtmlControls.HtmlTextArea textResponse;
		protected System.Web.UI.HtmlControls.HtmlTextArea textResult;
		protected System.Web.UI.HtmlControls.HtmlSelect comboDevice;
		protected System.Web.UI.HtmlControls.HtmlForm Form1;
		protected System.Web.UI.WebControls.Button Button1;
		
		private void Page_Load(object sender, System.EventArgs e)
		{
			int i;

			m_objComport = new ComPort();

			comboDevice.Items.Clear ();

			for( i = 0; i < m_objComport.GetDeviceCount (); i++ )
			{
				comboDevice.Items.Add( m_objComport.GetDevice ( i ) );
			}
			
			for( i = 1; i < 9; i++ )
			{
				comboDevice.Items.Add( "COM" + i.ToString () );
			}
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.Button1.Click += new System.EventHandler(this.Button1_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void Button1_Click(object sender, System.EventArgs e)
		{
			m_objComport.Device = comboDevice.Value.ToString ();
			m_objComport.BaudRate = 9600;
			m_objComport.ComTimeout = 500;

			m_objComport.LogFile = "C:\\ComLog.txt";

			m_objComport.Open ();
 			m_objComport.HardwareFlowControl = -1;

			textResult.Value = "ERROR " + m_objComport.LastError + " : " + m_objComport.GetErrorDescription ( m_objComport.LastError );

			if  ( m_objComport.IsOpened == -1 )
			{
				m_objComport.WriteString ( textCommand.Value );

				textResponse.Value = "";

				while ( m_objComport.LastError == 0 )
				{
					textResponse.Value += m_objComport.ReadString () + "\n";
				}

				m_objComport.Close ();
			}
		}
	}
}
There are many working samples included with the product. You can also find them on the ActiveXperts FTP site: ftp.activexperts-labs.com/samples/acomport.


NOTE: Demo Projects are created with Microsoft Visual Studio 2002

The project ships with a set of Microsoft Visual Studio .NET samples, including samples for Microsoft ASP .NET C#. The projects are created with Microsoft Visual Studio 2002.
Users with a later version of Microsoft Visual Studio can open such a project. The Visual Studio Conversion Wizard will guide you through the process of converting the project to the version used.






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.

Copyright ©1999-2007 ActiveXperts Software. All rights reserved.