SuperCom - The Data Communication Library

-- A programmers introduction to some of the SuperCom concepts --

SuperCom offers a rich set of APIs that can be used to setup data connections and transfer data or files.

There is always the 'direct API' (calling the native SuperCom functions directly) but also wrappers like the ActiveX control, C++ class CSuperCom, Delphi / Pascal class TSuperCom or the NET class TSCom (imitates the ActiveX) and other. You select the one that fits best to your environment and compiler language.

Many samples, showing the API, are available. In this section we will present the most used functions for establishing a data connection with SuperCom.

Data Communications protocol library, serial driver. One API for Serial communication or TCP/IP communication.

Connection Index

In order to setup and control a connection (data link) using SuperCom one usually has to define a 'communication-index'. Every connection, SuperCom handles, uses a unique communication-index. Nearly every function in the SuperCom API expects this index as it's first parameter. This index can also be considered as a 'handle' and is often declared as the variable Com within a program.

When using some classes the communication-index seems to disappear but it's always there. Even when a connection was setup without the need to provide one, SuperCom will allocate one.

When using serial ports the connection-index is hard-wired to a specific serial port. Thus the index 'COM_1' is connected to the first serial port in the system e.g. under Windows it is the "COM1". The index 'COM_2' would connect to "COM2" etc. When using connection over TCP, TAPI, ISDN etc. there exist no such relation and every available index between COM_1 and COM_255 can be used.

A software developer can define the index to use manually although SuperCom offers functions to check for available communication-index (data link) e.g. ComValid and also offers functions (e.g. ComPortPresent) in order to query for available serial ports, TAPI devices etc.

Setup a data connection

The following short samples show the most frequently used APIs when setting up a connection with SuperCom.

Calling the native SuperCom API directly

C/C++

  TCOMMID Com = COM_2;  // Communication index, e.g. using serial port COM2
  char *Msg = "Hello World";

  ComInit(Com);

  ComSetState(Com, 57600, 8, 1, 'N', SIGNAL_CTS);

  RS_TXPacket(Com, Msg, strlen(Msg), &Result);

  ComReset(Com);

  C/C++    C#    Delphi    Java    Visual Basic

 

Let's explain the above lines a bit:
The function ComInit instructs SuperCom to assign the second data link (e.g. the second serial port on Windows "COM2", on Linux "ttyS1"). ComSetState applies the communication parameters and flow control. Now the connection is ready to transfer data. The function RS_TXPacket transmits the data packet Msg through the data link (e.g. serial interface) and ComReset finaly closes all actions on the data link and releases the used data link and the related hardware and software resources used.

 

Using alternative functions and class libraries (wrapper) created around the native SuperCom API

C/C++

       // Serial, TCP, ... - direct API
   TCOMMID Com = COM_2; // Communication index, e.g. using serial port COM2

ComInit (Com); ComSetState (Com, 9600, ...); // if Modem, TAPI, TCP, ISDN: RS_ConnectEx establishes connection RS_ConnectEx(Com,... );
: ComWriteEx(Com, STR_HELLO, strlen(STR_HELLO)); ch = ComRead(Com); : ComReset();
  C/C++    C#    Delphi    Java    Visual Basic

 

RS_OpenLink is a newer function that eases the setup of a connection since all the required configuration data can be provided using a string as parameter containing "name=value" pairs. There also exists special forms, in selected SuperCom protocol modules, like RS_S7OpenLink used to setup a connection to an S7 type plc.

A short list of the native SuperCom functions Serial and TCP data communication library function list

Another source of custom functions and classe are the many samples. Free to use in order to get it done faster.

 


Home    Back
Modified at:

ADONTEC