lnxsdk-rm001_-en-e
lnxsdk-rm001_-en-e
lnxsdk-rm001_-en-e
Manual
Version 6.40.00
Activities including installation, adjustments, putting into service, use, assembly, disassembly, and maintenance are required to be carried out by suitably trained
personnel in accordance with applicable code of practice.
If this equipment is used in a manner not specified by the manufacturer, the protection provided by the equipment may be impaired.
In no event will Rockwell Automation, Inc. be responsible or liable for indirect or consequential damages resulting from the use or application of this equipment.
The examples and diagrams in this manual are included solely for illustrative purposes. Because of the many variables and requirements associated with any particular
installation, Rockwell Automation, Inc. cannot assume responsibility or liability for actual use based on the examples and diagrams.
No patent liability is assumed by Rockwell Automation, Inc. with respect to use of information, circuits, equipment, or software described in this manual.
Reproduction of the contents of this manual, in whole or in part, without written permission of Rockwell Automation, Inc., is prohibited.
Throughout this manual, when necessary, we use notes to make you aware of safety considerations.
WARNING: Identifies information about practices or circumstances that can cause an explosion in a hazardous environment, which may lead to personal
injury or death, property damage, or economic loss.
ATTENTION: Identifies information about practices or circumstances that can lead to personal injury or death, property damage, or economic loss.
Attentions help you identify a hazard, avoid a hazard, and recognize the consequence.
IMPORTANT: Identifies information that is critical for successful application and understanding of the product.
These labels may also be on or inside the equipment to provide specific precautions.
SHOCK HAZARD: Labels may be on or inside the equipment, for example, a drive or motor, to alert people that dangerous voltage may be present.
BURN HAZARD: Labels may be on or inside the equipment, for example, a drive or motor, to alert people that surfaces may reach dangerous
temperatures.
ARC FLASH HAZARD: Labels may be on or inside the equipment, for example, a motor control center, to alert people to potential Arc Flash. Arc Flash
will cause severe injury or death. Wear proper Personal Protective Equipment (PPE). Follow ALL Regulatory requirements for safe work practices and for
Personal Protective Equipment (PPE).
Tip: Identifies information that is useful and can help to make a process easier to do or easier to understand.
Rockwell Automation recognizes that some of the terms that are currently used in our industry and in this publication are not in alignment with the movement toward
inclusive language in technology. We are proactively collaborating with industry peers to find alternatives to such terms and making changes to our products and content.
Please excuse the use of such terms in our content while we implement these changes.
SDK Interface........................................................................................................................................................................................................................................... 6
DTL_INIT.................................................................................................................................................................................................................................................................................. 25
DTL_CreateDtsa......................................................................................................................................................................................................................................................................26
DTL_CreateDtsaFromPathString..........................................................................................................................................................................................................................................27
DTL_PCCC_MSG_W................................................................................................................................................................................................................................................................. 28
DTL_PCCC_MSG_CB................................................................................................................................................................................................................................................................32
DTL_ASA_OPEN....................................................................................................................................................................................................................................................................... 34
DTL_ASA_CLOSE......................................................................................................................................................................................................................................................................35
DTL_ASA_MSG_W.................................................................................................................................................................................................................................................................... 35
DTL_ASA_MSG_CB...................................................................................................................................................................................................................................................................35
DTL_CIP_CONNECTION_OPEN...............................................................................................................................................................................................................................................36
DTL_CIP_CONNECTION_CLOSE............................................................................................................................................................................................................................................. 38
DTL_CIP_LARGE_CONNECTION_OPEN..................................................................................................................................................................................................................................39
DTL_CIP_LARGE_CONNECTION_CLOSE................................................................................................................................................................................................................................40
DTL_CIP_MESSAGE_SEND_CB................................................................................................................................................................................................................................................41
DTL_CIP_MESSAGE_SEND_W.................................................................................................................................................................................................................................................43
DTL_OpenDtsa........................................................................................................................................................................................................................................................................ 45
DTL_CloseDtsa........................................................................................................................................................................................................................................................................46
DTL_DestroyDtsa....................................................................................................................................................................................................................................................................47
DTL_UNINIT.............................................................................................................................................................................................................................................................................48
DTL_ERROR_S......................................................................................................................................................................................................................................................................... 48
DTL_DRIVER_OPEN.................................................................................................................................................................................................................................................................48
DTL_DRIVER_CLOSE...............................................................................................................................................................................................................................................................50
DTL_GetDriverIDByDriverName.............................................................................................................................................................................................................................................51
DTL_GetHandleByDriverName...............................................................................................................................................................................................................................................51
DTL_GetDstDriverIDByDriverName...................................................................................................................................................................................................................................... 52
DTL_GetNetworkTypeByDriverName...................................................................................................................................................................................................................................53
DTL_MaxDrivers......................................................................................................................................................................................................................................................................54
DTL_DRIVER_LIST_EX............................................................................................................................................................................................................................................................ 54
DTL_SetDriverListEntryType................................................................................................................................................................................................................................................ 55
DTL_GetTypeFromDriverListEntry....................................................................................................................................................................................................................................... 56
DTL_GetHandleFromDriverListEntry................................................................................................................................................................................................................................... 56
DTL_GetDriverNameFromDriverListEntry...........................................................................................................................................................................................................................57
DTL_GetNetworkTypeFromDriverListEntry.........................................................................................................................................................................................................................57
DTL_GetDriverIDFromDriverListEntry..................................................................................................................................................................................................................................57
DTL_GetDstDriverIDFromDriverListEntry............................................................................................................................................................................................................................59
DTL_GetStationFromDriverListEntry...................................................................................................................................................................................................................................60
DTL_GetMTUFromDriverListEntry........................................................................................................................................................................................................................................60
DTL_GetServerNameFromDriverListEntry..........................................................................................................................................................................................................................60
DTL_GetDriverAliasFromDriverListEntry............................................................................................................................................................................................................................. 61
DTL_GetDriverListEntryFromDriverListIndex..................................................................................................................................................................................................................... 61
DTL_CreatetDriverList............................................................................................................................................................................................................................................................61
DTL_DestroyDriverList.......................................................................................................................................................................................................................................................... 62
DTL_GetNameByDriverId.......................................................................................................................................................................................................................................................62
DTL_CIP_CONNECTION_SEND............................................................................................................................................................................................................................................... 63
DTL_CIP_CONNECTION_PACKET_PROC................................................................................................................................................................................................................................64
DTL_CIP_CONNECTION_STATUS_PROC................................................................................................................................................................................................................................65
DTL_IO_CALLBACK _PROC..................................................................................................................................................................................................................................................... 67
Global Header......................................................................................................................................................................................................................................................................... 67
Example: Send the PCCC request to the ControlLogix, SLC, or PLC controllers in a synchronized method.........................................................................................................93
Legal Notices........................................................................................................................................................................................................................................108
Legal Notices........................................................................................................................................................................................................................................................................108
SDK Interface
How do I open the SDK Interface?
1. From the Start menu, select Rockwell Software > FactoryTalk Linx Gateway Configuration.
2. Select SDK Interface.
Starting with version 6.31.00, the FactoryTalk Linx Software Development Kit (SDK) provides a collection of software
development tools that permit custom-built software to communicate with automation equipment using an
Application Program Interface (API) in FactoryTalk Linx. This enables the custom-built software to communicate
to devices using the Open Vendor Device Association (ODVA) Common Industrial Protocol (CIP) to access services
and certain forms of device data. By using the API, the custom-built software must manage most aspects of the
communications and does not currently provide access to FactoryTalk Linx shortcut data optimization. To enable
custom-built software to access the API, FactoryTalk Linx Gateway must detect an appropriate activation, and access
to the API must be enabled in the FactoryTalk Linx Gateway configuration user interface.
Tip:
◦ This API utilizes a similar approach and many similar commands as the RSLinx Classic C-
SDK. For more information, refer to Overview of SDK reference calls on page 14.
◦ You can use Ctrl+rotate the mouse wheel to zoom in or zoom out the SDK Interface tab.
• DTL_ErrorCode.h
Defines all error codes returned by the SDK Interface.
• DTLMsgCommon.h
Defines the common data structures used in the SDK Interface.
• FTLinx_SDK.dll
The SDK Interface's dynamic link library which will be used when running the applications.
• FTLinx_SDK.h
The header file that defines all interfaces provided by the SDK Interface.
• FTLinx_SDK.lib
The SDK Interface's static library which will be used when compiling the applications.
• Standard Activation
Permits communications with a single device at a time.
• Extended, Distributed, or Professional Activation
Permits communications to multiple devices simultaneously. The SDK Interface supports up to 200 clients
and 200 devices.
Items Descriptions
Activation Status Shows the status of the FactoryTalk Linx Gateway activations.
Refer to Activation types on page for more information.
Enable access to the SDK API Turns on access to the SDK API.
Access Control Specifies the clients that can access the SDK API.
• All
Grants access to all clients.
• Listed Client
Grants access to the clients in the client list. The clients
must have digital signatures.
Last Request Time Shows the time that this client last requested API access.
Items Descriptions
3. On the Details tab, check the SDK Interface version in Product version.
If the SDK Interface version and the FactoryTalk Linx version are different, change either of them to the
same version.
Connected messaging
A connected message opens a persisted link from the computer to a target device. This form of communications
allocates resources in every device in the route to ensure responses and subsequent exchanges of information are
able to pass more efficiently.
Unconnected messaging
An unconnected message permits the computer to perform a single interaction with a device. While an unconnected
message can be simpler to initiate, the entire route must be included in every request. Processing of the unconnected
message request and response are lower priority than other forms of communications making this a less efficient
form of communications.
For more information about the CIP protocol, see The Common Industrial Protocol (CIP™) and the Family of CIP
Networks.
The variable of connection structure must have a global lifecycle, because the member will be used by
the asynchronous callback process.
◦ Another parameter of the interface is an internal object identifier (IOI), which must be set to specify the
logical address of the message router.
◦ The application should provide a callback function, for example, DTL_CIP_CONNECTION_STATUS_PROC,
which the SDK Interface can call when the connection is established, closed, rejected, or timed out.
◦ These interfaces will return a connection ID for the application to use.
4. Wait for the connection to be established.
When the connection is established, the SDK Interface will call DTL_CIP_CONNECTION_STATUS_PROC.
◦ If the connection is established, the returned value will be DTL_CONN_ESTABLISHED.
◦ If the connection is not established, the returned value will be DTL_CONN_ERROR or DTL_CONN_FAILED.
5. Use the connection to send messages.
Call DTL_CIP_CONNECTION_SEND to send a CIP message. The parameter is an IOI which includes service
requests and logical segment information. For more information, see Logix 5000 Controllers Data Access.
6. Wait for the response.
The SDK Interface will asynchronously call DTL_CIP_CONNECTION_PACKET_PROC to the application if the
response is ready.
Tip: Repeat steps 5 an6 if additional communication to the CIP device is required.
Tip: You can perform additional reads and writes before closing.
2. Create a DTSA.
Call DTL_CreateDtsaFromPathString with the path and flag DTL_FLAGS_ROUTE_TYPE_CIP.
3. Send unconnected messages.
Call DTL_ASA_MSG_CB, DTL_ASA_MSG_W, DTL_CIP_MESSAGE_SEND_CB, DTL_CIP_MESSAGE_SEND_W to send
messages.
Tip: Commands ending with "W" are synchronous and will cause the software to wait for the
operation to complete. Using commands ending with "CB" operate asynchronously and will
perform a "callback" when completed.
These interfaces initiate the actual service request message across the network and transmit it.
The interface parameters include a pointer to a buffer in which the application must contain the IOI or logical
address of the target object within its CIP device. You can find the logical address format in the Logix 5000
Data Access Programming Manual. For more information, see Logix 5000 Controllers Data Access.
4. Wait for the response.
If the application sends messages using DTL_ASA_MSG_CB or DTL_CIP_MESSAGE_SEND_CB, the SDK Interface
will asynchronously call DTL_CIP_CONNECTION_PACKET_PROC.
If the application sends messages using DTL_ASA_MSG_W or DTL_CIP_MESSAGE_SEND_W, the application will
stop responding until the response returns or times out.
5. Release the DTSA.
Call DTL_DestroyDtsa to free up the DTSA resource.
Tip: You can perform multiple reads and writes to the device before releasing the DTSA.
Tip: Commands ending with "W" are synchronous and will cause the software to wait for the
operation to complete. Using commands ending with "CB" operate asynchronously and will
perform a "callback" when completed.
Tip: You can perform multiple reads and writes to the device before releasing the DTSA.
The Common Industrial Protocol (CIP), supported by ODVA, is an industrial protocol for industrial automation
applications.
The Programmable Controller Communication Commands protocol (PCCC) lets you deal with the legacy poll or
response messages to arrays of data. It is the core message that moves easily between DF1, DH485, DH+, AB/Enet, and
Ethernet/IP with the PCCC encapsulation.
DTL_INIT on page This interface must The SDK Interface. The SDK Interface's N/A Only when this
25 be called before The maximum size internal data and interface succeeds,
other interfaces of the internal data. the FactoryTalk the other interfaces
because it starts The value of this Linx Gateway can be executed
the SDK Interface's parameter will be activation correctly. The
internal data set as 0 by default. DTL_UNIT must
and checks the be called at last,
activation license. which will free up
This interface the SDK interface's
must be called with resources.
DTL_UNIT in pairs.
DTL_CreateDtsa on This interface A DTSA structure Allocate memory N/A The application can
page 26 is only for for the DTSA compose the DTSA
composing the structure. content by itself
DTSA content by based on the DTSA
the application. We structure returned
do not recommend by this interface.
that you use this
interface.
We recommend
that you use
DTL_CreateDtsaFro
mPathString.
This interface
must be called with
DTL_DestroyDtsa
in pairs. When the
DTSA is no longer
used, you must
close it.
Tip: The Device
Transport System
Access (DTSA) is a
cache utilized by
the DTL interface
to hold route
information and
state information to
communicate with
a device.
DTL_CreateDtsaFro This interface A utility DTSA Allocate memory N/A The application
mPathString on starts a utility DTSA structure for the DTSA can send requests
page 27 with a valid path. It structure and to the controller
must be called with assign the path. along with the DTSA
DTL_DestroyDtsa The DTSA is an returned by this
in pairs. When the internal handle of interface.
DTSA is no longer the SDK Interface,
used, you must which represents a
close it. controller.
The path indicates
a topology path of
a controller in the
FactoryTalk Linx
server.
For example,
<MachineName>!<D
riverName>\<IP>\B
ackplane\<SlotNum
ber >or
<MachineName>!<D
riverName>\<IP>.
Tip: You can
right-click a device
in the FactoryTalk
Linx Browser, and
then select Device
Properties to get
the path.
DTL_PCCC_MSG_W This interface The PCCC request The FactoryTalk PCCC The response
on page 28 sends the PCCC Linx Transport will be received
requests. It is synchronously
not required in other threads.
to establish This interface
the connection will not block the
previously application.
DTL_PCCC_MSG_CB This interface The PCCC request The FactoryTalk PCCC The response
on page 32 sends the PCCC Linx Transport will be received
requests to receive asynchronously
the response in other threads.
asynchronously This interface
through the will not block the
callback function application.
set by this
interface.
It is not required
to establish
connection
previously.
Architecture (ASA)
is the Rockwell
Automation internal
name for the
protocol that is
renamed CIP by
ODVA.
DTL_ASA_CLOSE on This interface A specified This interface CIP The CIP connection
page 35 will call the connection ID builds and sends will be no longer
DTL_CIP_CONNECTI a Forward_Close used.
ON_CLOSE that service request
closes and to the Message
releases a CIP Router to close
connection opened and releases a
by DTL_ASA_OPEN. CIP connection
that associated
with the specified
connection ID.
DTL_ASA_MSG_W on This interface A CIP request and This interface CIP This interface
page 35 will call the an unconnected initializes a CIP will block the
DTL_CIP_MESSAGE_ connection request and an application. When
SEND_W which unconnected it succeeds, the
sends the CIP connection. application can
requests through get the response
an unconnected directly.
connection to wait
for the response to
the application.
DTL_ASA_MSG_CB This interface A CIP request and This interface CIP This interface
on page 35 will call an unconnected initializes a CIP will not block the
DTL_CIP_MESSAGE_ connection request and an application. When
SEND_CB which unconnected it succeeds, the
sends the CIP connection and application will
requests through registers a callback keep moving,
an unconnected function that will and the callback
connection send the response function will
to receive to the application. receive the
the response response
asynchronously asynchronously.
through the
callback function
set by this
interface.
DTL_CIP_CONNECTI This interface will A specified This interface CIP The CIP connection
ON_CLOSE on page close and release connection ID builds and sends will be no longer
38 a CIP connection a Forward_Close used.
opened by the service request
DTL_CIP_CONNECTI to the Message
ON_OPEN. Router to close
and releases a
CIP connection
associated with
the specified
connection ID.
DTL_CIP_LARGE_CO This interface A large CIP This interface is CIP Get a connection
NNECTION_OPEN on will establish a connected different from the ID if this interface
page 39 CIP connected connection DTL_CIP_CONNECTI succeeds. You
connection to the structure ON_OPEN. The must send and
specified controller. difference is in receive messages
The connection the data type along with this
can convey much and bit-field connection ID later.
bigger buffer assignments of
messages between the O to T and
the application and T to O Network
controller. Connection
This interface must parameters. For
be called with the example, the
DTL_CIP_LARGE_CO size can be up to
NNECTION_CLOSE 4000 bytes for the
in pairs. When the Ethernet.
connection is no
DTL_CIP_LARGE_CO This interface A specified This interface CIP The CIP connection
NNECTION_CLOSE will close and connection ID builds and sends will be no longer
on page 40 release a large a Forward_Close used.
CIP connection service request
opened by the to the Message
DTL_CIP_LARGE_CO Router to close
NNECTION_OPEN. and releases a
CIP connection
associated with
the specified
connection ID.
DTL_CIP_MESSAGE_ This interface A CIP request and This interface CIP This interface
SEND_CB on page sends the CIP an unconnected starts a CIP will not block the
41 requests through connection request and an application. When
an unconnected unconnected it succeeds, the
connection connection and application will
to receive registers a callback keep moving,
the response function that will and the callback
asynchronously send the response function will
through the to the application. receive response
callback function asynchronously.
set by this
interface.
DTL_CIP_MESSAGE_ This interface A CIP request and This interface CIP This interface
SEND_W on page sends the CIP an unconnected starts a CIP will block the
43 requests through connection request and an application. When
an unconnected unconnected it succeeds, the
connection to wait connection. application can
for the response to get the response
the application. directly.
DTL_OpenDtsa on This interface A utility DTSA This interface N/A When this interface
page 45 will call the marks the DTSA succeeds, the
DTL_DRIVER_OPEN being used. application
which marks the can call the
DTSA being used. interface, like the
We do not DTL_GetNameByDri
recommend that verId, to get the
you use it because driver's name
it is only used for corresponding to
RSLinx Classic. the DTSA.
DTL_CloseDtsa on This interface A utility DTSA This interface N/A When this interface
page 46 will call the marks the DTSA not succeeds, the
DTL_DRIVER_CLOSE being used. application cannot
which marks the get the driver
DTSA not being namedriver's name
used. corresponding
to the DTSA
through the
DTL_GetNameByDri
verId.
DTL_DestroyDtsa on This interface A DTSA This interface frees N/A The DTSA will be no
page 47 will free up the up the DTSA. longer used.
DTSA's memory
returned by the
DTL_CreateDtsaFro
mPathString or
DTL_CreateDtsa.
DTL_ERROR_S on This interface Error code ID Map of the SDK N/A Get the error
page 48 interprets error Interface that maps message content
codes generated by the error code ID to which represents
the SDK Interface error messages. the meaning of
to a null-terminated error codes.
ASCII string text
message.
DTL_DRIVER_OPEN This interface Driver ID This interface N/A When this interface
on page 48 marks the driver marks the driver succeeds, the
being used. being used. application
can call the
interfaces, like the
DTL_GetNameByDri
verId, to get name
of driver.
DTL_DRIVER_CLOSE This interface Driver ID This interface N/A When this interface
on page 50 marks the driver marks the driver succeeds, the
not being used. not being used. application cannot
get the driver
namedriver's
name through the
DTL_GetNameByDri
verId.
DTL_GetDriverIDByD This interface gets Driver name FTLinx topology N/A Get the FactoryTalk
riverName on page the driver ID of the Linx driver
51 FactoryTalk Linx ID, such as
server from the LINXE_DRVTYPE_ET
driver's name. HERNET,
LINXE_DRVTYPE_D
F1, and
LINXE_DRVTYPE_VB
ACKPLANE defined
in FTLinx_SDK.h.
DTL_GetHandleByDr This interface gets Driver name FactoryTalk Linx N/A Get the driver
iverName on page the driver handle driver list handle to identify
51 which represents the specified driver
the address of this object.
driver object from
the driver's name.
DTL_GetDstDriverID This interface gets Driver name FactoryTalk Linx N/A Get the FactoryTalk
ByDriverName on the driver ID that topology Linx driver
page 52 is the same as the ID, such as
returned by the LINXE_DRVTYPE_ET
DTL_GetDriverIDByD HERNET,
riverName. LINXE_DRVTYPE_D
F1, and
LINXE_DRVTYPE_VB
ACKPLANE
defined in the file
FTLinx_SDK.h.
DTL_GetNetworkTyp This interface gets Driver name FactoryTalk Linx N/A Get the driver
eByDriverName on the driver network topology network type
page 53 type from the driver from the driver
namedriver's name. namedriver's
name, such as
DTL_NETTYPE_EN
ET, and
DTL_NETTYPE_VBP
defined in the file
FTLinx_SDK.h.
DTL_DRIVER_LIST This interface The driver list FactoryTalk Linx N/A Get the
_EX on page 54 will fetch a new memory that topology corresponding
driver list from the started by the driver structure
current FactoryTalk DTL_SetDriverListE list according to
Linx server. ntryType. the driver type
Before calling setting for the
this interface, DTL_SetDriverListE
you must call the ntryType, such as
DTL_SetDriverListE DTL_DVRLIST_TY
ntryType to start PE2 and
the first entry in the DTL_DVRLIST_TYPE
block of memory _EX.
that receives the
driver list.
DTL_SetDriverListE This interface The driver list block FactoryTalk Linx N/A This interface
ntryType on page must be called and driver type. topology starts a specific
55 before calling the The driver driver list block to
DTL_DRIVER_LIST_ type includes receive the driver
EX. It starts DTL_DVRLIST_TY information of the
the first entry PE2 and
DTL_GetTypeFromD This interface will A specific driver Driver object N/A Get the driver type
riverListEntry on return the specified to determine what
page 56 driver's type. to do next.
DTL_GetHandleFro This interface will A specific driver Driver object N/A Get members of
mDriverListEntry on return a handle the driver structure
page 56 for the specified directly.
driver. The handle
represents the
address of this
driver object.
DTL_GetDriverName This interface will A specific driver Driver object N/A Get the driver's
FromDriverListEntry return the specified name to determine
on page 57 driver's name. what to do next.
DTL_GetNetworkTyp This interface A specific driver Driver object N/A Get the network
eFromDriverListEn will return the type, such as
try on page 57 network type of the DTL_NETTYPE_EN
specified driver. ET,
DTL_NETTYPE_VBP
and so on.
DTL_GetDriverIDFro This interface will A specific driver Driver object N/A This driver ID can
mDriverListEntry on return the specified represent the
page 57 driver's ID. SDK Interface
driver's ID, such as
DTL_DVRTYPE_ETH
ERNET and
DTL_DVRTYPE_VBAC
KPLANE, or
represent the
handle of this
driver.
DTL_GetDstDriverID This interface is A specific driver Driver object N/A Refer to the
FromDriverListEntry the same as the DTL_GetDriverIDFro
on page 59 DTL_GetDriverIDFro mDriverListEntry.
mDriverListEntry.
DTL_GetStationFro This interface will A specific driver Driver object N/A N/A
mDriverListEntry on return the specified
page 60 driver's station
address.
DTL_GetMTUFromDr This interface will A specific driver Driver object N/A N/A
iverListEntry on return the specified
page 60 driver's maximum
transmission unit.
DTL_GetServerNam This interface will A specific driver Driver object N/A N/A
eFromDriverListEn return the specified
try on page 60 driver's server
name.
DTL_GetDriverAliasF This interface will A specific driver Driver object N/A N/A
romDriverListEntry return the specified
on page 61 driver's name. It
is the same as the
DTL_GetDriverName
FromDriverListEnt
ry.
DTL_GetDriverListE This interface will Index of the driver Driver list N/A N/A
ntryFromDriverListI return a driver list
ndex on page 61 entry from a list.
DTL_CreateDriverL This interface will A variable indicates FactoryTalk Linx N/A Enumerate every
ist on page 61 fetch all drivers that the driver topology driver in the list.
from the current amount and a It must be
FactoryTalk Linx timeout. called with the
server and return DTL_DestroyDriverL
a pointer to a ist in pairs.
list of the struct
DTLDRIVER_EX.
DTL_DestroyDriverL This interface must The pointer Driver list N/A N/A
ist on page 62 be called with the returned by the
DTL_CreateDriverL DTL_CreateDriverLi
ist in pairs. It frees st.
up the resources
returned by the
DTL_CreateDriverLi
st.
DTL_GetNameByDri This interface will Before calling Driver list N/A N/A
verId on page 62 return the driver's this interface,
name. you must call the
DTL_DRIVER_OPEN
or DTL_OpenDtsa.
DTL_CIP_CONNECTI This interface will CIP request CIP connection CIP The response
ON_SEND on page send a packet on will be received
63 a connected CIP asynchronously
DTL_CIP_CONNECTI This interface is a This address of the FactoryTalk Linx CIP Receive the
ON_PACKET_PROC callback function callback function transport response from the
on page 64 that the application must be set to CIP connection.
can implement the interfaces
it to receive the that want to get
response package the response
to a CIP request asynchronously.
asynchronously.
DTL_CIP_CONNECTI This interface is a This address of the FactoryTalk Linx CIP Receive the CIP
ON_STATUS_PROC callback function callback function transport connection's status.
on page 65 that the application must be set to the
can implement interfaces that
it to receive create the CIP
status of current connection.
CIP connection
asynchronously.
DTL_IO_CALLBACK_ This interface is a This address of the FactoryTalk Linx PCCC Receive the
PROC on page 67 callback function callback function transport response to the
that the application must be set to the PCCC request.
can implement DTL_PCCC_MSG_CB
it to receive the as an argument.
response package
to the PCCC request
asynchronously.
DTL_INIT
The DTL_INIT starts the SDK Interface, and it will check the activation of FactoryTalk Linx Gateway. This interface
must be called before calling the others.
DTL_INIT
Parameters
Parameters Descriptions
Max_defines The maximum size of the internal data. The maximum size of
the internal data. The value of this parameter will be set as 0 by
default.
Return values
When DTL_INIT returns values of DTL_RETVAL to the client application, you can use the DTL_ERROR_S function to
interpret the return values.
DTL_CreateDtsa
The DTL_CreateDtsa will return the Device Transmision System Access (DTSA) structure by allocating a memory. We
do not recommend this interface. We recommend that you use the DTL_CreateDtsaFromPathString to create the DTSA
from a given path.
DTL_CreateDtsa
Parameters
N/A
Return values
DTL_CreateDtsaFromPathString
The DTL_CreateDtsaFromPathString creates a Device Transmision System Access (DTSA) structure in the
specified path. The DTSA contains the device's information, such as driver handle. It is required when you set up a
connection with the device or send messages to the device, and it will be used in the DTL_CIP_CONNECTION_OPEN,
DTL_CIP_MESSAGE_SEND_W, etc.
DTL_CreateDtsaFromPathString
DWORD* pError,
DWORD dwFlags
);
Parameters
Parameters Descriptions
pError pError is the returned error code, see the error codes table for
more information.
dwFlags dwFlags is the required route type. The SDK Interface supports
the follows:
• DTL_FLAGS_ROUTE_TYPE_CIP
• DTL_FLAGS_ROUTE_TYPE_PCCC
Error codes
The following table identifies the error codes that can be returned by the DTL_CreateDtsaFromPathString.
Return values
The DTL_CreateDtsaFromPathString returns the DTSA structure that can be used for interfaces, such as
DTL_CIP_CONNECTION_OPEN, DTL_CIP_MESSAGE_SEND_W, etc.
DTL_PCCC_MSG_W
The DTL_PCCC_MSG_W provides the synchronous method to allow the client applications to send the PCCC commands
directly to processors. This interface can be used when you want to read or write tags from a device via the PCCC
command. The interface call will keep waiting until the device response returns or the request is timed out. The DTSA
must be created successfully before this interface is called.
Tip: The "W" at the end of the interface indicates that the operation will be synchronous and will wait for
a response from the device or a timeout before proceeding.
DTL_PCCC_MSG_W
Parameters
Parameters Descriptions
dptr A pointer to the buffer where FactoryTalk Linx will copy the
reply data from the target processor. Only the data following the
PCCC header, not the header itself, will be copied from the reply
packet to the destination buffer.
Parameters Descriptions
FactoryTalk Linx will not copy more than this number of bytes
into the destination buffer. On output, FactoryTalk Linx stores
the actual number of bytes in the reply data in this variable.
If the client application knows that there is no reply data,
including status and extended status, it is permissible to pass a
null pointer in dptr and zero in dsize.
When dsize is a null pointer, there is no limit to the size of the
reply data, and the size is not returned to the client application.
When dsize is non-null, and the PCCC reply data is larger than
the specified size of dptr, the reply data will be copied only until
dptr is full; the remaining reply data will be discarded, and the
final completion status will be set to DTL_E_TOOBIG.
iostat A pointer to a buffer in the client application into which the final
I/O completion status will be written.
For more information, see the iostat values table.
Iostat value
The final I/O completion status code may be any one of the return values or one of the following.
Returned values
The following table identifies the error codes that can be returned by the DTL_PCCC_MSG_W.
DTL_PCCC_MSG_CB
The DTL_PCCC_MSG_CB provides the asynchronous method to allow the client application to send the PCCC
commands directly to processors. This interface can be used when you want to read or write tags from a device via
the PCCC command. The interface call will return immediately after sending out the message. The callback will be
called if the PCCC response returns from the device, or the request is timed out.
DTL_PCCC_MSG_CB
Parameters
Parameters Descriptions
Parameters Descriptions
dptr A pointer to the buffer where FactoryTalk Linx will copy the
replied data from the target processor. Only the data following
the PCCC header, not the header itself, will be copied from the
reply packet to the destination buffer.
Returned values
The following table identifies the error codes that can be returned by the DTL_PCCC_MSG_CB.
DTL_ASA_OPEN
The DTL_ASA_OPEN calls the DTL_CIP_CONNECTION_OPEN.Refer to the DTL_CIP_CONNECTION_OPEN for more details.
DTL_ASA_OPEN
DTL_ASA_CLOSE
The DTL_ASA_CLOSE calls the DTL_CIP_CONNECTION_CLOSE. Refer to the DTL_CIP_CONNECTION_CLSOE for more
details.
DTL_ASA_CLOSE
);
DTL_ASA_MSG_W
The DTL_ASA_MSG_W calls the DTL_CIP_MESSAGE_SEND_W. Refer to the DTL_CIP_MESSAGE_SEND_W for more details.
DTL_ASA_MSG_W
DTL_ASA_MSG_CB
The DTL_ASA_MSG_CB calls the DTL_CIP_MESSAGE_SEND_CB. Refer to the DTL_CIP_MESSAGE_SEND_CB for more
details.
DTL_ASA_MSG_CB
DTL_CIP_CONNECTION_OPEN
The DTL_CIP_CONNECTION_OPEN opens a connection with a CIP object. If you want to send the CIP messages to
devices via the connected method, this interface must be called to create a connection before sending messages to
the device. Connected means there has been a CIP connection before the CIP message is send to the device, which
improves the communication performance and reliability. When this interface is completed, it returns a value of type
DTL_RETVAL to the client application, and you can use the DTL_ERROR_S to interpret the returned value.
DTL_CIP_CONNECTION_OPEN
Parameters
Parameters Descriptions
Ioi Internal Object Identifier (Ioi) identifies the CIP object with
which the connection is to be established within the CIP device
specified by the target.
Returned values
The following table identifies the error codes that can be returned by the DTL_CIP_CONNECTION_OPEN.
DTL_CIP_CONNECTION_CLOSE
The DTL_CIP_CONNECTION_CLOSE closes a connection with a CIP object. The connection is created by
DTL_CIP_CONNECTION_OPEN. You must call this interface to close the CIP connection if the connection is not needed.
Calling DTL_UNINIT or exiting the application will cause the connection to be terminated but will not clean up the
connection properly.
DTL_CIP_CONNECTION_CLOSE
Parameters
Parameters Descriptions
Returned values
The following table identifies the error codes that can be returned by the DTL_CIP_CONNECTION_CLOSE.
DTL_CIP_LARGE_CONNECTION_OPEN
The DTL_CIP_LARGE_CONNECTION_OPEN is similar with the DTL_CIP_CONNECTION_OPEN but opens a large connection
with a CIP object. The MaxPacketSize is up to 65535 bytes for the Ethernet. You must call this interface to open the
CIP connection if the CIP message size is greater than 504 bytes which is the regular CIP message size.
DTL_CIP_LARGE_CONNECTION_OPEN
Parameters
Returned values
DTL_CIP_LARGE_CONNECTION_CLOSE
The DTL_CIP_LARGE_CONNECTION_CLOSE closes a large connection with a CIP object. The connection is created by
the DTL_CIP_LARGE_CONNECTION_OPEN. Calling the DTL_UNINIT or exiting the application will cause the connection
to be terminated but will not clean up the connection properly.
DTL_CIP_LARGE_CONNECTION_CLOSE
Parameters
Parameters Descriptions
Returned values
The following table identifies the error codes that can be returned by the DTL_CIP_LARGE_CONNECTION_CLOSE.
DTL_CIP_MESSAGE_SEND_CB
The DTL_CIP_MESSAGE_SEND_CB provides the asynchronous way to send a service request to a CIP object.
Asynchronous means the interface call will return immediately after sending out the message. The callback will be
called if the response is returned from the device or timed out. When the interface is completed, it returns a value of
DTL_RETVAL to the client application. You can use the DTL_ERROR_S to interpret the returned value.
DTL_CIP_MESSAGE_SEND_CB
Parameters
Parameters Descriptions
Svc_code Svc_code is the CIP- or CIP object-defined code for the service
being requested.
Dst_buf Dst_buf is a pointer to the buffer where the SDK Interface will
copy the response from the CIP target.
Ext_buf Ext_buf is a pointer to the buffer where The SDK Interface will
copy any extended status information from the CIP target.
Returned values
The following table identifies the error codes that can be returned by the DTL_CIP_MESSAGE_SEND_CB.
DTL_CIP_MESSAGE_SEND_W
The DTL_CIP_MSG_W provides the synchronous method to allow the client application to send a CIP request message
to a CIP object. Synchronous means the interface call will keep waiting till the response is returned, or the request
is timed out.The DTSA must be created successfully before this interface is called. When the interface is completed,
it returns a value of DTL_RETVAL to the client application. You can use the DTL_ERROR_S to interpret the returned
values.
DTL_CIP_MESSAGE_SEND_W
Parameters
Parameters Descriptions
Svc_code Svc_code is the CIP- or CIP object-defined code for the service
being requested.
Dst_buf Dst_buf is a pointer to the buffer where the SDK Interface will
copy the response from the CIP target.
Ext_buf Ext_buf is a pointer to the buffer where the SDK Interface will
copy any extended status information from the CIP target.
Returned values
The following table identifies the error codes that can be returned by the DTL_CIP_MESSAGE_SEND_W.
DTL_OpenDtsa
The DTL_OpenDtsa will call the DTL_DRIVER_OPEN to open the DTSA related the driver. You must call this interface
before calling the DTL_GetNameByDriverId to get the driver's name, and the DTSA must be created before this call.
DTL_OpenDtsa
Parameters
Parameters Descriptions
Returned values
When this interface completes, it returns a value of the DTL_RETVAL to the client application. You can call the
DTL_ERROR_S to interpret the returned values.
DTL_CloseDtsa
The DTL_CloseDtsa will call the DTL_DRIVER_CLOSE to close the DTSA related the driver. The DTSA must be created
before this call.
DTL_CloseDtsa
Parameters
Parameters Descriptions
Returned values
When this function completes, it returns a value of the DTL_RETVAL to the client application. You can use the
DTL_ERROR_S to interpret the returned values.
DTL_DestroyDtsa
The DTL_DestroyDtsa will free up the memory allocated for the DTSA structure. You can call this interface if the DTSA
is not needed.
DTL_DestroyDtsa
Parameters
Parameters Descriptions
Returned values
N/A
DTL_UNINIT
The DTL_UNINIT un-initialize the SDK interface, de-allocates resources, and detaches from the FactoryTalk Linx
executable. Applications must call the DTL_UNINIT before exiting. If not, the FactoryTalk Linx executable will identify
that the application is still running.
DTL_UNINIT
Parameters
Parameters Descriptions
Returned values
N/A
DTL_ERROR_S
The DTL_ERROR_S interprets the error codes generated by the SDK Interface and returns a null-terminated ASCII
string text message that describes the error.
DTL_ERROR_S
void LIBMEM DTL_ERROR_S ( unsigned long id, char LIBPTR * buf, int bufsize);
Parameters
Parameters Descriptions
Buf Buf is a pointer to the buffer where the DTL_ERROR_S will place
the ASCII text string that describes the error.
Returned values
N/A
DTL_DRIVER_OPEN
The DTL_DRIVER_OPEN will open the driver if the driver is not opened previously.
DTL_DRIVER_OPEN
long driver_id,
Parameters
Parameters Descriptions
Returned values
When this function completes, it returns a value of type DTL_RETVAL to the client application. User can use the
DTL_ERROR_S function to interpret the returned value.
DTL_DRIVER_CLOSE
The DTL_DRIVER_CLOSE will close the driver.
DTL_DRIVER_CLOSE
Parameters
Parameters Descriptions
Returned values
When this function completes, it returns a value of type DTL_RETVAL to the client application. User can use the
DTL_ERROR_S function to interpret the returned values.
DTL_GetRSLinxDriverID
The DTL_GetRSLinxDriverID will return a fixed value "65535". It is used for RSLinx Classic. We do not recommend that
you use it.
DTL_GetRSLinxDriverID
Parameters
N/A
Returned values
DTL_GetDriverIDByDriverName
The DTL_GetDriverIDByDriverName gets the driver ID of the FactoryTalk Linx server by the driver's name. If the driver's
name is not correct, this interface returns 0.
DTL_GetDriverIDByDriverName
Parameters
Parameters Descriptions
Returned values
This interface returns the driver ID if the driver's name is correct. The following table shows the driver ID and the
related driver types.
0x01 LINXE_DRVTYPE_ETHERNET
0x02 LINXE_DRVTYPE_DF1
0x03 LINXE_DRVTYPE_DHP
0x04 LINXE_DRVTYPE_DH485
0x05 LINXE_DRVTYPE_RIO
0x06 LINXE_DRVTYPE_VBACKPLANE
0x07 LINXE_DRVTYPE_RN6_DHP
0x08 LINXE_DRVTYPE_SERIAL_DH485
0x09 LINXE_DRVTYPE_RN6_DH485
0x0a LINXE_DRVTYPE_RN6_RIO
0x0b LINXE_DRVTYPE_RN1_RIO
DTL_GetHandleByDriverName
The DTL_GetHandleByDriverName gets the driver handle by the driver's name. The driver handle is a pointer value of
the driver object.
DTL_GetHandleByDriverName
Parameters
Parameters Descriptions
Returned values
This function return the driver handle. If driver's name is not correct, this function returns 0xffffffff.
DTL_GetDstDriverIDByDriverName
The DTL_GetDstDriverIDByDriverName gets the driver ID by the driver's name from the FactoryTalk Linx server. This
function is same with the DTL_GetDriverIDByDriverName.
DTL_GetDstDriverIDByDriverName
Parameters
Parameters Descriptions
Returned values
This function returns the driver ID, and return 0 if driver's name is not correct.
0x14 Soft 5
0x16 The SDK Interface client driver connected to the SDK Interface
server
0x1c Ethernet
0xce 1747-PIC
0xe1 1784-KTC
0x104 1784-PCC
0x111 1784-PCIC
0x01 LINXE_DRVTYPE_ETHERNET
0x02 LINXE_DRVTYPE_DF1
0x03 LINXE_DRVTYPE_DHP
0x04 LINXE_DRVTYPE_DH485
0x05 LINXE_DRVTYPE_RIO
0x06 LINXE_DRVTYPE_VBACKPLANE
0x07 LINXE_DRVTYPE_RN6_DHP
0x08 LINXE_DRVTYPE_SERIAL_DH485
0x09 LINXE_DRVTYPE_RN6_DH485
0x0a LINXE_DRVTYPE_RN6_RIO
0x0b LINXE_DRVTYPE_RN1_RIO
DTL_GetNetworkTypeByDriverName
The DTL_GetNetworkTypeByDriverName gets the network type by the driver's name from the FactoryTalk Linx server.
The network includes Controlnet, Ethernet, Devicenet, etc.
DTL_GetNetworkTypeByDriverName
Parameters
Parameters Descriptions
Returned values
0x0040 Controlnet
0x0010 Ethernet
0x0100 Devicenet
0x0080 ICP
0x0400 RIO
0x0002 DHP
0x0200 DF1
0x0800 VBP
0x0001 DH
0x0004 DH485
DTL_MaxDrivers
The DTL_MaxDrivers returns the max drivers of the SDK Interface. We do not recommend that you use it.
DTL_MaxDrivers
Parameters
N/A
Returned values
DTL_DRIVER_LIST_EX
The DTL_DRIVER_LIST_EX gets a driver list from the FactoryTalk Linx server. You must call the
DTL_SetDriverListEntryType to indicate which driver list, DTLDRIVER or DTLDRIVER_EX, will be fetched.
DTL_DRIVER_LIST_EX
PDTLDRIVER pDtlDriver,
Parameters
Parameters Descriptions
Returned values
The following table identifies the error codes that can be returned by the DTL_DRIVER_LIST_EX.
DTL_SetDriverListEntryType
You must call the DTL_SetDriverListEntryType before calling the DTL_DRIVER_LIST_EX to start the first entry in the
block of memory that will receive the driver list. The valid values are DTL_DVRLIST_TYPE2 and DTL_DVRLIST_TYPE_EX.
DTL_SetDriverListEntryType
Parameters
Parameters Descriptions
Parameters Descriptions
Returned values
The following table identifies the error codes that can be returned by the DTL_SetDriverListEntryType.
DTL_GetTypeFromDriverListEntry
The DTL_GetTypeFromDriverListEntry returns the driver type in the specified structure DTLDRIVER or DTLDRIVER_EX.
DTL_GetTypeFromDriverListEntry
Parameters
Returned values
This interface returns the driver type in the specified structure, DTLDRIVER or DTLDRIVER_EX. The valid type value are
DTL_DVRLIST_TYPE2 and DTL_DVRLIST_TYPE_EX.
DTL_GetHandleFromDriverListEntry
The DTL_GetHandleFromDriverListEntry returns the driver handle in the specified structure, DTLDRIVER or
DTLDRIVER_EX.
DTL_GetHandleFromDriverListEntry
Parameters
Returned values
This interface returns the driver handle in the specified structure, DTLDRIVER or DTLDRIVER_EX, or returns 0xffffffff if
pDrivier is null.
DTL_GetDriverNameFromDriverListEntry
The DTL_GetDriverNameFromDriverListEntry returns the driver's name in the specified structure, DTLDRIVER or
DTLDRIVER_EX.
DTL_GetDriverNameFromDriverListEntry
Parameters
Returned values
This interface returns the driver's name in the specified structure, DTLDRIVER or DTLDRIVER_EX.
DTL_GetNetworkTypeFromDriverListEntry
The DTL_GetNetworkTypeFromDriverListEntry returns the network type in the specified structure, DTLDRIVER or
DTLDRIVER_EX.
DTL_GetNetworkTypeFromDriverListEntry
Parameters
Returned values
This interface returns the network types in the specified structure, DTLDRIVER or DTLDRIVER_EX.
0x0040 Controlnet
0x0010 Ethernet
0x0100 Devicenet
0x0080 ICP
0x0400 RIO
0x0002 DHP
0x0200 DF1
0x0800 VBP
0x0001 DH
0x0004 DH485
DTL_GetDriverIDFromDriverListEntry
The DTL_GetDriverIDFromDriverListEntry returns the driver ID in the specified structure, DTLDRIVER or DTLDRIVER_EX.
DTL_GetDriverIDFromDriverListEntry
Parameters
Returned values
This interface returns the driver ID in the specified structure, DTLDRIVER or DTLDRIVER_EX, or returns 0 if pDriver is
null.
0x14 Soft 5
0x16 The SDK Interface client driver connected to the SDK Interface
server
0x1c Ethernet
0xce 1747-PIC
0xe1 1784-KTC
0x104 1784-PCC
0x111 1784-PCIC
DTL_GetDstDriverIDFromDriverListEntry
The DTL_GetDstDriverIDFromDriverListEntry funtion returns the driver ID in the specified structure, DTLDRIVER or
DTLDRIVER_EX.
DTL_GetDstDriverIDFromDriverListEntry
Parameters
Returned values
This interface returns the driver ID in the specified structure, DTLDRIVER or DTLDRIVER_EX, or returns 0 if pDriver is
null.
0x14 Soft 5
0x16 The SDK Interface client driver connected to the SDK Interface
server
0x1c Ethernet
0xce 1747-PIC
0xe1 1784-KTC
0x104 1784-PCC
0x111 1784-PCIC
DTL_GetStationFromDriverListEntry
The DTL_GetStationFromDriverListEntry returns the driver's own station address on its network in the specified
structure, DTLDRIVER or DTLDRIVER_EX.
DTL_GetStationFromDriverListEntry
Parameters
Returned values
This interface returns the driver’s own station address on its network in the specified structure, DTLDRIVER or
DTLDRIVER_EX, or returns 0xffffffff if pDrive is null.
DTL_GetMTUFromDriverListEntry
The DTL_GetMTUFromDriverListEntry returns the Maximum Transmission Unit on the driver’s network in the specified
structure, DTLDRIVER or DTLDRIVER_EX.
DTL_GetMTUFromDriverListEntry
Parameters
Returned values
This interface returns the Maximum Transmission Unit on the driver’s network in the specified structure, DTLDRIVER
or DTLDRIVER_EX.
DTL_GetServerNameFromDriverListEntry
The DTL_GetServerNameFromDriverListEntry returns server name of DTLDRIVER_EX or returns NULL for DTLDRIVER.
DTL_GetServerNameFromDriverListEntry
Parameters
Returned values
This interface returns the server name of DTLDRIVER_EX or returns NULL for DTLDRIVER.
DTL_GetDriverAliasFromDriverListEntry
The DTL_GetDriverAliasFromDriverListEntry returns the driver alias name in the specified structure, DTLDRIVER_EX or
DTLDRIVER.
DTL_GetDriverAliasFromDriverListEntry
Parameters
Returned values
This interface returns the driver alias name in the specified structure, DTLDRIVER_EX or DTLDRIVER.
DTL_GetDriverListEntryFromDriverListIndex
The DTL_GetDriverListEntryFromDriverListIndex returns a pointer to a DTLDRIVER or DTLDRIVER_EX structure
specified by the nIndex value.
DTL_GetDriverListEntryFromDriverListIndex
nIndex);
Parameters
Parameters Descriptions
Returned values
DTL_CreatetDriverList
The DTL_CreateDriverList returns driver list of the DTLDRIVER_EX structure.
DTL_CreatetDriverList
Parameters
Parameters Descriptions
Returned values
DTL_DestroyDriverList
The DTL_DestroyDriverList releases the driver list created by the DTL_CreateDriverList.
DTL_DestroyDriverList
Parameters
Parameters Descriptions
Returned values
NULL
DTL_GetNameByDriverId
The DTL_GetNameByDriverId gets the driver's name by the drive ID. You must call the DTL_DRIVER_OPEN or
DTL_OpenDtsa before calling this interface.
DTL_GetNameByDriverId
Parameters
Parameters Descriptions
Returned values
The following table identifies the error codes that can be returned by the DTL_ GetNameByDriverId.
DTL_CIP_CONNECTION_SEND
The DTL_CIP_CONNECTION_SEND sends data on a CIP connection. If the application expects to receive data on the
connection, it must specify a DTL_CIP_CONNECTION_PACKET_PROC in its DTL_CIP_CONNECTION_OPEN call. This
callback function will be called whenever data comes in on the connection.
DTL_CIP_CONNECTION_SEND
Parameters
Parameters Descriptions
Returned values
The following table identifies the error codes that can be returned by the DTL_ CIP_CONNECTION_SEND.
DTL_CIP_CONNECTION_PACKET_PROC
The DTL_CIP_CONNECTION_PACKET_PROC is a callback procedure for receiving data on a CIP connection. It is a
user-defined function called for the application each time when new data is available on the CIP connection. A
DTL_CIP_CONNECTION_ PACKET _PROC procedure is associated with a connection via the packet_proc parameter in
the DTL_CIP_CONNECTION_OPEN.
DTL_CIP_CONNECTION_PACKET_PROC
Parameters
Parameters Descriptions
Parameters Descriptions
Returned values
A DTL_CIP_CONNECTION_PACKET_PROC procedure is a user-defined function called for the application each time
when new data is received over a CIP connection. The returned value is not used currently.
DTL_CIP_CONNECTION_STATUS_PROC
The DTL_CIP_CONNECTION_STATUS_PROC is the callback procedure for notices of status changes on a CIP
connection. It is a user-defined function called for the application each time the status of a CIP connection changes.
A DTL_CIP_CONNECTION_STATUS_PROC procedure is associated with a connection via the status_proc parameter in a
DTL_CIP_CONNECTION_OPEN.
DTL_CIP_CONNECTION_STATUS_PROC
Parameters
Parameters Descriptions
state State indicates the new state of the CIP connection or an event
which occurred on the connection. See the possible state values
table.
Parameters Descriptions
Returned values
A DTL_CIP_CONNECTION_STATUS_PROC procedure is a user-defined function called for the application each time new
data is received over a CIP connection. The returned value is not used currently.
DTL_IO_CALLBACK _PROC
The DTL_IO_CALLBACK_PROC is a callback procedure that the client application can use to handle the completion
of I/O operations. It is associated with an I/O operation by specifying it as callback_proc in the initiating function
call. Do not use callback_param to point to automatic data, that is, data within the stack frame of a function, as it
probably will not be active when the callback is invoked.
DTL_IO_CALLBACK _PROC
Parameters
Parameters Descriptions
Io_stat The final I/O completion status. You can use the DTL_ERROR_S
function to interpret the io_stat value.
Returned values
N/A
Global Header
//
#include <iostream>
#include <map>
#include <array>
#include <vector>
#include "FTLinx_SDK.h"
class CGlobalData
public:
CGlobalData()
};
~CGlobalData()
if(m_hEvent)
::CloseHandle(m_hEvent);
if(m_hEventPacket)
::CloseHandle(m_hEventPacket);
};
return;
m_vecBuffer.swap(vecData);
HANDLE m_hEvent{ 0 };
HANDLE m_hEventPacket{ 0 };
WORD m_wCommState{ 0 };
std::vector<BYTE> m_vecBuffer;
};
DTL_CIP_TRANSPORT_CONNECTION g_cip_conn = { 0 };
// Note: g_cip_conn - Must pay attention to its lifecycle, especialy asynchronous calling with
this variable.
// The members of this struct variable would be used by the internal callback, so, it would
stop responding when the callback returned if this object had been released.
CGlobalData g_objData;
if (conn_param != NULL)
pPtr->m_wCommState = (WORD)state;
SetEvent(pPtr->m_hEvent);
return 0;
if (conn_param != NULL)
pPtr->SetResponseData(data_buf, data_size);
SetEvent(pPtr->m_hEventPacket);
return 0;
if (io_stat != DTL_SUCCESS)
char szErrMsg[256]{0};
std::cout << "callback_proc, error: " << io_stat << " with " << szErrMsg << "\n";
if (callback_param != NULL)
SetEvent(pPtr->m_hEventPacket);
return 0;
int nCount = 0;
pIOI[4] = HIBYTE(nClassId);
pIOI[8] = HIBYTE(nInstId);
if (nAttribId == 0)
pIOI[0] = 0x04;
else
pIOI[10] = (BYTE)nAttribId;
else
pIOI[1] = 0x20;
pIOI[2] = LOBYTE(nClassId);
if (nAttribId == 0)
pIOI[0] = 0x02;
else
pIOI[6] = (BYTE)nAttribId;
int index = 0;
int rightPos = 0;
DWORD dimVal;
array_dim++;
index += leftPos1;
leftPos = szTagName.find('[');
rightPos = szTagName.find(']');
indexList->insert(std::make_pair(index, dimVal));
leftPos1 = leftPos + 1;
int array_dim = 0;
if (array_dim != 0)
pIOI[2] = tagLen;
if (tagLen % 2)
tagLen = tagLen + 1;
pIOI[1] = 0x91;
int wlenOfLogicSegment = 0;
if (array_dim != 0)
DWORD dimVal = 0;
int j = 1;
dimVal = indexIter->second;
pIOI[len] = 0x28;
pIOI[len + 1] = (char)dimVal;
len = len + 2;
wlenOfLogicSegment += 1;
pIOI[len] = 0x29;
pIOI[len + 1] = 0x00;
pIOI[len + 2] = LOBYTE(dimVal);
pIOI[len + 3] = HIBYTE(dimVal);
len = len + 4;
wlenOfLogicSegment += 2;
pIOI[len] = 0x2a;
pIOI[len + 1] = 0x00;
pIOI[len + 2] = LOBYTE(LOWORD(dimVal));
pIOI[len + 3] = HIBYTE(LOWORD(dimVal));
pIOI[len + 4] = LOBYTE(HIWORD(dimVal));
pIOI[len + 5] = HIBYTE(HIWORD(dimVal));
len = len + 6;
wlenOfLogicSegment += 3;
*target_mem = *iter;
if (pDtsa)
DTL_DestroyDtsa(pDtsa);
pDtsa = NULL;
DTL_UNINIT(0);
};
DTL_RETVAL OpenCloseCIPNormalConnection()
retval = DTL_INIT(0);
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "DTL INIT NOT SUCCESS, error: " << retval << " with " << szError << "\n";
return retval;
DWORD dwError = 0;
DTL_FLAGS_ROUTE_TYPE_CIP);
char szError[256];
std::cout << "Failed to create dtsa, dwError = " << dwError << " with " << szError <<
"\n";
DTL_UNINIT(0);
return dwError;
unsigned char mr_ioi[5] = { 0x02, 0x20, 0x02, 0x24, 0x01, };// CIP class:Message Router
0x02; Instance:0x01
DWORD dwConnId = 0;
g_cip_conn.ctype = DTL_CONN_CIP;
g_cip_conn.mode = DTL_CIP_CONN_MODE_IS_CLIENT;
g_cip_conn.trigger = DTL_CIP_CONN_TRIGGER_APPLICATION;
g_cip_conn.transport = 3;
g_cip_conn.tmo_mult = 0;
g_cip_conn.OT.conn_type = DTL_CIP_CONN_TYPE_POINT_TO_POINT;
g_cip_conn.OT.pkt_type = DTL_CIP_CONN_PACKET_SIZE_VARIABLE;
g_cip_conn.OT.pkt_size = 400;
g_cip_conn.OT.rpi = 30000000L;
g_cip_conn.OT.api = 0L;
g_cip_conn.TO.conn_type = DTL_CIP_CONN_TYPE_POINT_TO_POINT;
g_cip_conn.TO.pkt_type = DTL_CIP_CONN_PACKET_SIZE_VARIABLE;
g_cip_conn.TO.pkt_size = 400;
g_cip_conn.TO.rpi = 30000000L;
g_cip_conn.TO.api = 0L;
g_cip_conn.bLargeConnection = 0;
retval = DTL_CIP_CONNECTION_OPEN(
pDtsa,
mr_ioi,
&dwConnId,
(unsigned long)&g_objData,
&g_cip_conn,
(DTL_CIP_CONNECTION_PACKET_PROC)NULL,
(DTL_CIP_CONNECTION_STATUS_PROC)status_proc,
5000L);
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "Failed to open connection, error: " << retval << " with " << szError <<
"\n";
destroy(pDtsa);
return retval;
destroy(pDtsa);
return retval;
if(g_objData.m_wCommState != DTL_CONN_ESTABLISHED)
char szError[256];
std::cout << "Failed to establish connection, error: " << g_objData.m_wCommState << "
destroy(pDtsa);
return g_objData.m_wCommState;
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "Failed to close connection, error: " << retval << " with " << szError <<
"\n";
std::cout << "Timed out while waiting for connection closing." << "\n";
destroy(pDtsa);
return retval;
destroy(pDtsa);
return retval;
DTL_RETVAL OpenCloseCIPLargeConnection()
retval = DTL_INIT(0);
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "DTL INIT NOT SUCCESS, error: " << retval << " with " << szError << "\n";
return retval;
DWORD dwError = 0;
DTL_FLAGS_ROUTE_TYPE_CIP);
char szError[256];
std::cout << "Failed to create dtsa, dwError = " << dwError << " with " << szError <<
"\n";
DTL_UNINIT(0);
return dwError;
unsigned char mr_ioi[5] = { 0x02, 0x20, 0x02, 0x24, 0x01, };// CIP class:Message Router
0x02; Instance:0x01
DWORD dwConnId = 0;
g_cip_conn.ctype = DTL_CONN_CIP;
g_cip_conn.mode = DTL_CIP_CONN_MODE_IS_CLIENT;
g_cip_conn.trigger = DTL_CIP_CONN_TRIGGER_APPLICATION;
g_cip_conn.transport = 3;
g_cip_conn.tmo_mult = 0;
g_cip_conn.OT.conn_type = DTL_CIP_CONN_TYPE_POINT_TO_POINT;
g_cip_conn.OT.pkt_type = DTL_CIP_CONN_PACKET_SIZE_VARIABLE;
g_cip_conn.OT.pkt_size = 4002;
g_cip_conn.OT.rpi = 30000000L;
g_cip_conn.OT.api = 0L;
g_cip_conn.TO.conn_type = DTL_CIP_CONN_TYPE_POINT_TO_POINT;
g_cip_conn.TO.pkt_type = DTL_CIP_CONN_PACKET_SIZE_VARIABLE;
g_cip_conn.TO.pkt_size = 4002;
g_cip_conn.TO.rpi = 30000000L;
g_cip_conn.TO.api = 0L;
g_cip_conn.bLargeConnection = 1;
retval = DTL_CIP_LARGE_CONNECTION_OPEN(
pDtsa,
mr_ioi,
&dwConnId,
(unsigned long)&g_objData,
&g_cip_conn,
(DTL_CIP_CONNECTION_PACKET_PROC)NULL,
(DTL_CIP_CONNECTION_STATUS_PROC)status_proc,
5000L);
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "Failed to open connection, error: " << retval << " with " << szError <<
"\n";
destroy(pDtsa);
return retval;
destroy(pDtsa);
return retval;
if (g_objData.m_wCommState != DTL_CONN_ESTABLISHED)
char szError[256];
std::cout << "Failed to establish connection, error: " << g_objData.m_wCommState << "
destroy(pDtsa);
return g_objData.m_wCommState;
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "Failed to close connection, error: " << retval << " with " << szError <<
"\n";
std::cout << "Timed out while waiting for connection closing." << "\n";
destroy(pDtsa);
return retval;
destroy(pDtsa);
return retval;
DTL_RETVAL ReadTagOnConnectedConnection()
retval = DTL_INIT(0);
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "DTL INIT NOT SUCCESS, error: " << retval << " with " << szError << "\n";
return retval;
DWORD dwError = 0;
DTL_FLAGS_ROUTE_TYPE_CIP);
char szError[256];
std::cout << "Failed to create dtsa, dwError = " << dwError << " with " << szError <<
"\n";
DTL_UNINIT(0);
return dwError;
unsigned char mr_ioi[5] = { 0x02, 0x20, 0x02, 0x24, 0x01, };// CIP class:Message Router
0x02; Instance:0x01
DWORD dwConnId = 0;
g_cip_conn.ctype = DTL_CONN_CIP;
g_cip_conn.mode = DTL_CIP_CONN_MODE_IS_CLIENT;
g_cip_conn.trigger = DTL_CIP_CONN_TRIGGER_APPLICATION;
g_cip_conn.transport = 3;
g_cip_conn.tmo_mult = 0;
g_cip_conn.OT.conn_type = DTL_CIP_CONN_TYPE_POINT_TO_POINT;
g_cip_conn.OT.pkt_type = DTL_CIP_CONN_PACKET_SIZE_VARIABLE;
g_cip_conn.OT.pkt_size = 400;
g_cip_conn.OT.rpi = 30000000L;
g_cip_conn.OT.api = 0L;
g_cip_conn.TO.conn_type = DTL_CIP_CONN_TYPE_POINT_TO_POINT;
g_cip_conn.TO.pkt_type = DTL_CIP_CONN_PACKET_SIZE_VARIABLE;
g_cip_conn.TO.pkt_size = 400;
g_cip_conn.TO.rpi = 30000000L;
g_cip_conn.TO.api = 0L;
g_cip_conn.bLargeConnection = 0;
retval = DTL_CIP_CONNECTION_OPEN(
pDtsa,
mr_ioi,
&dwConnId,
(unsigned long)&g_objData,
&g_cip_conn,
(DTL_CIP_CONNECTION_PACKET_PROC)packet_proc,
(DTL_CIP_CONNECTION_STATUS_PROC)status_proc,
5000L);
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "Failed to open connection, error: " << retval << " with " << szError <<
"\n";
destroy(pDtsa);
return retval;
destroy(pDtsa);
return retval;
if (g_objData.m_wCommState != DTL_CONN_ESTABLISHED)
char szError[256];
std::cout << "Failed to establish connection, error: " << g_objData.m_wCommState << "
destroy(pDtsa);
return g_objData.m_wCommState;
CreateIOIbyTagName(TAG_NAME, &bufIOI[1]);
bufIOI[bufIOI[1] * 2 + 3] = 0x00;
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "Failed to read this tag, error: " << g_objData.m_wCommState << " with "
bSuccess = false;
bSuccess = false;
if (bSuccess)
std::cout << TAG_NAME <<" Type of value: " << (WORD)g_objData.m_vecBuffer[4] << "
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "Failed to close connection, error: " << retval << " with " << szError <<
"\n";
std::cout << "Timed out while waiting for connection closing." << "\n";
destroy(pDtsa);
return retval;
destroy(pDtsa);
return retval;
DTL_RETVAL ReadWriteTagOnUnconnectedConnection()
retval = DTL_INIT(0);
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "DTL INIT NOT SUCCESS, error: " << retval << " with " << szError << "\n";
return retval;
DWORD dwError = 0;
DTL_FLAGS_ROUTE_TYPE_CIP);
char szError[256];
std::cout << "Failed to create dtsa, dwError = " << dwError << " with " << szError <<
"\n";
DTL_UNINIT(0);
return dwError;
BYTE byExtStatus = 0;
BYTE ioi[32] = { 0 };
CreateIOIbyTagName(TAG_NAME, ioi);
20000); // timeout
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "Failed to read this tag, error: " << retval << " with " << szError <<
"\n";
destroy(pDtsa);
return retval;
std::cout << TAG_NAME << " Type of value: " << (WORD)arrReply[0] << " Value: " <<
std::vector<BYTE> vecRequest;
vecRequest.resize(dwReadsize + sizeof(WORD));
vecRequest[3] = HIBYTE(0x0001);
* (LONGLONG*)&vecRequest[4] = llValue;
arrReply.fill(0);
dwReadsize = arrReply.size();
20000); // timeout
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "Failed to write this tag, error: " << retval << " with " << szError <<
"\n";
destroy(pDtsa);
return retval;
std::cout << TAG_NAME << " Type of value: " << (WORD)vecRequest[0] << " Value wrote: " <<
destroy(pDtsa);
return retval;
// Multiple packts in a CIP request with the connected CIP connection method.
DTL_RETVAL RequestMultiPacketsOnceOnConnectedConnection()
retval = DTL_INIT(0);
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "DTL INIT NOT SUCCESS, error: " << retval << " with " << szError << "\n";
return retval;
DWORD dwError = 0;
DTL_FLAGS_ROUTE_TYPE_CIP);
char szError[256];
std::cout << "Failed to create dtsa, dwError = " << dwError << " with " << szError <<
"\n";
DTL_UNINIT(0);
return dwError;
unsigned char mr_ioi[5] = { 0x02, 0x20, 0x02, 0x24, 0x01, };// CIP class:Message Router
0x02; Instance:0x01
DWORD dwConnId = 0;
g_cip_conn.ctype = DTL_CONN_CIP;
g_cip_conn.mode = DTL_CIP_CONN_MODE_IS_CLIENT;
g_cip_conn.trigger = DTL_CIP_CONN_TRIGGER_APPLICATION;
g_cip_conn.transport = 3;
g_cip_conn.tmo_mult = 0;
g_cip_conn.OT.conn_type = DTL_CIP_CONN_TYPE_POINT_TO_POINT;
g_cip_conn.OT.pkt_type = DTL_CIP_CONN_PACKET_SIZE_VARIABLE;
g_cip_conn.OT.pkt_size = 400;
g_cip_conn.OT.rpi = 30000000L;
g_cip_conn.OT.api = 0L;
g_cip_conn.TO.conn_type = DTL_CIP_CONN_TYPE_POINT_TO_POINT;
g_cip_conn.TO.pkt_type = DTL_CIP_CONN_PACKET_SIZE_VARIABLE;
g_cip_conn.TO.pkt_size = 400;
g_cip_conn.TO.rpi = 30000000L;
g_cip_conn.TO.api = 0L;
g_cip_conn.bLargeConnection = 0;
retval = DTL_CIP_CONNECTION_OPEN(
pDtsa,
mr_ioi,
&dwConnId,
(unsigned long)&g_objData,
&g_cip_conn,
(DTL_CIP_CONNECTION_PACKET_PROC)packet_proc,
(DTL_CIP_CONNECTION_STATUS_PROC)status_proc,
5000L);
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "Failed to open connection, error: " << retval << " with " << szError <<
"\n";
destroy(pDtsa);
return retval;
destroy(pDtsa);
return retval;
if (g_objData.m_wCommState != DTL_CONN_ESTABLISHED)
char szError[256];
std::cout << "Failed to establish connection, error: " << g_objData.m_wCommState << "
destroy(pDtsa);
return g_objData.m_wCommState;
arrRequest[7] = 0x03;
arrRequest[8] = 0x20;
arrRequest[10] = 0x25;
arrRequest[11] = 0x00;
arrRequest[12] = 0x01;
arrRequest[13] = 0x00;
arrRequest[15] = 0x03;
arrRequest[16] = 0x20;
arrRequest[18] = 0x25;
arrRequest[19] = 0x00;
arrRequest[20] = 0x01;
arrRequest[21] = 0x00;
std::vector<BYTE> bufIOI = { 0x0A ,0x03, 0x20, 0x02, 0x25, 0x00, 0x01, 0x00 };// 0x0A :
bufIOI.insert(std::end(bufIOI),std::begin(arrRequest), std::end(arrRequest));
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "Failed to send message, error: " << retval << " with " << szError <<
"\n";
bSuccess = false;
bSuccess = false;
if (bSuccess)
std::cout << " Number of service responses: " << *(WORD*)&g_objData.m_vecBuffer[4] <<
"\n";
std::cout << " The offset of first service response: " <<
std::cout << " The offset of second service response: " <<
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "Failed to close connection, error: " << retval << " with " << szError <<
"\n";
destroy(pDtsa);
return retval;
destroy(pDtsa);
return retval;
// Multiple packts in a CIP request with the unconnected CIP connection method.
DTL_RETVAL RequestMultiPacketsOnceOnUnconnectedConnection()
retval = DTL_INIT(0);
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "DTL INIT NOT SUCCESS, error: " << retval << " with " << szError << "\n";
return retval;
DWORD dwError = 0;
DTL_FLAGS_ROUTE_TYPE_CIP);
char szError[256];
std::cout << "Failed to create dtsa, dwError = " << dwError << " with " << szError <<
"\n";
DTL_UNINIT(0);
return dwError;
BYTE byExtStatus = 0;
BYTE ioi[] = { 0x03, 0x20, 0x02, 0x25, 0x00, 0x01, 0x00 };// CIP class:Message Router 0x02;
Instance:0x01
arrRequest[7] = 0x03;
arrRequest[8] = 0x20;
arrRequest[10] = 0x25;
arrRequest[11] = 0x00;
arrRequest[12] = 0x01;
arrRequest[13] = 0x00;
arrRequest[15] = 0x03;
arrRequest[16] = 0x20;
arrRequest[18] = 0x25;
arrRequest[19] = 0x00;
arrRequest[20] = 0x01;
arrRequest[21] = 0x00;
20000); // timeout
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "Failed to send message, error: " << retval << " with " << szError <<
"\n";
else
std::cout << " Number of service responses: " << *(WORD*)&arrReply[0] << "\n";
std::cout << " The offset of first service response: " << *(WORD*)&arrReply[2] << "\n";
std::cout << " The offset of second service response: " << *(WORD*)&arrReply[4] <<
"\n";
destroy(pDtsa);
return retval;
DTL_RETVAL RequestCIPService()
retval = DTL_INIT(0);
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "DTL INIT NOT SUCCESS, error: " << retval << " with " << szError << "\n";
return retval;
DWORD dwError = 0;
DTL_FLAGS_ROUTE_TYPE_CIP);
char szError[256];
std::cout << "Failed to create dtsa, dwError = " << dwError << " with " << szError << "\n";
DTL_UNINIT(0);
return dwError;
unsigned char mr_ioi[5] = { 0x02, 0x20, 0x02, 0x24, 0x01, };// CIP class:Message Router 0x02;
Instance:0x01
DWORD dwConnId = 0;
g_cip_conn.ctype = DTL_CONN_CIP;
g_cip_conn.mode = DTL_CIP_CONN_MODE_IS_CLIENT;
g_cip_conn.trigger = DTL_CIP_CONN_TRIGGER_APPLICATION;
g_cip_conn.transport = 3;
g_cip_conn.tmo_mult = 0;
g_cip_conn.OT.conn_type = DTL_CIP_CONN_TYPE_POINT_TO_POINT;
g_cip_conn.OT.pkt_type = DTL_CIP_CONN_PACKET_SIZE_VARIABLE;
g_cip_conn.OT.pkt_size = 400;
g_cip_conn.OT.rpi = 30000000L;
g_cip_conn.OT.api = 0L;
g_cip_conn.TO.conn_type = DTL_CIP_CONN_TYPE_POINT_TO_POINT;
g_cip_conn.TO.pkt_type = DTL_CIP_CONN_PACKET_SIZE_VARIABLE;
g_cip_conn.TO.pkt_size = 400;
g_cip_conn.TO.rpi = 30000000L;
g_cip_conn.TO.api = 0L;
g_cip_conn.bLargeConnection = 0;
retval = DTL_CIP_CONNECTION_OPEN(
pDtsa,
mr_ioi,
&dwConnId,
(unsigned long)&g_objData,
&g_cip_conn,
(DTL_CIP_CONNECTION_PACKET_PROC)packet_proc,
(DTL_CIP_CONNECTION_STATUS_PROC)status_proc,
5000L);
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "Failed to open connection, error: " << retval << " with " << szError << "\n";
destroy(pDtsa);
return retval;
destroy(pDtsa);
return retval;
if (g_objData.m_wCommState != DTL_CONN_ESTABLISHED)
char szError[256];
std::cout << "Failed to establish connection, error: " << g_objData.m_wCommState << " with "
destroy(pDtsa);
return g_objData.m_wCommState;
SetIOI(&bufIOI[1], 0x01, 0x01, 0x07); // 0x01 : Identity class; 0x01 : Instance ID; 0x07:
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "Failed to send message, error: " << retval << " with " << szError << "\n";
bSuccess = false;
bSuccess = false;
if (bSuccess)
myCopyMemory(std::begin(g_objData.m_vecBuffer) + 4, std::end(g_objData.m_vecBuffer),
std::ostream_iterator<BYTE>{std::cout,""});
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "Failed to close connection, error: " << retval << " with " << szError << "\n";
destroy(pDtsa);
return retval;
destroy(pDtsa);
return retval;
Example: Send the PCCC request to the ControlLogix, SLC, or PLC controllers in a synchronized method
Add Global Header on page 67 to the beginning of this example.
// This sample can be used to send the PCCC request to the ControlLogix or SLC/PLC controllers
DTL_RETVAL SyncSendPCCCToDevice()
if (retval != DTL_SUCCESS)
char szError[256]{ 0 };
std::cout << "DTL INIT fail, error: " << retval << " with " << szError << "\n";
return retval;
DWORD dwError = 0;
//if send PCCC command to ControlLogix, like 1756-L85, make sure configure PLC5/SLC mapping in
Logix Designer, so that the address in PCCC cmd can be recgnized by the ControlLogix.
//if send PCCC command to device under DH+ driver, Harmony Path should be like this:
"WIN-OA4J4R7R9S8!DH+\\3";
DTL_FLAGS_ROUTE_TYPE_PCCC);
char szError[256]{ 0 };
std::cout << "Failed to create dtsa, dwError = " << dwError << "with" << szError << "\n";
DTL_UNINIT(0);
return dwError;
//0xa2: FNC code 0xa2 means Proteted Typed Logical Read w/3 address fields
BYTE rspRead[10] = { 0 };
DWORD iostat = 0;
retval = DTL_PCCC_MSG_W(pDtsa,
cmd,
readCmdReq,
readCmdReqSize,
rspRead,
&rspSize,
&iostat,
timeout);
if (retval != DTL_SUCCESS)
std::cout << "read tag failed with error " << retval << "\n";
destroy(pDtsa);
return retval;
WORD data = 0;
//0xaa: FNC code 0xaa means Proteted Typed Logical Write w/3 address fields
BYTE rspWrite[10] = { 0 };
rspSize = sizeof(rspWrite);
cmd = 0x0f;
iostat = 0;
timeout = 5000L;
retval = DTL_PCCC_MSG_W(pDtsa,
cmd,
writeCmdReq,
writeCmdReqSize,
rspWrite,
&rspSize,
&iostat,
timeout);
if (retval != DTL_SUCCESS)
std::cout << "write tag failed with error " << retval << "\n";
destroy(pDtsa);
return retval;
destroy(pDtsa);
return retval;
Example: Send the PCCC request to the ControlLogix, SLC, or PLC controllers in an asynchronized
method
Add Global Header on page 67 to the beginning of this example.
// This sample can be used to send the PCCC request to the ControlLogix or SLC/PLC controllers
under the ethernet direct driver or DH+ direct driver by asynchronized way.
DTL_RETVAL AsyncSendPCCCToDevice()
if (retval != DTL_SUCCESS)
char szError[256]{ 0 };
std::cout << "DTL INIT NOT SUCCESS, error: " << retval << " with " << szError << "\n";
return retval;
DWORD dwError = 0;
//if send PCCC command to ControlLogix, like 1756-L85, make sure configure PLC5/SLC mapping in
Logix Designer, so that the address in PCCC cmd can be recgnized by the ControlLogix.
//if send PCCC command to device under DH+ driver, Harmony Path should be like this:
"WIN-OA4J4R7R9S8!DH+\\3";
DTL_FLAGS_ROUTE_TYPE_PCCC);
char szError[256]{ 0 };
std::cout << "Failed to create dtsa, dwError = " << dwError << "with" << szError << "\n";
DTL_UNINIT(0);
return dwError;
//0xa2: FNC code 0xa2 means Proteted Typed Logical Read w/3 address fields
BYTE rspRead[10] = { 0 };
retval = DTL_PCCC_MSG_CB(pDtsa,
cmd,
readCmdReq,
readCmdReqSize,
rspRead,
&rspSize,
timeout,
(DTL_IO_CALLBACK_PROC)callback_proc,
(unsigned long)&g_objData
);
if (retval != DTL_SUCCESS)
std::cout << "read tag failed with error " << retval << "\n";
bSuccess = false;
bSuccess = false;
if (bSuccess)
WORD data = 0;
//0xaa: FNC code 0xaa means Proteted Typed Logical Write w/3 address fields
BYTE rspWrite[10] = { 0 };
rspSize = sizeof(rspWrite);
cmd = 0x0f;
timeout = 5000L;
retval = DTL_PCCC_MSG_CB(pDtsa,
cmd,
writeCmdReq,
writeCmdReqSize,
rspWrite,
&rspSize,
timeout,
(DTL_IO_CALLBACK_PROC)callback_proc,
(unsigned long)&g_objData
);
if (retval != DTL_SUCCESS)
std::cout << "write tag failed with error " << retval << "\n";
destroy(pDtsa);
return retval;
DTL_RETVAL TryOtherInterfaces()
retval = DTL_INIT(0);
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "DTL INIT NOT SUCCESS, error: " << retval << " with " << szError << "\n";
return retval;
DTLDRIVER DriverList[DTL_MAX_DRIVERS]{};
retval = DTL_SetDriverListEntryType((void*)&DriverList,DTL_DVRLIST_TYPE2);
if(retval == DTL_SUCCESS)
retval = DTL_DRIVER_LIST_EX(DriverList,&dwNumDrivers,500000000UL);
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "Get driver list failed, error: " << retval << " with " << szError << "\n";
if (pDriver)
dwDriverHandle = DTL_GetHandleByDriverName(pDriver->szDriverName);
wDstDriverIDOfFTLinx = DTL_GetDstDriverIDByDriverName(pDriver->szDriverName);
wNetworkType = DTL_GetNetworkTypeByDriverName(pDriver->szDriverName);
wDriverIDOfFTLinx = DTL_GetDriverIDByDriverName(pDriver->szDriverName);
<< "\n";
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "Can not open this driver, error: " << retval << " with " << szError << "\n";
else
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "Can not get name from this driver ID, error: " << retval << " with " << szError
<< "\n";
else
std::cout << "Got name (" << szRetName << ") from Driver ID (" << wDriverIDOfFTLinx << ")\n";
pszDriverName = DTL_GetDriverNameFromDriverListEntry(&DriverList[dwIndx]);
wDriverType = DTL_GetTypeFromDriverListEntry(&DriverList[dwIndx]);
dwDriverHandle = DTL_GetHandleFromDriverListEntry(&DriverList[dwIndx]);
wNetworkType = DTL_GetNetworkTypeFromDriverListEntry(&DriverList[dwIndx]);
wDriverIDOfDTL = DTL_GetDriverIDFromDriverListEntry(&DriverList[dwIndx]);
wDstDriverIDOfDTL = DTL_GetDstDriverIDFromDriverListEntry(&DriverList[dwIndx]);
dwStation = DTL_GetStationFromDriverListEntry(&DriverList[dwIndx]);
wMTU = DTL_GetMTUFromDriverListEntry(&DriverList[dwIndx]);
pszDriverAlias = DTL_GetDriverAliasFromDriverListEntry(&DriverList[dwIndx]);
<< "\n";
dwNumDrivers = 0;
if (pDriverExList)
pszServerName = DTL_GetServerNameFromDriverListEntry(&pDriverExList[dwIndx]);
<< "\n";
DTL_DestroyDriverList(pDriverExList, 5000L);
std::cout << "The fixed max count of drivers: " << dwMaxDrivers
<< "\n";
DWORD dwError = 0;
DTL_FLAGS_ROUTE_TYPE_CIP);
if (pDtsa)
retval = DTL_OpenDtsa(pDtsa);
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "Open the DTSA failed, error: " << retval << " with " << szError << "\n";
else
dwDriverHandle = ((DTSA_AB_DH_LOCAL*)pDtsa)->driver_id;
if (retval != DTL_SUCCESS)
char szError[256];
std::cout << "Can not get name from this driver ID, error: " << retval << " with " << szError
<< "\n";
else
std::cout << "Got name (" << szRetName << ") from Driver handle (" << dwDriverHandle << ")\n";
retval = DTL_CloseDtsa(pDtsa);
DTL_DestroyDtsa(pDtsa);
else
DTL_UNINIT(0);
return retval;
int main()
retval = RequestCIPService();
::Sleep(1000);
retval = ReadWriteTagOnUnconnectedConnection();
::Sleep(1000);
retval = ReadTagOnConnectedConnection();
::Sleep(1000);
retval = OpenCloseCIPNormalConnection();
::Sleep(1000);
retval = OpenCloseCIPLargeConnection();
::Sleep(1000);
retval = RequestMultiPacketsOnceOnConnectedConnection();
::Sleep(1000);
retval = RequestMultiPacketsOnceOnUnconnectedConnection();
::Sleep(1000);
retval = AsyncSendPCCCToDevice();
::Sleep(1000);
retval = SyncSendPCCCToDevice();
::Sleep(1000);
retval = TryOtherInterfaces();
::Sleep(1000);
The supported tag and tag’s data type are listed as follows:
Tag
Data type
• DINT
• INT
• SINT
• UDINT
• UINT
• USINT
• REAL
• BOOL
NOTE: FactoryTalk Linx SDK Test Client can access bits with integers in Logix controllers.
Prerequisites
• Activate FactoryTalk Linx Gateway
• Enable access to the SDK API
Tip: You can right-click a device in the FactoryTalk Linx Network Browser and then select Device
Properties to get the path. For example, APCNSDA1PYSF62!AB_ETH-5\\10.224.82.10.
2. Select Connect.
Device information appears, such as the product name and serial number, when the FactoryTalk Linx SDK
Interface works.
3. When connected to a Logix controller, the tool can access a tag. In the Tag ID box, enter the tag ID.
If the tag is under a global scope, the name format is:
◦ Scalar: GlobalTagName
◦ Structure: GlobalStructureTagName.ElementName
◦ Array: GlobalArrayTagName[Index]
The [Index] means the array ID, for example, 01, 02, and so on. You can customize it as needed.
If the tag is under a program, the name format is:
◦ Scalar: Program:ProgramName.TagName
◦ Structure: Program:ProgramName.StructureTagName.ElementName
◦ Array: Program:ProgramName.ArrayTagName[Index]
The [Index] means the array ID, for example, 01, 02, and so on. You can customize it as needed.
Items Descriptions
Device Path Shows the entered device path in the FactoryTalk Linx topology.
You can right-click a device in the FactoryTalk Linx Network
Browser and then select Device Properties to get the path.
Device Information Shows the device information, such as the product name and
serial number, when the FactoryTalk Linx SDK Interface works.
Tag Value Shows the tag ID's value when you select Read.
Tip: The newly built application with these sample codes will not contain the Rockwell Automation digital signature.
You can get your signature as needed.
Legal Notices
Legal Notices
Rockwell Automation publishes legal notices, such as privacy policies, license agreements, trademark disclosures,
and other terms and conditions on the Legal Notices page of the Rockwell Automation website.
You can view a full list of all open source software used in this product and their corresponding licenses by opening
the oss_license.txt file located in your product's OPENSOURCE folder on your hard drive. This file is divided into these
sections:
• Components
Includes the name of the open source component, its version number, and the type of license.
• Copyright Text
Includes the name of the open source component, its version number, and the copyright declaration.
• Licenses
Includes the name of the license, the list of open source components citing the license, and the terms of the
license.
You may obtain Corresponding Source code for open source packages included in this product from their respective
project web site(s). Alternatively, you may obtain complete Corresponding Source code by contacting Rockwell
Automation via the Contact form on the Rockwell Automation website: http://www.rockwellautomation.com/global/
about-us/contact/contact.page. Please include "Open Source" as part of the request text.
The following table lists the commercially licensed software components in FactoryTalk Linx Gateway.
Component Copyright
Softing OPC UA C++ Server SDK for Windows version 6.20.1 Copyright Softing Industrial Automation GmbH 2009 - 2023
Technical Support Center Find help with how-to videos, FAQs, chat, user forums, and product notification updates. rok.auto/support
Local Technical Support Phone Numbers Locate the telephone number for your country. rok.auto/phonesupport
Literature Library Find installation instructions, manuals, brochures, and technical data publications. rok.auto/literature
Product Compatibility and Download Center Get help determining how products interact, check features and capabilities, and find rok.auto/pcdc
(PCDC) associated firmware.
Documentation feedback
Your comments help us serve your documentation needs better. If you have any suggestions on how to improve our content, complete the form at rok.auto/docfeedback.
Rockwell Automation maintains current product environmental information on its website at rok.auto/pec.
Rockwell Otomasyon Ticaret A.Ş. Kar Plaza İş Merkezi E Blok Kat:6 34752 İçerenköy, İstanbul, Tel: +90 (216) 5698400 EEE Yönetmeliğine Uygundur
Copyright © 2023, Rockwell Automation Technologies, Inc. All rights reserved. Printed in the U.S.A.