Download ActiveComport Serial Port Toolkit 3.1  (3008 KB - .exe file)
Download Manual  (118 KB - .htm file)
Using ActiveComport Serial Port Toolkit with with ASP.NET (Visual Basic)
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 .NET environments.
This document describes how ActiveComport can be integrated into into ASP.NET projects.
Prerequisites
You must install and configre 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 ActiveComport from the ActiveXperts Download Site and start the installation.
The installation guides you through the installation process.
Step 2: Create a new ASP .NET VB 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 library 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:
Imports ACOMPORTLib
In your Main function, declare and create the following object:
Dim objComport As ComPort
objComPort = New ComPort()
Step 4: Send an AT command to a Hayes compatible modem
You can now send and/or receive data to and/or from a serial interface.
The following code shows how to query a modem:
Public Class WebForm1
Imports ACOMPORTLib
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents comboDevice As System.Web.UI.HtmlControls.HtmlSelect
Protected WithEvents textCommand As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents textResponse As System.Web.UI.HtmlControls.HtmlTextArea
Protected WithEvents textResult As System.Web.UI.HtmlControls.HtmlTextArea
Protected WithEvents Form1 As System.Web.UI.HtmlControls.HtmlForm
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
InitializeComponent()
End Sub
#End Region
Public m_objComPort As ComPort
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As System.Int32
m_objComPort = New ComPort()
comboDevice.Items.Clear()
For i = 0 To m_objComPort.GetDeviceCount - 1
comboDevice.Items.Add(m_objComPort.GetDevice(i))
Next
For i = 1 To 8
comboDevice.Items.Add("COM" + i.ToString())
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim LastError
m_objComPort.Device = Request.Form(comboDevice.UniqueID)
m_objComPort.BaudRate = 9600
m_objComPort.ComTimeout = 500
m_objComPort.LogFile = "C:\ComLog.txt"
m_objComPort.Open()
LastError = m_objComPort.LastError
If (LastError = 0) Then
textResult.Value = "SUCCESS"
Else
textResult.Value = "ERROR " & LastError & " ( " & m_objComPort.GetErrorDescription(LastError) & " )"
End If
If (m_objComPort.IsOpened = -1) Then
m_objComPort.WriteString(textCommand.Value)
textResponse.Value = ""
While (m_objComPort.LastError = 0)
textResponse.Value += m_objComPort.ReadString() + vbCrLf
End While
m_objComPort.Close()
End If
End Sub
End Class
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 ActiveComport project ships with a set of Microsoft Visual Studio .NET samples, including samples for Microsoft ASP .NET (Visual Basic).
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.
|