AdsLib
 All Classes Files Functions Variables Typedefs Macros Pages
Functions
AdsLib.h File Reference
#include "AdsDef.h"

Go to the source code of this file.

Functions

long AdsAddRoute (AmsNetId ams, const char *ip)
 
void AdsDelRoute (AmsNetId ams)
 
long AdsPortCloseEx (long port)
 
long AdsPortOpenEx ()
 
long AdsGetLocalAddressEx (long port, AmsAddr *pAddr)
 
long AdsSyncReadReqEx2 (long port, const AmsAddr *pAddr, uint32_t indexGroup, uint32_t indexOffset, uint32_t bufferLength, void *buffer, uint32_t *bytesRead)
 
long AdsSyncReadDeviceInfoReqEx (long port, const AmsAddr *pAddr, char *devName, AdsVersion *version)
 
long AdsSyncReadStateReqEx (long port, const AmsAddr *pAddr, uint16_t *adsState, uint16_t *devState)
 
long AdsSyncReadWriteReqEx2 (long port, const AmsAddr *pAddr, uint32_t indexGroup, uint32_t indexOffset, uint32_t readLength, void *readData, uint32_t writeLength, const void *writeData, uint32_t *bytesRead)
 
long AdsSyncWriteReqEx (long port, const AmsAddr *pAddr, uint32_t indexGroup, uint32_t indexOffset, uint32_t bufferLength, const void *buffer)
 
long AdsSyncWriteControlReqEx (long port, const AmsAddr *pAddr, uint16_t adsState, uint16_t devState, uint32_t bufferLength, const void *buffer)
 
long AdsSyncAddDeviceNotificationReqEx (long port, const AmsAddr *pAddr, uint32_t indexGroup, uint32_t indexOffset, const AdsNotificationAttrib *pAttrib, PAdsNotificationFuncEx pFunc, uint32_t hUser, uint32_t *pNotification)
 
long AdsSyncDelDeviceNotificationReqEx (long port, const AmsAddr *pAddr, uint32_t hNotification)
 
long AdsSyncGetTimeoutEx (long port, uint32_t *timeout)
 
long AdsSyncSetTimeoutEx (long port, uint32_t timeout)
 

Detailed Description

Copyright (c) 2015 - 2016 Beckhoff Automation GmbH & Co. KG

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Function Documentation

long AdsAddRoute ( AmsNetId  ams,
const char *  ip 
)

Add new ams route to target system

Parameters
[in]amsaddress of the target system
[in]ipaddress of the target system
Returns
ADS Return Code
void AdsDelRoute ( AmsNetId  ams)

Delete ams route that had previously been added with AdsAddRoute().

Parameters
[in]amsaddress of the target system
long AdsGetLocalAddressEx ( long  port,
AmsAddr pAddr 
)

Returns the local NetId and port number.

Parameters
[in]portport number of an Ads port that had previously been opened with AdsPortOpenEx().
[out]pAddrPointer to the structure of type AmsAddr.
Returns
ADS Return Code
long AdsPortCloseEx ( long  port)

The connection (communication port) to the message router is closed. The port to be closed must previously have been opened via an AdsPortOpenEx() call.

Parameters
[in]portport number of an Ads port that had previously been opened with AdsPortOpenEx().
Returns
ADS Return Code
long AdsPortOpenEx ( )

Establishes a connection (communication port) to the message router. The port number returned by AdsPortOpenEx() is required as parameter for further AdsLib function calls.

Returns
port number of a new Ads port or 0 if no more ports available
long AdsSyncAddDeviceNotificationReqEx ( long  port,
const AmsAddr pAddr,
uint32_t  indexGroup,
uint32_t  indexOffset,
const AdsNotificationAttrib pAttrib,
PAdsNotificationFuncEx  pFunc,
uint32_t  hUser,
uint32_t *  pNotification 
)

A notification is defined within an ADS server (e.g. PLC). When a certain event occurs a function (the callback function) is invoked in the ADS client (C program).

Parameters
[in]portport number of an Ads port that had previously been opened with AdsPortOpenEx().
[in]pAddrStructure with NetId and port number of the ADS server.
[in]indexGroupIndex Group.
[in]indexOffsetIndex Offset.
[in]pAttribPointer to the structure that contains further information.
[in]pFuncPointer to the structure describing the callback function.
[in]hUser32-bit value that is passed to the callback function.
[out]pNotificationAddress of the variable that will receive the handle of the notification.
Returns
ADS Return Code
long AdsSyncDelDeviceNotificationReqEx ( long  port,
const AmsAddr pAddr,
uint32_t  hNotification 
)

A notification defined previously is deleted from an ADS server.

Parameters
[in]portport number of an Ads port that had previously been opened with AdsPortOpenEx().
[in]pAddrStructure with NetId and port number of the ADS server.
[in]hNotificationAddress of the variable that contains the handle of the notification.
Returns
ADS Return Code
long AdsSyncGetTimeoutEx ( long  port,
uint32_t *  timeout 
)

Read the configured timeout for the ADS functions. The standard value is 5000 ms.

Parameters
[in]portport number of an Ads port that had previously been opened with AdsPortOpenEx().
[out]timeoutBuffer to store timeout value in ms.
Returns
ADS Return Code
long AdsSyncReadDeviceInfoReqEx ( long  port,
const AmsAddr pAddr,
char *  devName,
AdsVersion version 
)

Reads the identification and version number of an ADS server.

Parameters
[in]portport number of an Ads port that had previously been opened with AdsPortOpenEx().
[in]pAddrStructure with NetId and port number of the ADS server.
[out]devNamePointer to a character string of at least 16 bytes, that will receive the name of the ADS device.
[out]versionAddress of a variable of type AdsVersion, which will receive the version number, revision number and the build number.
Returns
ADS Return Code
long AdsSyncReadReqEx2 ( long  port,
const AmsAddr pAddr,
uint32_t  indexGroup,
uint32_t  indexOffset,
uint32_t  bufferLength,
void *  buffer,
uint32_t *  bytesRead 
)

Reads data synchronously from an ADS server.

Parameters
[in]portport number of an Ads port that had previously been opened with AdsPortOpenEx().
[in]pAddrStructure with NetId and port number of the ADS server.
[in]indexGroupIndex Group.
[in]indexOffsetIndex Offset.
[in]bufferLengthLength of the data in bytes.
[out]bufferPointer to a data buffer that will receive the data.
[out]bytesReadpointer to a variable. If successful, this variable will return the number of actually read data bytes.
Returns
ADS Return Code
long AdsSyncReadStateReqEx ( long  port,
const AmsAddr pAddr,
uint16_t *  adsState,
uint16_t *  devState 
)

Reads the ADS status and the device status from an ADS server.

Parameters
[in]portport number of an Ads port that had previously been opened with AdsPortOpenEx().
[in]pAddrStructure with NetId and port number of the ADS server.
[out]adsStateAddress of a variable that will receive the ADS status (see data type ADSSTATE).
[out]devStateAddress of a variable that will receive the device status.
Returns
ADS Return Code
long AdsSyncReadWriteReqEx2 ( long  port,
const AmsAddr pAddr,
uint32_t  indexGroup,
uint32_t  indexOffset,
uint32_t  readLength,
void *  readData,
uint32_t  writeLength,
const void *  writeData,
uint32_t *  bytesRead 
)

Writes data synchronously into an ADS server and receives data back from the ADS server.

Parameters
[in]portport number of an Ads port that had previously been opened with AdsPortOpenEx().
[in]pAddrStructure with NetId and port number of the ADS server.
[in]indexGroupIndex Group.
[in]indexOffsetIndex Offset.
[in]readLengthLength, in bytes, of the read buffer readData.
[out]readDataBuffer for data read from the ADS server.
[in]writeLengthLength of the data, in bytes, send to the ADS server.
[in]writeDataBuffer with data send to the ADS server.
[out]bytesReadpointer to a variable. If successful, this variable will return the number of actually read data bytes.
Returns
ADS Return Code
long AdsSyncSetTimeoutEx ( long  port,
uint32_t  timeout 
)

Alters the timeout for the ADS functions. The standard value is 5000 ms.

Parameters
[in]portport number of an Ads port that had previously been opened with AdsPortOpenEx().
[in]timeoutTimeout in ms.
Returns
ADS Return Code
long AdsSyncWriteControlReqEx ( long  port,
const AmsAddr pAddr,
uint16_t  adsState,
uint16_t  devState,
uint32_t  bufferLength,
const void *  buffer 
)

Changes the ADS status and the device status of an ADS server.

Parameters
[in]portport number of an Ads port that had previously been opened with AdsPortOpenEx().
[in]pAddrStructure with NetId and port number of the ADS server.
[in]adsStateNew ADS status.
[in]devStateNew device status.
[in]bufferLengthLength of the additional data, in bytes, send to the ADS server.
[in]bufferBuffer with additional data send to the ADS server.
Returns
ADS Return Code
long AdsSyncWriteReqEx ( long  port,
const AmsAddr pAddr,
uint32_t  indexGroup,
uint32_t  indexOffset,
uint32_t  bufferLength,
const void *  buffer 
)

Writes data synchronously to an ADS server.

Parameters
[in]portport number of an Ads port that had previously been opened with AdsPortOpenEx().
[in]pAddrStructure with NetId and port number of the ADS server.
[in]indexGroupIndex Group.
[in]indexOffsetIndex Offset.
[in]bufferLengthLength of the data, in bytes, send to the ADS server.
[in]bufferBuffer with data send to the ADS server.
Returns
ADS Return Code