Download ActiveComport Serial Port Toolkit 3.1  (3008 KB - .exe file)
Download Manual  (118 KB - .htm file)
Using ActiveComport Serial Port Toolkit with Borland C++ Builder
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 Borland C++ Builder environments.
This document describes how the ActiveComport Toolkit can be integrated into Borland C++ Builder projects.
Step 1: Download and install the ActiveComport Toolkit
Download the ActiveComport from the ActiveXperts Download Site and start the installation.
The installation guides you through the installation process.
Step 2: Create a new C++ Builder Project
Launch Borland C++ Builder (for instance 'Borland C++ Builder 6') from the Start menu.
Choose 'New' from the 'File' menu and select 'Application'.
A new Form is displayed in the workspace.

(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 ActiveComport in the project to be able to use the ActiveComport object.
To do so, choose 'Import Type Library...' from the 'Project' menu. The Import Type Library' dialog appears.

(Click on the picture to enlarge)
In the upper selection box, select 'ActiveComport 3.0 Type Library' and click 'Create Unit':
The interface code is generated now and is shown in the ACOMPORTLib_TLB.cpp and ACOMPORTLib_TLB.h tab of the project.
Step 4: Declare and create the object
From the Project Manager, open Unit1.h and add include the ACOMPORTLib_TLB.h file to refer to the ActiveComport library:

(Click on the picture to enlarge)
In the 'private' or 'public' section, declare the following objects:
TCOMIComPort Comport;
You can now create the objects, for instance in the 'FormCreate' event handler or the class constructor:
Comport = CoComPort::Create ();
Step 5: Send an AT command to a connected Hayes compatible modem
You can now send and/or receive data to and/or from a serial port.
The following code shows how to query a modem:
//---------------------------------------------------------------------------
#include
#pragma hdrstop
#include "Main.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Comport = CoComPort::Create ();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ButtonOpenClick(TObject *Sender)
{
Comport->set_Device( WideString ( EditDevice->Text ) );
Comport->set_BaudRate( ComboBoxBaudrate->Text.ToInt() );
Comport->set_ComTimeout( 1000 );
Comport->Open();
EditResult->Text = Comport->GetErrorDescription(Comport->LastError);
EnableControls ();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
ComboBoxBaudrate->Items->Add ( "300" );
ComboBoxBaudrate->Items->Add ( "1200" );
ComboBoxBaudrate->Items->Add ( "2400" );
ComboBoxBaudrate->Items->Add ( "4800" );
ComboBoxBaudrate->Items->Add ( "9600" );
ComboBoxBaudrate->Items->Add ( "19200" );
ComboBoxBaudrate->Items->Add ( "38400" );
ComboBoxBaudrate->Items->Add ( "57600" );
ComboBoxBaudrate->Items->Add ( "115200" );
ComboBoxBaudrate->ItemIndex = 8;
EnableControls ();
}
//---------------------------------------------------------------------------
void TForm1::EnableControls ()
{
if ( Comport->IsOpened )
{
ButtonOpen->Enabled = FALSE;
ButtonClose->Enabled = TRUE;
ButtonSend->Enabled = TRUE;
}
else
{
ButtonOpen->Enabled = TRUE;
ButtonClose->Enabled = FALSE;
ButtonSend->Enabled = FALSE;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ButtonCloseClick(TObject *Sender)
{
Comport->Close();
EditResult->Text = Comport->GetErrorDescription(Comport->LastError);
EnableControls ();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
if ( Comport->IsOpened )
{
wchar_t * pwszTemp = Comport->ReadString();
if ( wcslen ( pwszTemp ) )
{
EditResponse->Lines->Add( pwszTemp );
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ButtonSendClick(TObject *Sender)
{
Comport->WriteString( WideString ( EditCommand->Text ) );
EditResult->Text = Comport->GetErrorDescription(Comport->LastError);
EnableControls ();
}
//---------------------------------------------------------------------------
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 Borland C++ Builder 6
The ActiveComport project ships with a set of samples for Borland C++ Builder.
The projects are created with Borland C++ Builder 6.
Users with a later version of Borland C++ Builder 6 can open such a project. The Borland 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.
|