Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

titleOverview

This manual describes the various I/O drivers available for the Tsentry system. Both W32 and RTSS versions of most of the drivers are available.

Supported drivers include the following:

  • Allen Bradley PLC 2, PLC 3, and PLC 5

  • Nattional Instruments Process I/O controllers

  • GE 9030 / 9070 PLC

  • TCP/IP Generic Driver

  • Lantronix Terminal Server

  • Generalized Remote Device Connection Driver

  • Allen-Bradley Control Logic PLC

...

Allen-Bradley Process I/O Server

...

Expand
titleSoftware Driver

The core of the driver is provided as a C++ class that implements the initialization and communications functions.  A sample process is provided which calls the appropriate class members.

The IP address, configuration information, and data areas to be read and written are passed as calling parameters to the class functions.

The following is a list of the provided driver files.  After review of the example driver, the user is required to modify the files as indicated:

File Name

Description

Modifications

ABPlc.cpp

Driver mainline function

Modify configuration class calls for specific PLC configuration.  Modify locations to read and write data.  Modify input and output datagram structure definition

ABPlcIn.cpp

ABPlc driver initialization

Insert required global common areas. 

PlcUsr.cpp

Process received values from PLC datagram and place in user data variables.

Get application variables and store in datagra for transmission to PLC

Change as required

...

TpriABPlc Class Descriptions

Summary -
Expand
titleClass Inferface
Info
Overview

The Tsentry tpriABPlc class encapsulates the functionality required to communicate with the Allen Bradley PLC 2, PLC3, and PLC5 PLCs over a TCP/IP network.

Expand
titleClass Inferface

The following public member functions are provided as part of the tpriABPlc class:

  • tpriABPlc *pABPlc = new tpriABPlc;

    • Allocate a new tpriABplc object

  • destroy (tpriABPlcPlc *)pABPlc();

    • Destroy the tpriABPlc class object.

  • int Config (char *pHostName, int timeout);

where:

char *pHostName= host name or IP address

int timeout = time value for read and write operation in milliseconds

This function stores new configuration information for use by class functions

  •  int GetConnStatus (void);

where:

return status = connection status

                        0 = unconnected

1 = connected

This function returns the status of the connection between the Compute system and the PLC

  • int SetReadFile(char *file, int offset, int num);
    where:
    char *file = PLC file name from which to read data
    int offset  = byte offset from start of ‘filename’ from which to read data
    int num = number of data items to read

This function stores the PLC read control information for use by the ScanIO class member

  • int SetWriteFile(char *file, int offset, int num);
    where:
    char *file = PLC file name where to write data
    int offset  = byte offset from start of ‘filename’ to write data
    int num = number of data items to write

This function stores the PLC read control information for use by the ScanIO class member

  •  int Connect (void);

This function establishes a connection between the computer system and the PLC

  •  int Disconnect (void);

This function breaks a connection between the computer system and the PLC

  •  int ScanIO (int *igram, int *ogram, int *ipsta);

where:
int *igram = user memory address where PLC read data will be returned

int *ogram = user memory address where PLC write will be obtained

int *ipsta = addr of an integer variable where I/O status will be returned

This function first reads a single data block of 16 bit integers values from the PLC user register memory and then writes a block of 16 bit integers to the PLC memory.  The plc locations for the read and write are obtained from prior calls to the SetReadFile90 and SetWriteFile() functions.

Expand
titleProcess Driver Mainline

Some comments on the driver program below:

  • This test program, on each expiration of the process timer, writes a single block of data to the PLC and then reads a single block of data.  This sequence, the number of reads and writes, their addresses, and the sizes of the blocks can be modified to fit the requirements of the application.

  • PlcUsr and the ‘datagram’ structures they reference should be modified as required to reference appropriate variables in application variables for transfer between the PLC and the control system.

  • A sample driver is provided in the examples subdirectories of the standard Tsentry distribution

National Instruments Process I/O Driver

Expand
titleCapabilities
  • Handles National Instruments E-Series Boards

  • Direct program control over all I/O

  • Process I/O includes

    • 12-bit A/I channels

    • 12-bit A/O channels

    • Digital Inputs

    • Digital Outputs

  • High Speed bus access

    • A/I at 300KHZ sample rate

  • Software implemented as a C++ Class

  • Capable of running 1ms Input and Output scan rep rates

...

Expand
titleRTP 6700 Configuration

The RTP 6700 controller requires a set of configuration parameters for proper operation.  To configure the 6700, connect the console port of the 6700 to a terminal or a PC running a terminal emulator (such as HyperTerminal).  Terminal characteristics are 9600, 8, None, 1.  Switch on the power to the 6700 and enter a “3” to the first prompt  after power up.  The following is an example of reasonable configuration process and parameters for the RTP 6700 controller:

Code Block
A:\>echo off

Datalight is a registered trademark of Datalight, Inc.

CardTrick is a registered trademark of Datalight, Inc.

ROM-DOS is a trademark of Datalight, Inc.

Copyright 1989-1994 Datalight, Inc., All Rights Reserved

Bad command or filename

Loading the Ethernet Packet Driver

smc9192 0x62 0x7 0x300 0x604 ...

Current settings follow :

Twisted pair interface, using select # 2 for interrupt & 6 packets reserved for Tx

My Ethernet address is 00:80:F9:03:04:EC

***********************************************

RTP Corp.                                   *

Pompano Beach, Florida.                     *

Ethernet IO Bus Controller Version F.0.0    *

***********************************************
Code Block

************************
PROTOCOL=TCP
LINK=ETHERNET
MAX_CONNECTIONS=1
CONNECTION_TIMEOUT=3
SERVICE_ACCESS_POINT=0
IP_ADDRESS=89.89.89.121
SUBNET_MASK=255.0.0.0
CMD_BUF_SIZE=1464
RESP_BUF_SIZE=1464
BAUD_RATE=38400 BPS
MESSAGE_TRACE=OFF
MAX_TRACE_BUFF_SIZE=1
CONNECTION_WIRING=TWISTED
************************
1.- Revert Back to Default Configuration
2.- Continue with Saved Configuration
3.- Modify Configuration

No input is necesary, if no change is desired

3

Select Protocol:
[Current - 1] [Default - 0]
0 <Enter> - UDP
1 <Enter> - TCP
2 <Enter> - 802.2
<Enter>   - Keep Current Value
<Esc>     - Exit Configuration without Saving
S<Enter>  - Save Configuration

Selection: 0

Select Link:
[Current - 0] [Default - 0]
0 <Enter> - ETHERNET
1 <Enter> - SERIAL
<Enter>   - Keep Current Value
<Esc>     - Exit Configuration without Saving
S<Enter>  - Save Configuration

Selection: 0

Enter Maximum Number of Connections (1 - 4):
[Current - 1] [Default - 1]
<Enter>   - Keep Current Value
<Esc>     - Exit Configuration without Saving
S<Enter>  - Save Configuration

Selection: 1

Enter the Connection Timeout (0 - 600 seconds):
[Current - 3] [Default - 3]
<Enter>   - Keep Current Value
<Esc>     - Exit Configuration without Saving
S<Enter>  - Save Configuration

Selection: 3

Enter the Service Access Point (SAP) (0 - 254 even only):
[Current - 0]
<Enter>   - Keep Current Value
<Esc>     - Exit Configuration without Saving
S<Enter>  - Save Configuration

Selection: 0

Enter the IP Address (dotted decimal notation e.g. 255.2.3.3):
[Current - 89.89.89.121]
10.0.0.2

Enter the Subnet Mask (dotted decimal notation e.g. 255.0.0.0):
[Current - 255.0.0.0]
255.0.0.0

Enter the Command Buffer Size (1464 - 32727):
[Current - 1464] [Default - 1464]
<Enter>   - Keep Current Value
<Esc>     - Exit Configuration without Saving
S<Enter>  - Save Configuration

Selection: 1464

Enter the Response Buffer Size (1464 - 32727):
[Current - 1464] [Default - 1464]
<Enter>   - Keep Current Value
<Esc>     - Exit Configuration without Saving
S<Enter>  - Save Configuration

Selection: 1464

Select Baud Rate:
[Current - 2] [Default - 2]
0 <Enter> - 9.60  KBPS
1 <Enter> - 19.2  KBPS
2 <Enter> - 38.4  KBPS
3 <Enter> - 57.6  KBPS
4 <Enter> - 115.2 KBPS
<Enter>   - Keep Current Value
<Esc>     - Exit Configuration without Saving
S<Enter>  - Save Configuration

Selection: 0

Select Trace:
[Current - 0] [Default - 0]
0 <Enter> - OFF
1 <Enter> - ON
<Enter>   - Keep Current Value
<Esc>     - Exit Configuration without Saving
S<Enter>  - Save Configuration

Selection: 0

Enter the Trace Buffer size (1-63 KBytes):
[Current - 1] [Default - 1]
<Enter>   - Keep Current Value
<Esc>     - Exit Configuration without Saving
S<Enter>  - Save Configuration

Selection: 1

Select the Connection Wiring
[Current - 1] [Default - 0]
0 <Enter> - COAX
1 <Enter> - TWISTED
<Enter>   - Keep Current Value
<Esc>     - Exit Configuration without Saving
S<Enter>  - Save Configuration

Selection: 1

Configuration Complete.

************************
PROTOCOL=UDP
LINK=ETHERNET
MAX_CONNECTIONS=1
CONNECTION_TIMEOUT=3
SERVICE_ACCESS_POINT=0
IP_ADDRESS=10.0.10.11
SUBNET_MASK=255.0.0.0
CMD_BUF_SIZE=1464
RESP_BUF_SIZE=1464
BAUD_RATE=9600 BPS
MESSAGE_TRACE=OFF
MAX_TRACE_BUFF_SIZE=1
CONNECTION_WIRING=TWISTED
************************

Enter Y to Accept Configuration, N to Modify it

Y

EIOBC Ethernet Address: 00-80-F9-03-04-EC

After the configuration is accepted, it will be stored on the controller.  Cycling the power on the card will initialize the card to use these parameters.

Expand
titleRTP Initialization file

The following is an example of a operational RTP initialization file.  It describes a system with 16 Analog inputs input (1 A/D card and 2 mux cards), 4 Digital input cards (64 bits), 32 Analog output channels (8 cards),and 4 digital dgital output cards (64 bits) in two (2) RTP chassises.  The RTP 6700 is set up for IP address 10.0.10.11

Code Block
# ---------------------------------------------------------------------------

#   Cold Mill RTP Control Table

#

#   This table defines the configuration information for the

#      RTP (Real Time Products) Process I/O system

#   It assumes connection via an Ethernet network and a RTP 6700 interface

#

#   Section [SYSTEM] defines system wide parameters

#   Section [AI] defines Analog Inputs

#   Section [AO] defines Analog Outputs

#   Section [DI] defines Digital Inputs

#   Section [DO] defines Digital Outputs

#

# --------------------------------------------------------------------------------------

#

[SYSTEM]

#   IPAddr:  IP address of 6700 controller

#   #AI:     Number of AI channels

#   #AO:     Number of AO channels

#   #DI:     Number of DI cards

#   #DO:     Number of DO cards

#

#IPAddr      #AI #DI #AO #DO

10.0.10.11   16   4   8   4    

#

[AI]

#

# Define analog input scan list

    16

#

# Field Definitions

#

#   CORR_ID:     Correlation ID.  A 32 bit number that is transmitted to the

#                eiobc and returned from the eiobc for each I/O point.
#      #                         Usually numbered sequentially.

#

#   TYPE:        An 8 bit number that defines the type of I/O to be performed.

#                There are currently four (4) types of I/O that can be

#                performed with the eiobc:

#

#                     TYPE            DEFINITION

#                     ----         -------------------

#                      1           OUTPUT_BASIC

#                      2           OUTPUT_WITH_BIT_OPS

#                      3           INPUT_BASIC

#                      4           INPUT_WITH_BIT_OPS

#

#                The TYPE used for analog inputs is 3, INPUT_BASIC.

#

#   DEV_ADDRESS: Device address.  An 8 bit number that defines the RTP

#                device address (chassis address).  If the chassis address is

#                set to 0x31, the address used for this field should be 0x01.

#

#   OPTION:      A bit mask of options.  A 16 bit value that is used as a mask

#                to control I/O options.  For type 3 (INPUT_BASIC) I/O, the

#                options are defined as follows:

#
#                #                Bitit 15: Output command word contained in COMMAND

#                Bit 14: Check Test Return before writing output data

#                Bit 13: Wait DELAY number of microseconds for Test Return

#                        before output.  Only valid when Bit 14 is set.

#                Bit 12: Output data word contained in Output Data (OUT_DATA).

#

#                Bit 11: Check Test Return before reading input data.

#                Bit 10: Wait Delay number of microseconds for Test Return

#                        Only valid when Bit 11 set.

#                Bit 09: Perform an input operation and return data in

#                        response.  If this bit is not set, input is not

#                        performed and only POINT_STATUS is returned

#                        in response.

#                Bit 08: Perform a second input operation and return additional

#                        data in response.  Only valid if bit 09 is set.
#          #                                     If this bit is set and POINT_EXTENDED_INPUT return

#                        is used.

#                Bit 07: Replace the Output Data (OUT_DATA) with the value

#                        obtained from the second input operation for auto-

#                        ranging purposes.  Only valid if bit 08 is used.

#

#                The OPTION value for analog inputs is 0x9E00.

#

#   COMMAND:     Command to the iobc.  A 16 bit value that defines which

#                card in the chassis rack will be doing the analog

#                inputs.  A value of 0x0500 in COMMAND indicates that

#                there is a analog input card in logical slot 0

#                (physical slot 5) of the chassis.

#

#   OUT_DATA:    Output Data.  A 16 bit value that is used to tell the

#                analog input card which input channel to read.  Due

#                to the delay in reading sequential channels on the

#                same analog input card, it may be desirable to sequence

#                through all the analog input cards, reading all the

#                channel 0's, then all the channel 1's, etc.

#

#                The card number and channel are defined as follows:

#

#                  bits  0 1 2 3   4 5 6 7  8 9 10 11  12 13 14 15

#                                    x x x  x y  y  y   z  z  z  z

#

#                    where   xxxx defines the card number.

#                             yyy defines the channel number.

#                            zzzz defines the gain (0= +-10volts)

#

#                These values go in the OUT_DATA field below

#

#   DELAY:       Delay value.  A 16 bit value indicating the amount of

#                time after which, if the card is not ready, an error is

#                returned.  Multiply us by 1.19 to get the proper delay.

#                A delay of 100 us == 100 * 1.19 = 119 (base 10) or

#                77 (base 16).

#

#                The DELAY value for analog inputs is typically 0x00FF.

#

#   AND_VAL:     A 16 bit value to logically AND with the output data

#                value (OUT_DATA).  This value is not used for analog

#                inputs but must be present.

#

#                The AND_VALUE value for analog inputs is 0x0000.

#

#   OR_VAL:      A 16 bit value to logically OR with the output data

#                value (OUT_DATA).  This value is not used for analog

#                inputs but must be present.

#

#                The OR_VALUE value for analog inputs is 0x0000.

#

#

#      DELAY is a HEX value indicating the number of microseconds to wait before

#     returning an error.  Multiply us by 1.19 to get the proper delay.  A delay

#     of 100 us == 100 * 1.19 = 119 (base 10) or 77 (base 16).

#

#

#     SC

#     LH

#     OA

#     TN

#

#CORR_ID   TYPE  DEV_ADDRESS  OPTION   COMMAND  OUT_DATA  DELAY(uS)   AND_VAL   XOR_VAL

#

 0000010      3    0x00       0x9E00    0x0500    0x0080    0x0077      0x0000   0x0000

 0000011      3    0x00       0x9E00    0x0500    0x0090    0x0077      0x0000   0x0000

 0000012      3    0x00       0x9E00    0x0500    0x00A0    0x0077      0x0000   0x0000

 0000013      3    0x00       0x9E00    0x0500    0x00B0    0x0077      0x0000   0x0000

 0000014      3    0x00       0x9E00    0x0500    0x00C0    0x0077      0x0000   0x0000

 0000015      3    0x00       0x9E00    0x0500    0x00D0    0x0077      0x0000   0x0000

 0000016      3    0x00       0x9E00    0x0500    0x00E0    0x0077      0x0000   0x0000

 0000017      3    0x00       0x9E00    0x0500    0x00F0    0x0077      0x0000   0x0000

#

 0000020      3    0x00       0x9E00    0x0500    0x0100    0x0077      0x0000   0x0000

 0000021      3    0x00       0x9E00    0x0500    0x0110    0x0077      0x0000   0x0000

 0000022      3    0x00       0x9E00    0x0500    0x0120    0x0077      0x0000   0x0000

 0000023      3    0x00       0x9E00    0x0500    0x0130    0x0077     0x0077      0x0000   0x0000

 0000024      3    0x00       0x9E00    0x0500    0x0140    0x0077      0x0000   0x0000

 0000025      3    0x00       0x9E00    0x0500    0x0150    0x0077      0x0000   0x0000

 0000026      3    0x00       0x9E00    0x0500    0x0160    0x0077      0x0000   0x0000

 0000027      3    0x00       0x9E00    0x0500    0x0170    0x0077      0x0000   0x0000

#

[AO]

# Define analog output scan list

      8

#

# Field Definitions

#

#   CORR_ID:     Correlation ID.  A 32 bit number that is transmitted to the

#                eiobc and returned from the eiobc for each I/O point.

#                Usually numbered sequentially.

#

#   TYPE:        An 8 bit number that defines the type of I/O to be performed.

#                There are currently four (4) types of I/O that can be

#                performed with the eiobc:

#

#                     TYPE            DEFINITION

#                     ----         -------------------

#                      1           OUTPUT_BASIC

#                      2           OUTPUT_WITH_BIT_OPS

#                      3           INPUT_BASIC

#                      4           INPUT_WITH_BIT_OPS

#

#                The TYPE used for analog outputs is 2, OUTPUT_WITH_BIT_OPS.

#

#   DEV_ADDRESS: Device address.  An 8 bit number that defines the RTP

#                device address (chassis address).  If the chassis address is

#                set to 0x31, the address used for this field should be 0x01.

#

#   OPTION:      A bit mask of options.  A 16 bit value that is used as a mask

#                to control I/O options.  For type 2 (OUTPUT_WITH_BIT_OPS) I/O,

#                the options are defined as follows:

#

#                Bit 15: Output command word contained in COMMAND

#                Bit 14: Check Test Return before writing output data

#                Bit 13: Wait DELAY number of microseconds for Test Return

#                        before output.  Only valid when Bit 14 is set.

#                Bit 12: Output data word contained in Process Scan List

#                        message.  If this bit is not set then no output

#                        word should be included in the Process

#                        Scan List.

#

#                The OPTION value for analog outputs is 0x9000.

#

#   COMMAND:     Command to the iobc.  A 16 bit value that defines which

#                card in the chassis rack will be doing the analog

#                outputs.  A value of 0x0505 in COMMAND indicates that

#                there is a analog output card in logical slot 5

#                (physical slot 10) of the chassis.

#                (Note: logical slot = physical slot - 5.)

#

#   OUT_DATA:    Output Data.  A 16 bit value that is used as output data

#                to the iobc.  This value is not used for analog outputs

#                but must be present.

#

#                The OUT_DATA value for analog outputs is 0x0000.

#

#   DELAY:       Delay value.  A 16 bit value indicating the amount of

#                time after which, if the card is not ready, an error is

#                returned.  Multiply us by 1.19 to get the proper delay.

#                A delay of 100 us == 100 * 1.19 = 119 (base 10) or

#                77 (base 16).

#

#                The DELAY value for analog outputs is typically 0x00FF.

#

#   AND_VAL:     A 16 bit value to logically AND with the output data

#                value in the Process Scan List command.  Only valid when

#                Options Bit 12 is set.  A value of 0x0FFF sends all 12

#                bits of the output value to the output channel.

#

#                The AND_VALUE value for analog outputs is 0x0FFF.

#

#   XOR_VAL:     A 16 bit value to exclusively OR with the results

#                obtained from ANDing the output value in the Process

#                Scan List command and the AND Value (AND_VAL).

#                Only valid when Options Bit 12 is set.  This value

#                represents the channel number (0-4) of the analog

#                output card.

#

#

#CORR_ID   TYPE  DEV_ADDRESS  OPTION   COMMAND  OUT_DATA  DELAY(uS)   AND_VAL   XOR_VAL

 0000001      2    0x00       0x9000    0x0507    0x0000    0x00FF      0x0FFF   0x0000

 0000002      2    0x00       0x9000    0x0507    0x0000    0x00FF      0x0FFF   0x4000

 0000003      2    0x00       0x9000    0x0507    0x0000    0x00FF      0x0FFF   0x8000

 0000004      2    0x00       0x9000    0x0507    0x0000    0x00FF      0x0FFF   0xC000

#

 0000005      2    0x00       0x9000    0x0508    0x0000    0x00FF      0x0FFF   0x0000

 0000006      2    0x00       0x9000    0x0508    0x0000    0x00FF      0x0FFF   0x4000

 0000007      2    0x00       0x9000    0x0508    0x0000    0x00FF      0x0FFF   0x8000

 0000008      2    0x00       0x9000    0x0508    0x0000    0x00FF      0x0FFF   0xC000

#

[DI]

# Define digital input scan list

               4

#

# Field Definitions

#

#   CORR_ID:     Correlation ID.  A 32 bit number that is transmitted to the

#                eiobc and returned from the eiobc for each I/O point.

#                Usually numbered sequentially.

#

#   TYPE:        An 8 bit number that defines the type of I/O to be performed.

#                There are currently four (4) types of I/O that can be

#                performed with the eiobc:

#

#                     TYPE            DEFINITION

#                     ----         -------------------

#                      1           OUTPUT_BASIC

#                      2           OUTPUT_WITH_BIT_OPS

#                      3           INPUT_BASIC

#                      4           INPUT_WITH_BIT_OPS

#

#                The TYPE used for digital inputs is 3, INPUT_BASIC.

#

#   DEV_ADDRESS: Device address.  An 8 bit number that defines the RTP

#                device address (chassis address).  If the chassis address is

#                set to 0x31, the address used for this field should be 0x01.

#

#   OPTION:      A bit mask of options.  A 16 bit value that is used as a mask

#                to control I/O options.  For type 3 (INPUT_BASIC) I/O, the

#                options are defined as follows:

#

#                Bit 15: Output command word contained in COMMAND

#                Bit 14: Check Test Return before writing output data

#                Bit 13: Wait DELAY number of microseconds for Test Return

#                        before output.  Only valid when Bit 14 is set.

#                Bit 12: Output data word contained in Output Data (OUT_DATA).

#                Bit 11: Check Test Return before reading input data.

#                Bit 10: Wait Delay number of microseconds for Test Return

#                        Only valid when Bit 11 set.

#                Bit 09: Perform an input operation and return data in

#                        response.  If this bit is not set, input is not

#                        performed and onlu POINT_STATUS is returned

#                        in response.

#                Bit 08: Perform a second input operation and return additional

#                        data in response.  Only valid if bit 09 is set.

#                        If this bit is set and POINT_EXTENDED_INPUT return

#                        is used.

#                Bit 07: Replace the Output Data (OUT_DATA) with the value

#                        obtained from the second input operation for auto-

#                        ranging purposes.  Only valid if bit 08 is used.

#

#                The OPTION value for digital inputs is 0x8A00.

#

#   COMMAND:     Command to the iobc.  A 16 bit value that defines which

#                card in the chassis rack will be doing the digital

#                inputs.  A value of 0x0503 in COMMAND indicates that

#                there is a digital input card in logical slot 3

#                (physical slot 8) of the chassis. 

#                (Note: logical slot = physical slot - 5.)

#

#   OUT_DATA:    Output Data.  A 16 bit value that is used as output data

#                to the iobc.  For digital inputs, this value is used as

#                an initialization value.

#

#                The OUT_DATA value for digital inputs is 0x0000.

#

#   DELAY:       Delay value.  A 16 bit value indicating the amount of

#                time after which, if the card is not ready, an error is

#                returned.  Multiply us by 1.19 to get the proper delay.

#                A delay of 100 us == 100 * 1.19 = 119 (base 10) or

#                77 (base 16).

#

#                The DELAY value for digital inputs is typically 0x00FF.

#

#   AND_VAL:     A 16 bit value to logically AND with the output data

#                value (OUT_DATA).  This value is not used for digital

#                inputs but must be present.

#

#                The AND_VALUE value for digital inputs is 0x0000.

#

#   OR_VAL:      A 16 bit value to logically OR with the output data

#                value (OUT_DATA).  This value is not used for digital

#                inputs but must be present.

#

#                The OR_VALUE value for digital inputs is 0x0000.

#

#

#CORR_ID   TYPE  DEV_ADDRESS  OPTION   COMMAND  OUT_DATA  DELAY(uS)   AND_VAL   XOR_VAL

 0000001    3        0x01     0x8A00   0x0500    0x0000   0x00FF      0x0000     0x0000

 0000002    3        0x01     0x8A00   0x0501    0x0000   0x00FF      0x0000     0x0000

 0000003    3        0x01     0x8A00   0x0502    0x0000   0x00FF      0x0000     0x0000

 0000004    3        0x01     0x8A00   0x0503    0x0000   0x00FF      0x0000     0x0000

#

[DO]

# Define digital output scan list

      4

#

# Field Definitions

#

#   CORR_ID:     Correlation ID.  A 32 bit number that is transmitted to the

#                eiobc and returned from the eiobc for each I/O point. 

#                Usually numbered sequentially.

#

#   TYPE:        An 8 bit number that defines the type of I/O to be performed. 

#                There are currently four (4) types of I/O that can be

#                performed with the eiobc:

#

#                     TYPE            DEFINITION

#                     ----         -------------------

#                      1           OUTPUT_BASIC

#                      2           OUTPUT_WITH_BIT_OPS

#                      3           INPUT_BASIC

#                      4           INPUT_WITH_BIT_OPS

#

#                The TYPE used for digital outputs is 1, OUTPUT_BASIC.

#

#   DEV_ADDRESS: Device address.  An 8 bit number that defines the RTP

#                device address (chassis address).  If the chassis address is

#                set to 0x31, the address used for this field should be 0x01.

#

#   OPTION:      A bit mask of options.  A 16 bit value that is used as a mask

#                to control I/O options.  For type 1 (OUTPUT_BASIC) I/O, the

#                options are defined as follows:

#

#                Bit 15: Output command word contained in COMMAND

#                Bit 14: Check Test Return before writing output data

#                Bit 13: Wait DELAY number of microseconds for Test Return

#                        before output.  Only valid when Bit 14 is set.

#                Bit 12: Output data word contained in Process Scan List

#                        message.  If this bit is not set then no output

#                        word should be included in the Process

#                        Scan List.

#

#                The OPTION value for digital outputs is 0xF000.

#

#   COMMAND:     Command to the iobc.  A 16 bit value....

#

#   OUT_DATA:    Output Data.  A 16 bit value that is used as output data

#                to the iobc.  This value is not used for digital outputs

#                but must be present. 

#

#                The OUT_DATA value for digital outputs is 0x0000.

#

#   DELAY:       Delay value.  A 16 bit value indicating the amount of

#                time after which, if the card is not ready, an error is

#                returned.  Multiply us by 1.19 to get the proper delay. 

#                A delay of 100 us == 100 * 1.19 = 119 (base 10) or

#                77 (base 16).

#

#                The DELAY value for digital outputs is typically 0x00FF.

#

#   AND_VAL:     A 16 bit value to logically AND with the output data

#                value (OUT_DATA).  This value is not used for digital

#                outputs but must be present.

#

#                The AND_VALUE value for digital outputs is 0x0000.

#

#   OR_VAL:      A 16 bit value to logically OR with the output data

#                value (OUT_DATA).  This value is not used for digital

#                outputs but must be present.

#

#                The OR_VALUE value for digital outputs is 0x0000.

#

#

#  CORR_ID   TYPE  DEV_ADDRESS  OPTION   COMMAND  OUT_DATA  DELAY(uS)   AND_VAL   XOR_VAL

   0000001    1        0x01     0xF000   0x0504    0x0000   0x00FF      0x0000     0x0000

   0000002    1        0x01     0xF000   0x0505    0x0000   0x00FF      0x0000     0x0000

   0000003    1        0x01     0xF000   0x0506    0x0000   0x00FF      0x0000     0x0000

   0000004    1        0x01     0xF000   0x0507    0x0000   0x00FF      0x0000     0x0000

#   End of RTP I/O Configuration File

...

Expand
titleSoftware Driver

The core of the driver is provided as a C++ class which implements the initialization and communications functions.  A sample process is provided which calls the appropriate class members. 

The IP address, configuration, and data areas to be read and written are passed as calling parameters to the class functions.

The following is a list of the provided driver files.  After review of the example driver, the user is required to modify the files as indicated:

File Name

Description

Modifications

GePlcDrv.cpp

Driver mainline function

Insert required global common areas.  Modify register files and values are required.  Modify inout and output datagram structure definition

PlcUsrInput.cpp

Process received values from PLC datagram and place in user data variables

Change as required

PlcUsrOutput.cpp

Get application variables and store in datagra for transmission to PLC

Change as required

GELPC Class Descriptions

Expand
Info

The Tsentry GePlc class encapsulates the functionality required to communicate with the GE PLC (9030 and 9070) over a TCP/IP network.

The following public member functions are provided as part of the tpriGePlc class:

  • tpriGePlc *pGePlc = new tpriGePlc;

    • Allocate a new tpriGePlc object

 

  • destroy (tpriGePlc *)pGePlc();

    • Destroy the tpriGePlc class object.

 

  • int Init (char *piffile, char *tplcIpAddr, unsigned short tPortNo,

                     long cTimeOut, long sTimeOut, long rTimeOut);

where:

char *piffile = initialization file name (currently not supported) = NULL

char *tplcIpAddr = IP address of the PLC in xxx.xxx.xxx.xxx format

unsigned short tPortNo = port (service) number of the TCP support in the GE PLC.  This value is normally fised at 18245 by GE.

            long cTimeOut = Connection timeout value in milliseconds

long sTimeOut = Send message timeout value in milliseconds

long rTimeOut = receive message timeout value in milliseconds

This function stores parameter values for use by the member functions of the class

  • int Connect ();

    • Connect (using TCP/IP) to the PLC and open an application connection

 

  • int Write (char *seg, int ref, int size, int bMode, unsigned char *buffer);

where

            char *seg = segment (plc memory area) type

                        “R”            = register variable

                        "L"            = Local Data Table (%L)

                        "P"            = Program Data Table (%P)

                        "R"            = Register Table (%R)

                        "AI"            = Analog Input Table (%AI)

                        "AQ"            = Analog Output Table (%AQ)

                        "I"               = Discrete Input Table, byte mode (%I)

                        "Q"            = Discrete Output Table, byte mode (%Q)

                        "T"            = Discrete Temporary Table, byte mode (%T)

                        "M"            = Discrete Internal Table, byte mode (%M)

                        "SA"            = Discrete System A Table, byte mode (%SA)

                        "SB"            = Discrete System B Table, byte mode (%SB)

                        "SC"            = Discrete System C Table, byte mode (%SC)

                        "S"            = Discrete System D Table, byte mode (%S)

                        "G"            = Genius Global Data Table, byte mode (%G)

                        "GA"            = Genius Global Data Table, byte mode (%GA)

            int ref = 1st variable within segment to transfer (beginning of table = 1)

int size = size of transfer in number of words, bytes or bits (see bmode)

int bmode = units size;

0 = words or bytes,

1 = bits

unsigned char *buffer = pointer to application program data buffer

This function writes an application buffer to the PLC

 

  • int Read (char *seg, int ref, int size, int bMode, unsigned char *buffer);

where

            char *seg = segment (plc memory area) type

                        See definitions in the Write function

            int ref = 1st variable within segment to transfer (beginning of table = 1)

int size = size of transfer in native units (words, bytes or bits) see bmode

int bmode = transfer unit size; 0 = words or bytes, 1 = bits

unsigned char *buffer = pointer to application program data buffer

This function reads an application buffer from the PLC

 

  • int getSrpErrorCode();

Return an integer equal to the last SRTP (GE PLC protocol) error code

 

  • int Is_Connect ();

Return an integer that indicates whether the application has an open connection with the GE PLC

...

int

tpriRdcTcp::open(int

*devHndl,

char

*devName,

int

portNum,

int

blocking

=

-1,

struct

sockaddr_in

*pServer

=

NULL)

Open

a

connection

to

the

specified

device.

Inputs:

int

*devHndl

Pointer

  Pointer to

device

handle

that

will

be

returned

from

the

open

call.

 

For

non-blocking

requests

this

must

point

to

a

handle

equal

to

-1

on

the

first

attempt

and

passed

unchanged

to

subsequent

open

calls

(made

while

open

remains

in

progress).

char

*devName

Remote

  Remote device

name.

int

portNum Remote device

portNum     Remote device TCP/IP

port

number

int

blocking Flag indicating if the open should block until

blocking    Flag indicating if the open should block until success/failure

(1)

or

return

immediately

(0).

Passing

 Passing -1

indicates

that

the

blocking

state

should

remain

unchanged

from

its

previous

value.

sockaddr_in

*pSvr

Pointer

to

server

structure

that

will

be

filled

in

by

the

open

call.

Once

filled

in,

the

same

structure

can

be

passed

on

subsequent

blocking

calls

to

speed

up

the

connection

process.

Passing

a

NULL

pointer

will

turn

off

this

feature.

Return

value:

Blocking

calls:

This

function

returns

zero

if

successful

or

a

positive

integer

if

the

open

fails.

If

 If successful,

the

device

handle

will

be

stored

in

the

location

pointed

to

by

devHndl.

Non-Blocking

calls:

This

function

will

return

-1

to

indicate

that

the

open

is

still

pending;

call

repeatedly

until

it

returns

a

success

or

failure.

int

tpriRdcTcp::close(int

devHndl)

Close

a

connection

associated

with

a

device

handle.

Inputs:

int

devHndl Device handle as returned from the open call. Return value: Always 0. int

devHndl      Device handle as returned from the open call.

Return value:

Always 0.

int tpriRdcTcp::read(int

devHndl,

char

*rxBuf,

int

rxCnt,

int

blocking

=

-1)

Read

a

set

of

data

from

a

remote

device.

Inputs:

int

devHndl Device handle as returned from the open call. char *rxBuf Pointer to the buffer into which the received data should be placed. int rxCnt Maximum number of bytes to read. int blocking Flag indicating if the read should block until rxCnt bytes have been read (1) or return immediately (0) with whatever data is available. Passing -1 indicates that the blocking state should remain unchanged from its previous value. Return value: If successful, the number of characters successfully read is returned. 1 indicates that an error occurred, and information about that error is available through WSAGetLastError(). -99 indicates that the connection has been closed. int tpriRdcTcp::write(int devHndl, char *txBuf, int txCnt) Write a set of data to a remote device. Inputs: int devHndl Device handle as returned from the open call. char *txBuf Pointer to the buffer containing the data to be written. int txCnt Number of bytes to write. Return value: If successful, the number of characters successfully written is returned. 1 indicates an error occurred. int tpriRdcTcp::listen(int *devHndl, int *svrHndl, int portNum, int backLog, int blocking /* = -1 */, char *hostName /* = NULL */) Listen for incoming TCP/IP connections. Inputs: int *devHndl Pointer to device handle that will be returned when a remote device connects to the server. int *svrHndl Pointer to device handle associated with the server socket. This handle can be reused to accept multiple connections. This must point to a handle equal to -1 on the first attempt and passed unchanged to subsequent listen calls. int portNum Remote device TCP/IP port number. int backLog Maximum number of connections to allow. int blocking Flag indicating if the open should block until success/failure (1) or return immediately (0). Passing a -1 indicates that the blocking state should remain unchanged from its previous value. char *hostName Local device name (if desired). Return value: Blocking calls: This function returns zero if successful or a positive integer if the open fails. If successful, the device handle will be stored in the location pointed to by devHndl. Non-Blocking calls: This function will return -1 to indicate that no connections are pending; call repeatedly until it returns a success or failure.

devHndl      Device handle as returned from the open call.

char *rxBuf      Pointer to the buffer into which the received data should be placed.

int rxCnt      Maximum number of bytes to read.

int blocking      Flag indicating if the read should block until rxCnt bytes have been read (1) or return immediately (0) with whatever data is available.  Passing -1 indicates that the blocking state should remain unchanged from its previous value.

Return value:

If successful, the number of characters successfully read is returned.   1 indicates that an error occurred, and information about that error is available through WSAGetLastError().  -99 indicates that the connection has been closed.

int tpriRdcTcp::write(int devHndl, char *txBuf, int txCnt)

Write a set of data to a remote device.

Inputs:

int devHndl      Device handle as returned from the open call.

char *txBuf      Pointer to the buffer containing the data to be written.

int txCnt      Number of bytes to write.

Return value:

If successful, the number of characters successfully written is returned.   1 indicates an error occurred.

int tpriRdcTcp::listen(int *devHndl, int *svrHndl, int portNum, int backLog,

                                 int blocking /* = -1 */, char *hostName /* = NULL */)

Listen for incoming TCP/IP connections.

Inputs:

   int *devHndl      Pointer to device handle that will be returned

                     when a remote device connects to the server.  

   int *svrHndl      Pointer to device handle associated with the

                     server socket.  This handle can be reused to

                     accept multiple connections.

                     This must point to a handle equal to -1 on the

                     first attempt and passed unchanged to

                     subsequent listen calls.

   int portNum       Remote device TCP/IP port number.

   int backLog       Maximum number of connections to allow.

   int blocking      Flag indicating if the open should block until

                     success/failure (1) or return immediately (0).

                     Passing a -1 indicates that the blocking state

                     should remain unchanged from its previous value.

   char *hostName    Local device name (if desired).

Return value:

   Blocking calls:

      This function returns zero if successful or a positive integer

      if the open fails.  If successful, the device handle will be

      stored in the location pointed to by devHndl.  

   Non-Blocking calls:

      This function will return -1 to indicate that no connections

      are pending; call repeatedly until it returns a success or

      failure.

Expand
titleStatic Class Functions
Code Block
languagenone

Lantronix Terminal Server Driver - tpriRdcLts

Expand
titleOverview

The I/O driver library includes the tpriRdcLts class for communications through a Lantronix terminal server to a remote device.  This class provides functions to open a connection to a specified port on the desired terminal server, to read and write data to and from the device attached to the terminal server, and to close the connection when finished.  Blocking and non-blocking modes are both supported individually for connections and reads.  The library is composed of several static class functions that can be explicitly called without having to manage the underlying class itself.

Expand
titleStatic Class Functions

int tpriRdcLts::open(int *devHndl, char *devName, int portNum, int blocking = -1, struct sockaddr_in *pServer = NULL)

This function is identical to that for the tpriRdcTcp class with the following exception:

Inputs:

int portNum      Desired port number on the terminal server, starting with 1.

int tpriRdcLts::close(int devHndl)

This function is identical to that for the tpriRdcTcp class.

int tpriRdcLts::read(int devHndl, char *rxBuf, int rxCnt, int blocking = -1)

This function is identical to that for the tpriRdcTcp class.

int tpriRdcLts::write(int devHndl, char *txBuf, int txCnt)

This function is identical to that for the tpriRdcTcp class.

int tpriRdcLts:: resetConn(char *devName, int ltsPort, char *password = NULL)

Reset a port on a Lantronix terminal server.  This is useful if a connection to the terminal server died unexpectedly such that the server thinks the connection is still present and will not allow new connections until the original is reset.

Inputs:

char *devName      Remote device name.

int ltsPort      Desired port number on the terminal server, starting with 1.

char *password      The privileged password on the terminal server.  If no password is provided "system" is assumed.

Return value:

If a connection was made to the terminal server then a zero will be returned regardless of whether or not the reset was successful.  A return value of -1 indicates that a connection could not be established.

Expand
titleExample Lantronix Terminal Server

Following is an example class definition and source code for a Lantronix driver using the static function calls above to loop a message through a port on a terminal server back into itself.  It requires that a loopback cable be plugged into the specified port on the Lantronix terminal server.

Code Block
languagec
<DemoLts.cpp>
//------------------------------------------------------------------------
//    File Name        : DemoLts.cpp
//
//    Author           : TelePro, Inc.
//
//    Date (Original)  : 6/15/01
//
//    Hdwr/Sys Config  : Pentium III PC or greater
//                       Windows 2000
//
//    Revision History :
//    Rev     Date       Who/Description
//    1.00    06/15/01   AJ Johnson
//                       Initial Version 
//------------------------------------------------------------------------
//    COPYRIGHT (C) 2001
//    TELEPRO, INC.
//    ALL RIGHTS RESERVED
//
//    THIS SOFTWARE AND ALL INFORMATION AND IDEAS CONTAINED WITHIN
//    ARE THE PROPERTY OF TELEPRO, INC. AND ARE CONFIDENTIAL.
//    NEITHER THIS SOFTWARE NOR ANY PART NOR ANY INFORMATION
//    CONTAINED IN IT MAY BE DISCLOSED OR FURNISHED TO OTHERS
//    WITHOUT THE PRIOR WRITTEN CONSENT OF TELEPRO, INC.
//------------------------------------------------------------------------
//    Function Name: DemoLts
//
//    Function Description and Notes:
//         This program demonstrates communications through a Lantronix
//         terminal server using a loopback test and the static class
//         tpriRdcLts functions to connect, read, write, and close.
//
//    Function type:
//       "C" language void function
//------------------------------------------------------------------------

// Standard header includes
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>

// System specific header includes
#include "tpriNtRt.h"
#include "tpriRdcLts.h"

void _cdecl main(int argc, char **argv, char **envp)
   {
   // Variable declarations
   int rstatus = 0;        // this function's return status
   int fstatus = 0;        // function call return status
   int forever = 1;        // Set => 0 when processing loop should exit
   char rxBuf[128];
   char rxCnt = 0;
   char *txBuf = "Test loopback message";
   int txCnt = strlen(txBuf);
   int devHndl = -1;
   char devName[256];
   int portNum;
   int connStat;
   // --------------------------------------------------------------
   // Initialize process management global
   // ------------
   fstatus = tpriProc::Create();
   if (fstatus < 0)
      {
      // unable to initialize process
      LogMsg("DemoLts", DBSS, "Error initializing process commons\n");
      forever = 0;
      }
   else
      {
      LogMsg("DemoLts", DBSS, "DemoLts V1.00\n");
      }
   // --------------------------------------------------------------
   // Set up local process environment using process initialization
   // file parameters
   // --------------------------------------------------------------
   if (forever)
      {
      fstatus = tpriProc::PrIni(argc, argv);
      if (fstatus < 0)
         {
         // unable to initialize process
         LogMsg("DemoLts", DBSS, "Error initializing process\n");
         forever = 0;
         }
      }
   // --------------------------------------------------------------
   // Application Code:
   //     The following code will be run once on initial process execution
   // --------------------------------------------------------------
#ifndef UNDER_RTSS
   WSADATA wsaData;
   int socketInit;
   if (forever)
      {
      // set up windows sockets
      socketInit = WSAStartup(0x0020, &wsaData);
      if (socketInit != 0)
         {
         // error initializing windows sockets
         LogMsg("DemoLts", DBERR, "Error %d starting Windows sockets\n",
            GetLastError());
         forever = 0;
         }
      }
#endif

   if (forever)
      {
      if (argc <= 1)
         {
         LogMsg("DemoLts", DBFERR, 
            "Ini file not specified on command line\n");
         forever = 0;
         }
      else
         {
         // get the LTS IP address
         tpriIniFile::getKeyValue("LtsLoopback", "IPAddress", "localhost", 
            devName, sizeof(devName), argv[1]);

         // get the LTS port number
         tpriIniFile::getKeyValue("LtsLoopback", "LtsPort", "1", 
            rxBuf, sizeof(rxBuf), argv[1]);
         portNum = atol(rxBuf);
         }
      }

   // --------------------------------------------------------------
   // Try to connect
   // -------------------------------------------------------------
   while ((forever) && 
          ((connStat = tpriRdcLts::open(&devHndl, devName, 
                                        portNum, 0)) < 0))
      {
      // -----------------------------------------------------------
      // Call PrWait to stall until the next timer interval
      // -----------------------------------------------------------
      fstatus = tpriProc::PrWait();

      // --------------------------------------------------------
      // Decide whether or not to continue
      // -------------------------------------------------------
      forever &= (tpriProc::getState() > 0);
      }

   if (connStat == 0)
      {
      LogMsg("DemoLts", DBSS, "Connected to terminal server %s port %d\n",
         devName, portNum);

      // write a message out to the terminal server
      if (tpriRdcLts::write(devHndl, txBuf, txCnt) != txCnt)
         {
         LogMsg("DemoLts", DBERR, 
            "Error writing data to terminal server\n");
         }
      else 
         {
         LogMsg("DemoLts", DBERR, 
            "Wrote loopback message <%s> to terminal server\n", txBuf);

         while (forever)
            {
            // read a bit of data
            fstatus = tpriRdcLts::read(devHndl, &rxBuf[rxCnt], 
                         sizeof(rxBuf) - rxCnt, 0);
            if (fstatus > 0)
               {
               // print out what we just received
               DumpHex(DEBUG, (unsigned char *)&rxBuf[rxCnt], 0, fstatus,
                  "Received data");

               // check if this new data completes the message
               rxCnt += fstatus;

               if (memcmp(rxBuf, txBuf, txCnt) == 0)
                  {
                  // bingo! - we got back what we sent
                  rxBuf[txCnt] = 0x00;
                  LogMsg("DemoLts", DBSS, 
                     "Received full loopback message <%s>\n", rxBuf);

                  // fall out of the loops
                  forever = 0;
                  }
               }
               
            // -----------------------------------------------------
            // Call PrWait to stall until the next timer interval
            // -----------------------------------------------------
            fstatus = tpriProc::PrWait();
            
            // ---------------------------------------------------
            // Decide whether or not to continue
            // ---------------------------------------------------
            forever &= (tpriProc::getState() > 0);
            }
         }
         
      // close the connection
      tpriRdcLts::close(devHndl);
      }
   // ----------------------------------------------------------
   // At this point the Application has decided that it no longer wants
   // to be run, so clean up and exit.
   // ------------------------------------------------------------
   LogMsg("DemoLts", DBSS, "Process exiting\n");
   tpriGsmDDCom::Destroy();
   tpriProc::Destroy();

   ExitProcess(rstatus);
   }

<LtsLoopback.ini>

#
#   Example Lantronix terminal server loopback program config file
#
[LtsLoopback]
IPAddress=192.55.195.222
LtsPort=1

Lantronix Cobox Terminal Server Driver - tpriRdcCbx

Expand
titleOverview

The I/O driver library includes the tpriRdcCbx class for communications through a Lantronix CoBox terminal server to a remote device.  This class provides functions to open a connection to a specified port on the desired CoBox terminal server, to read and write data to and from the device attached to the terminal server, and to close the connection when finished.  Blocking and non-blocking modes are both supported individually for connections and reads.  The library is composed of several static class functions that can be explicitly called without having to manage the underlying class itself.

Expand
titleStatic Class Functions

int tpriRdcCbx::open(int *devHndl, char *devName, int portNum, int blocking = -1, struct sockaddr_in *pServer = NULL)

This function is identical to that for the tpriRdcTcp class.

int tpriRdcCbx::close(int devHndl)

This function is identical to that for the tpriRdcTcp class.

int tpriRdcCbx::read(int devHndl, char *rxBuf, int rxCnt, int blocking = -1)

This function is identical to that for the tpriRdcTcp class.

int tpriRdcCbx::write(int devHndl, char *txBuf, int txCnt)

This function is identical to that for the tpriRdcTcp class.

int tpriRdcCbx:: resetConn(char *devName, char *password = NULL)

Reset a port on a CoBox terminal server.  This is useful if a connection to the terminal server died unexpectedly such that the server thinks the connection is still present and will not allow new connections until the original is reset.

Inputs:

char *devName      Remote device name.

char *password      The privileged password on the terminal server.  If no password is provided "system" is assumed.

Return value:

If a connection was made to the terminal server then a zero will be returned regardless of whether or not the reset was successful.  A return value of -1 indicates that a connection could not be established.

Generalized Remote Device Connection Driver

Expand
titleOverview

In addition to the static library functions described above, the tpriRdc-derived classes can be used to as a framework to manage all of the low-level I/O, timing, and error recovery associated with a connection to a remote device.  In effect, the tpriRdc classes act as a fully customizable state machine to communicate with a remote device through a variety of interfaces without having to worry about the specifics of the intermediate hardware or basic communications protocols.  Currently, the following interfaces are supported:

  • Direct serial RS-232

  • Direct TCP/IP

  • TCP/IP to serial via Lantronix 4-, 8-, and 16-port terminal servers

  • TCP/IP to serial via Lantronix CoBox single-port terminal servers

Info

As suggested above, tpriRdc library is actually composed of a set of C++ classes, each of which is specialized to handle a particular type of interface.  The user creates a custom device driver class derived from the tpriRdc class associated with the desired interface, setting the parent properties and filling in the provided virtual functions as appropriate.  A single entry point is then provided to automatically sequence the state machine through establishing the connection and passing data to and from the remote device.

Expand

The interface-specific tpriRdc classes are:

  • tpriRdcSer           Direct serial RS-232

  • tpriRdcTcp           Direct TCP/IP

  • tpriRdcLts            Lantronix multi-port terminal server

  • tpriRdcCbx           Lantronix CoBox terminal server

The custom device driver should be derived from one of these classes in order to build upon and use the functionality encapsulated within these classes.

Expand
titleState Machine Flow

Following is flow path for the state machine:

switch (current state)

      case UNINIT

  • call virtual function initDrv()

 

case IDLE

  • if first pass → goto state CONNECT

  • else if reopen

    • set/test delay timer for reopen

  • else return non-zero from state driver to indicate we’re finished

 

case CONNECT

  • call virtual function setupComm(0) to open connection

  • if success → goto state WAITMSG

  • else if error →

    • call virtual function setupComm(1) to clean up

 

case WAITMSG

  • call virtual function waitMsg() to check if it’s time to send a message

  • if it’s time → goto state BUILDMSG

  • else if it’s not yet time → continue waiting

 

case BUILDMSG

  • call virtual function buildMsg() to assemble the outbound message

  • if return = 0 → goto state XMITMSG

  • else if error → return to state WAITMSG

 

case XMITMSG

  • call virtual function xmitMsg() to send message

  • if return = 0 → goto state WAITRSP

  • else if error →

    • call virtual function setupComm(1) to clean up

    • return to state IDLE

 

case WAITRSP

  • call waitRsp() to read data from interface

  • call virtual function testRsp() to test if a full msg has been recv’d.

  • if full msg recv’d → goto state PROCRSP to process valid message

  • else if timeout → goto state PROCRSP to process empty message

  • else if error →

    • call virtual function setupComm(1) to clean up

    • return to state IDLE

 

case PROCRSP

  • call virtual function procRsp()

  • if return is 0 → goto state WAITMSG

  • else if error → goto state IDLE

 

The state machine for the remote device connection can be executed by calling the following function defined in the tpriRdc base class:

int tpriRdc:: stateDrv(int oneshot = 0)

Close a connection associated with a device handle.

Inputs:

int oneshot      If non-zero, the state machine will execute only once and return.  If zero, the state machine will repeatedly execute until the current state does not change from pass to pass. 

Return value:

Zero if no error and state machine can be called again to continue processing or non-zero if an error has occurred or the state machine has finished.

The state machine for the remote device connection can be executed by calling the following function defined in the tpriRdc base class:

Expand
titleClass Data Members

The following variables are internal data members of the tpriRdc class and the custom driver class should set their values as desired:

char *initStr 

Optional initialization string to be used by the custom class.

int reOpen

Flag indicating if connections should be automatically reopened (1) or not (0).

long reOpenDelay

Time to wait (ms) after communications failure before trying to reconnect to remote device.

int connBlocking 

Flag indicating if the connection is to be blocking (1) or non-blocking (0).

int ioBlocking  

Flag indicating if the device reads are to be blocking (1) or non-blocking (0).

char devName[]  

String specifying the name of the remote device.

long connTimeout  

Amount of time to wait for a non-blocking connection to timeout (ms) or <= 0 for no timeout.

long txTimeout

Amount of time to wait for a non-blocking write to timeout (ms) or <= 0 for no timeout (not currently supported).

long rxTimeout

Amount of time to wait for a non-blocking read to timeout (ms) or <= 0 for no timeout.

int txAttemptMax 

Maximum number of transmission attempts before message fails.

The following variables are internal data members of the tpriRdcTcp class the custom driver class should set their values as desired:

int portNum 

TCP/IP port number to use in the connection

The following variables are internal data members of the tpriRdc class that the custom device class will require for normal processing:

char txBuf[] 

Buffer containing the current message to be transmitted.  This buffer should be filled by the buildMsg() virtual function and will be transmitted by the xmitMsg() function.

int txCnt 

Number of characters in the current message to be transmitted.  This value should be set according to the txBuf[] above.

char rxBuf[]  

Buffer containing all data received by the driver since the last outbound message was sent.  This data should be checked by the testRsp() virtual function and either thrown away with a call to tossRsp(int nToss) or moved to the response buffer as a complete response with a call to ripRsp(int nRsp).

int rxCnt

Number of characters received by the driver since the last outbound message was sent, and consequently the number of bytes currently stored in the rxBuf[] receive buffer.

char *rspBuf

Dynamically allocated received response buffer.  This buffer is automatically allocated when a full response is found in the receive buffer and grabbed with a call to the ripRsp(int nRsp) function.  This buffer should then be processed by the procRsp() virtual function.

int rspCnt

Size of the dynamically allocated received response buffer *rspBuf.  This is automatically set when the buffer is allocated in the ripRsp(int nRsp) function.

Expand
titleClass Virtual Functions

The custom device driver class then overrides a set of virtual functions that will be called by the base classes at the appropriate times.  These virtual functions are:

 

  • Virtual int initDrv()
    The framework calls this function to process one-time initialization of internal parameters including device name, timeout values, max retry counts, etc.  Return zero to indicate success and nonzero to indicate that an error has occurred.

  •  Virtual int setupComm(int oper)
    The framework calls this function to connect (oper <> 0) or disconnect (oper = 0) from the remote device.  Return zero to indicate success and nonzero to indicate that an error has occurred.  This function does not need to be overridden under normal circumstances.

  •  Virtual int waitMsg()
    The framework calls this function to allow the derived class to decide when it is time to send a message to the remote device.  Return zero to indicate a message should now be sent and nonzero to continue waiting.

  •  Virtual int buildMsg()
    The framework calls this function to assemble the next outbound message immediately after the user has returned zero from a call to waitMsg().  The custom driver should copy the outbound message into the class data member txBuf[] character buffer and store the number of characters in the class data member txCnt.

  •  Virtual int xmitMsg()|
    The framework calls this function to transmit data to the remote device.  Return 0 to indicate success or nonzero indicate an error.  This function does not need to be overridden under normal circumstances.

  •  Virtual int waitRsp()
    The framework calls this function to read data from the remote device.  It must also call testRsp() to check if a full message has been received.  Return 0 to indicate reception of a complete message or timeout or -1 to continue reading data.  This function does not need to be overridden under normal circumstances.

  •  Virtual int testRsp()
    The framework calls this function to decide whether or not a response has been received from the remote device.  Upon entry into this function all data received from the remote device since transmission of the most recent message is stored in the class data member rxBuf[] character buffer and the number of received bytes stored in rxCnt.  Any bytes at the beginning of the rxBuf[] buffer that are not part of a valid response may be removed using the class member function tossRsp(int nToss).  If a valid message is found, copy it from the beginning of the rxBuf[] buffer to the response buffer using the class member function ripRsp(nRsp).  Return zero to indicate that the response is complete, less than zero to indicate that the response is incomplete, and greater than zero to indicate that an error has occurred.

  •  Virtual int procRsp()
    The framework calls this function to process a complete response from the remote device.  Return zero to reset and wait until the next message should be sent, and nonzero to reset the connection.

Expand
titleClass Helper Functions

The following functions are internal data methods of the tpriRdc class for use within the custom user driver:

int getState()

Return the current state.

Return value:

The current state is returned as specified in the following table:

UNINIT            0

IDLE            1

CONNECT           2

WAITMSG           3

BUILDMSG          4

XMITMSG           5

WAITRSP           6

PROCRSP           7

void setRxBufSize(int size)

Resize of the internal receive buffer.  Any data existing in the existing buffer will be transferred to the new buffer provided that it does not exceed the new size.  The default size of the receive buffer is 1024 bytes.

Inputs:

int size      New size of receive buffer.

void setTxBufSize(int size)

Resize of the internal transmit buffer.  Any data existing in the existing buffer will be transferred to the new buffer provided that it does not exceed the new size.  The default size of the transmit buffer is 1024 bytes.

Inputs:

int size      New size of transmit buffer.

void ripRsp(int nRsp)

Pops the first nRsp bytes from the receive buffer rxBuf[], dynamically allocates the response buffer *rspBuf, and stores the response there for later processing.  This function should be called from within the testRsp() virtual function once a full response starting at the beginning of the rxBuf buffer has been detected.  Each call to ripRsp(..) destroys the response buffer created by the previous call and shifts the receive buffer so that the remaining data is stored at the beginning of the buffer.

Inputs:

int nRsp      Number of bytes in the detected response that should be copied out of the receive buffer rxBuf[].

      void tossRsp(int nRsp)

Pops the first nRsp bytes from the receive buffer rxBuf[] and throws them away.  The receive buffer is then shifted so that the remaining data is stored at the beginning of the buffer.  This function should be called from within the testRsp() virtual function to throw away bytes at the beginning of the receive buffer that are not part of a valid response.

Inputs:

int nRsp   Number of bytes in the detected response that should be copied out of the receive buffer rxBuf[].

Expand
titleExample Lantronix Terminal Server RDC Driver

The Tsentry source distribution area contains an example class definition and source code for a tpriRdc-derived class used to loop a message through a port on a Lantronix multi-port terminal server back into itself.  It requires that a loopback cable be plugged into the specified port on the Lantronix terminal server.

Allen Bradley Control Logix PLC Driver

Expand
titleCapabilities

This driver:

  • Communicates with A-B Control Logix 5500 and 5555 PLC systems

  • Uses TCP/IP Communications over:

    • Standard Ethernet network connection

    • High Speed dedicated process I/O network with deterministic network performance

  • Software implemented as a C++ Class

  • Multiple PLC support

  • Supports:

    • Read Variables

    • Write variables

Capable of running 500ms Input and Output scan rep rates, depending on data buffer size.

Expand
titleA-B Configuration

The Allen Bradley PLC must be set up with the proper IP address.  This configuration is completed with the A-B software.  The IP must be chosen such that it lies within the subnet selected for the specific Ethernet controller used for communications.

If the Ethernet controller is one that is controlled by the Windows 2000 system, the subnet is specified in the network setup utility of the control panel.

If the Ethernet controller is one that is controlled by the RTX Real-Time TCP/IP controller, the IP address is specified in the file d:\LocNtRt\sys\pif\RtxTcp.ini. 

Expand
titleSoftware Driver

The core of the driver is provided as a C++ class that implements the initialization and communications functions.  A sample process is provided which calls the appropriate class members.

The IP address, configuration information, and data areas to be read and written are passed as calling parameters to the class functions.

The following is a list of the provided driver files.  After review of the example driver, the user is required to modify the files as indicated:

File Name

Description

Modifications

ClPlc.cpp

Driver mainline function

Modify configuration class calls for specific PLC configuration.  Modify locations to read and write data.  Modify input and output datagram structure definition

ClIn.cpp

ClPlc driver initialization

Insert required global common areas. 

PlcUsr.cpp

Process received values from PLC datagram and place in user data variables.

Get application variables and store in datagra for transmission to PLC

Change as required

Expand
titleCLeip Class Description

The Tsentry CLeip class encapsulates the functionality required to communicate with the Allen Bradley 5500 and 5555 PLCs over a TCP/IP network.

The following public member functions are provided as part of the tpriCLeip class:

  •  tpriCLeip *pCLeip = new tpriCLeip;

    • Allocate a new tpriCLeip object

  • destroy (tpriCLeip *)pCLeip();

    • Destroy the tpriCLeip class object.

  •  int SetTraceLevel (int TraceLevel);

where:

int TraceLevel = debug trace level for class operations

                           default value = 30

                           valid values range between 0 and 100, inclusive

                           lower values produce less debug information

                           higher values produce more debug information

                           debug information written using LogMsg function

This function stores a new value for the TraceLevel parameter

 

  • int SetEnetPort (int port);

where:

int port = Ethernet Port number

            Default value = 1

This function stores a new value for the Ethernet Port parameter.  This communications parameter defines the port number for the Ethernet controller in the PLC chassis

 

  • int SetLogixSlot (int slot);

where:

int slot = Control Logix process slot number

            Default value = 0

This function stores a new value for the Ethernet Port parameter.  This communications parameter defines the slot in which the Control Logix processor resides.

 

  • int SetTimeOut (int sTimeOut, int rTimeOut, unsigned char ticktime,

                              unsigned char timeoutticks, unsigned char timeoutmultiplier,

                              unsigned long otrpi, unsigned long torpi );

where:

int sTimeOut = TCP Send message timeout value in milliseconds

                                    Default value = 2000

int rTimeOut = TCP Receive message timeout value in milliseconds

                                    Default value = 2000

unsigned char ticktime = (optional) Protocol Tick time (see below)

                              Default value = 10
                              Minimum value = 0
                              Maximum value = 15

unsigned char timeoutticks = (optional) TickTimes multiplier (see below)

Default value = 14

Minimum value = 1

Maximum value = 255

unsigned char timeoutmultiplier = (optional) Inactivity timeout (see below)

Default value = 1

Minimum value = 1

Maximum value = 255

unsigned long otrpi = (optional) Originator->Term Reqested packet interval (u-sec)

Default value = 2064960

unsigned long torpi = (optional) Terminator->Orig Reqested packet interval (u-sec)

                                     Default value = 2064960

 

This function stores timeout parameter values for use by the member functions of the class.

The values sTimeOut and rTimeOut are used to determine the maximum time that will elapse for a single user level call (read or write, respectively) to transfer data to or from the PLC.  If this timeout is exceeded, the I/O request will return to the caller indicating a timeout has occurred.

The remaining values are used to define the PLC’s connection session timeout information.  The values ticktime and timeoutticks are used to calculate the maximum time allowed for a connection request to be serviced by the PLC.  If the PLC cannot establish a connection session within this amount of time, the Connect method will return to the caller an error indicating that a timeout has occurred.  This timeout value is calculated by the following formula:

Connection_Timeout (ms) = 2^(ticktime) * timeoutticks

 

The values timeoutmultiplier otrpi (which stands for Originator->Terminator Requested Packet Interval) and torpi (Terminator->Originator Requested Packet Interval) determine the inactivity timeout of the PLC session.  If this timeout is exceeded BETWEEN calls to the driver (more precisely, between protocol messages sent between the control system and the PLC), the PLC connection session will time out, and the connections to the PLC must be rebuilt.  Subsequent user calls to the driver to transfer data between the control system and the PLC will find the connection destroyed and will return an error.  This timeout value is calculated by the following formula:

Inactivity_Timeout (u-sec) = 4 * 2^(timeoutmultiplier) * min (otrpi, torpi)

Using the default values, the connection timeout and inactivity timeout are:

Connection_Timeout (ms) = 2^(ticktime) * timeoutticks

= 2^10 * 14

= 1024 * 14

= 14336

Connection_Timeout (seconds) = 14.336

Inactivity_Timeout (u-sec) = 4 * 2^(timeoutmultiplier) * min (otrpi, torpi)

= 4 * 2^1 * min (2064960, 2064960)

= 4 * 2 * 2064960

= 16519680

Inactivity_Timeout (seconds) = 16.51968

 

  • int SetConnectionID (unsigned int connid);

where:

unsigned int connid = Logical Connection ID

                       Default value = 0x0b000100

This function stores a new value for the Logical Connection ID parameter

 

  • int SetConnectionSN (unsigned short connsn);

where:

unsigned short connsn = Logical Connection Serial Number

 

This function stores a new value for the Logical Connection Serial Number

 

  • int SetOriginatorInfo(unsigned short vendorid,  unsigned int sn);

where:

unsigned short vendorid = Originator (local system) vendor ID

default value = 1

unsigned int sn = Originator Sequence Number

default value = 0xBC1C0042

This function stores new values for the Originator (local system) information

 

  • int Connect (char *hostname, short int port);

where:

char *hostname = host name, or

IP addresses expressed as a character string

short int port = TCP/IP port number name, or

 

This function establishes a connection between the computer system and the Allen-Bradley Control Logix PLC. Note that if a connection has already been established with a given connection serial number, no other connection may be made to that PLC with the same connection serial number until that connection is either gracefully disconnected or has timed out due to inactivity.

 

  • int Disconnect ();

This function breaks a connection between the computer system and the Allen-Bradley Control Logix PLC

 

  • int readClPccc (int adrType, void *FileName, int offset, int noElements,

                                 int dataType, void *buf);

where:

int adrType = address type

void *FileName = file name within PLC from which to read data

int offset = offset (in data variables) from which to start data read

int noElements = number of data elements to read

int dataType = type of data to be read

void *buf = address of user supplied data buffer

This function reads a single data block from the PLC and stores the results in a user defined buffer.

Offsets may work in one of two ways.  If the PLC contains a variable array called by a file name of “PLCVars”, function calls to retrieve data starting at the 61st element of this array could contain 2nd and 3rd arguments of:

“PLCVars”, 60

or,

“PLCVars[60]”, 0

Legal values for the dataType argument are:

CL_SINT – 1-byte integers

CL_INT – 2-byte integers

CL_DINT – 4-byte integers

CL_REAL – IEEE 4-byte floating point numbers

 

  • int writClPccc (int adrType, void *FileName, int offset, int noElements,

                                 int dataType, void *buf);

where:

int adrType = address type

void *FileName = file name within PLC to write user data

int offset = offset (in data variables) from which to start data write

int noElements = number of data elements to write

int dataType = type of data to be written

void *buf = address of user supplied data buffer containing write data

This function writes a single data block to the PLC from the user defined buffer. Offsets may work in one of two ways. If the PLC contains a variable array called by a file name of “PLCVars”, function calls to write data starting at the 61st element of this array could contain 2nd and 3rd arguments of:

“PLCVars”, 60

or,

“PLCVars[60]”, 0

Legal values for the dataType argument are:

CL_SINT – 1-byte integers

CL_INT – 2-byte integers

CL_DINT – 4-byte integers

CL_REAL – IEEE 4-byte floating point numbers

 

  • int readClCip (void *FileName, int offset, int noElements, int *dataType, void *buf);

where:

void *FileName = file name within PLC from which to read data

int offset = offset (in data variables) from which to start data read

int noElements = number of data elements to read

int *dataType = pointer to an integer variable where the type of the data read shall be returned

void *buf = address of user supplied data buffer

This function reads a single data block from the PLC and stores the results in a user defined buffer.

Legal values returned in the dataType variable are:

CL_SINT – 1-byte integers

CL_INT – 2-byte integers

CL_DINT – 4-byte integers

CL_REAL – IEEE 4-byte floating point numbers

 

  •  int writClCip (void *FileName, int offset, int noElements, int dataType, void *buf);

where:

void *FileName = file name within PLC to write user data

int offset = offset (in data variables) from which to start data write

int noElements = number of data elements to write

int dataType = type of data to be written

void *buf = address of user supplied data buffer containing write data

This function writes a single data block to the PLC from the user defined buffer.

Legal values for the dataType argument are:

CL_SINT – 1-byte integers

CL_INT – 2-byte integers

CL_DINT – 4-byte integers

CL_REAL – IEEE 4-byte floating point numbers

Expand
titleProcess Driver Mainline

Some comments on the driver program are below:

This test program, on each expiration of the process timer, writes a single block of data to the PLC and then reads a single block of data.  This sequence, the number of reads and writes, their addresses, and the sizes of the blocks can be modified to fit the requirements of the application.

PlcUsr and the ‘datagram’ structures they reference should be modified as required to reference appropriate variables in application variables for transfer between the PLC and the control system.

 A sample driver is provided in the examples subdirectories of the standard Tsentry distribution

Modicon PLC Driver

Expand
titleCapabilities

This driver:

  • Communicates with Modicon (Schneider Automation) TSX Quantum PLC systems

  • Uses TCP/IP Communications over:

    • Standard Ethernet network connection

    • High Speed dedicated process I/O network with deterministic network performance

  • Software implemented as a C++ Class

  • Multiple PLC support

  • Supports:

    • Read Variables

    • Write variables

Capable of running 500ms Input and Output scan rep rates, depending on data buffer size.

Expand
titleModicon PLC Configuration

The Modicon PLC must be set up with the proper IP address.  This configuration is completed with the Schneider Automation software.  The IP must be chosen such that it lies within the subnet selected for the specific Ethernet controller used for communications.

If the Ethernet controller is one that is controlled by the Windows 2000 system, the subnet is specified in the network setup utility of the control panel.

If the Ethernet controller is one that is controlled by the RTX Real-Time TCP/IP controller, the IP address is specified in the file d:\LocNtRt\sys\pif\RtxTcp.ini. 

Enough memory must be installed in the PLC to support the data buffer size that will be requested by the software reads and writes.

Expand
titleSoftware Driver

The core of the driver is provided as a C++ class that implements the initialization and communications functions.  A sample process is provided which calls the appropriate class members.

The IP address, configuration information, and data areas to be read and written are passed as calling parameters to the class functions.

The following is a list of the provided driver files.  After review of the example driver, the user is required to modify the files as indicated:

File Name

Description

Modification

ModPlc.cpp

Driver mainline function

Modify configuration class calls for specific PLC configuration.  Modify locations to read and write data.  Modify input and output datagram structure definition

ModPlcIn.cpp

ModPlc driver initialization

Insert required global common areas. 

PlcUsr.cpp

Process received values from PLC datagram and place in user data variables.

Get application variables and store in datagra for transmission to PLC

Change as required

TpriModPlc Class Descriptions

Expand
titleOverview

The Tsentry tpriModPlc class encapsulates the functionality required to communicate with the Modicon Quantum PLCs over a TCP/IP network.

Expand
titleClass Inferface

The following public member functions are provided as part of the tpriModPlc class:

  • tpriModPlc *pModPlc = new tpriModPlc;

Allocate a new tpriModPlc object

 

  • destroy (tpriModPlc *)pModPlc();

Destroy the tpriModPlc class object.

 

 

  • int SetTraceLevel (int TraceLevel);

where:

int TraceLevel = debug trace level for class operations

                           default value = 30

                           valid values range between 0 and 100, inclusive

                           lower values produce less debug information

                           higher values produce more debug information

                           debug information written using LogMsg function

This function stores a new value for the TraceLevel parameter

 

  • int SetTimeOut (int sTimeOut, int rTimeOut, unsigned char ticktime,

                              unsigned char timeoutticks, unsigned char timeoutmultiplier,

                              unsigned long otrpi, unsigned long torpi );

where:

int sTimeOut = Send message timeout value in milliseconds

                                    Default value = 2000

int rTimeOut = receive message timeout value in milliseconds

                                    Default value = 2000

This function stores timeout parameter values for use by the member functions of the class

 

  • int int SetDestinationInfo(unsigned char destID);

where:

unsigned short vendorid = Destination ID

default value = 1

This function stores new values for the Destination ID

 

  • int SetPduMaxIoDataBytes (int noBytes);

where:

int noBytes = the maximum number of data bytes that will be placed in a single PDU

                           default value = 125

                           a PDU is a protocol Data Unit and is equivalent to a single Ethernet frame   

                           valid values range between 2 and 125, inclusive

                           lower values may produce more frames to transfer the same user data

                           higher values may produce fewer frames to transfer the same user data

This function sets a new value for the maximum number of user data bytes to be included in a single Ethernet frame (PDU) that is transmitted to the PLC.  A value too low will increase the number of Ethernet frames that will be required to send a given number of user data bytes and reduce throughput. A number too high will not be understood or acknowledged by the PLC.  

 

  • int Connect (char *hostname, short int port);

where:

char *hostname = host name, or

IP addresses expressed as a character string

short int port = TCP/IP port number

This function establishes a connection between the computer system and the Modicon PLC

 

  • int Disconnect ();

This function breaks a connection between the computer system and the Modicon PLC

 

  • int read4x (int offset, int noElements, void *buf);

where:

int offset = PLC memory offset in 16 bit words from which to read data

int noElements = number of 16 bit integer data elements to read

void *buf = address of user supplied data buffer

This function reads a single data block of 16 bit integers values from the PLC user register memory starting at ‘offset’ words from 40000 and stores the results in a user defined buffer

 

  • int writ4x (int offset, int noElements, void *buf);

where:

int offset = PLC memory offset in 16 bit words from which to write data

int noElements = number of 16 bit integer data elements to write

void *buf = address of user supplied data buffer

This function writes a single block of user supplied 16 bit data words to the PLC user register memory starting at ‘offset’ words after 40000

Expand
titleProcess Driver Mainline

Some comments on the driver program follow:

This test program, on each expiration of the process timer, writes a single block of data to the PLC and then reads a single block of data.  This sequence, the number of reads and writes, their addresses, and the sizes of the blocks can be modified to fit the requirements of the application.

PlcUsr and the ‘datagram’ structures they reference should be modified as required to reference appropriate variables in application variables for transfer between the PLC and the control system.

 A sample driver is provided in the examples subdirectories of the standard Tsentry distribution.

VMIC Reflective Memory Driver

Expand
titleCapabilities

This driver provides an interface to an internal VMIC reflective memory card. It manages both reading and writing variables to the card’s onboard memory, which the card automatically synchronizes with all other cards on the optical network. The driver supports the following:

  • Operation in both Win32 and RTSS environment

  • Support for both VMICPCI-5576 and VMICPCI-5579 cards

  • Ini file configuration of read and write variable transfers

Expand
titleVMIC Card Configuration

There is no specific card configuration required for the VMIC reflective memory driver. Simply put the card into an empty full-length PCI slot, and the software driver manages the rest.

Expand
titleConfiguration File

The VMIC driver is configured by a flat ASCII file divided into [Sections].  The following sections are required in this file:

[General]

This section defines general parameters for the VMIC device.  The parameters are specified in the standard Key=Value pair format.

  • DeviceIdx=1

Defines the device index of the card you wish to use. By default this value is 1, and unless you have more than one VMIC card, this parameter is not needed.

  • DeviceType=PCI-5576

Defines the card type that you wish to use. Supported values are ‘PCI-5576’ and ‘PCI-5579’ (no quotes).  If this parameter is not specified, the driver will search for the first supported device that it can find.

  • ChkOverlap=0

This optional flag sets whether or not the driver will check your variable list to make sure that no two variables overlap one another in the VMIC memory buffer. For instance, two variables may mistakenly both be configured to write to the same bytes on the card. If this flag is set the driver will detect this overlap and fail to initialize. A message will be logged to the console to indicate the offending variables, and the ini file will need to be corrected before the driver will work.  By default this option is enabled; set the flag to 0 to turn it off. 

  • IODescFile=d:\MyIODesc.txt

This optional parameter specifies an output text file to which the VMIC driver will write a complete description of all variables and their associated offsets into the VMIC reflective memory buffer.  This is particularly useful when transferring entire structures and you want to know the offsets for each of the constituent variables contained in those structures.

 [VarDef]

This section defines all variables that are to be read from or written to the reflective memory segment. Each line in this section defines a single variable in a set of whitespace-delimited fields:

#Variable Name

#Read/Write

#Offset

#RemoteType

MyWriteStruct.MyWriteVar  

W

0x1000

MyReadStruct.MyReadVar       

R

0x2000

VT_I2

Empty lines or lines beginning with the ‘#’ symbol are ignored.

 

The fields for each variable are:

  • #VariableName

The variable name within the TSENTRY data dictionary (identical to that used by Probe, etc.).  Besides individual variables, entire arrays or structures may also be specified.

  • #Read/Write

Flag specifying whether the variable is to be read from the card (R) or written to the card (W).

  • #Offset

Offset into the VMIC onboard memory where this variable is to be read from or written to. This value can be specified in hex with the ‘0x’ prefix or in decimal.  The data will be reflected in the memory of all other VMIC cards in the ring at this same offset. Note that offsets 0x00-0x3F are reserved for use by the VMIC card and cannot be used for reflected data.

  • #RemoteType

Optional parameter used if the data on the card should be interpreted in a format different from that inside the PC’s internal memory. Typically this is used if the internal variable is a 4-byte integer but should be read/written as a 2-byte integer. This parameter applies only if an individual variable is specified; it will not automatically convert arrays or elements inside of structures.  The following remote types are supported:

VT_I1        1-byte integer (C/C++ character)

VT_I2        2-byte integer (C/C++ short)

VT_I4        4-byte integer (C/C++ long)

VT_I8        8-byte integer (C/C++ __int64)

VT_R4        1-byte integer (C/C++ float)

VT_R8        1-byte integer (C/C++ double)

Expand
titleClass Interface

The following public member functions are provided as part of the tpriVmic class:

  •  tpriVmic::tpriVmic()

    • Constructor for the VMIC driver object.

  •  tpriVmic::~tpriVmic()

    • Destructor for the VMIC driver object.

  • int tpriVmic:: initDrv(char *fileName)
    Initialize the VMIC driver with the specified ini file.

    • Inputs:
      char * fileName                        Configuration file name.

    • Return value:
      Zero indicates success, non-zero indicates failure.

  • int tpriVmic::writeIODesc()
    Write the I/O decription table to the specified file on disk.

    • Inputs:
      char * fileName                        Output file name.

    • Return value:
      Zero indicates success, non-zero indicates failure.

  •  int tpriVmic::runDrv()
    Run the VMIC driver state machine.  This function should be called iteratively in the main loop of the driver process.

    • Return value:
      Zero indicates success, non-zero indicates failure.

Expand
titleProcess Driver Mainline

A sample driver is provided in the examples subdirectories of the standard TSENTRY distribution.