Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions AdsLib/AdsLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

#include "Sockets.h"

#ifdef BHF_ADS_EXPORT_C
extern "C" {
#endif
/**
* Reads data synchronously from an ADS server.
* @param[in] port port number of an Ads port that had previously been opened with AdsPortOpenEx().
Expand Down Expand Up @@ -185,6 +188,10 @@ long GetRemoteAddress(const std::string &remote, AmsNetId &netId);
}
}

#define AdsAddRoute bhf::ads::AddLocalRoute
#define AdsDelRoute bhf::ads::DelLocalRoute
#define AdsSetLocalAddress bhf::ads::SetLocalAddress
long AdsAddRoute(AmsNetId netId, const char* ipAddr);
void AdsDelRoute(AmsNetId netId);
void AdsSetLocalAddress(AmsNetId netId);

#ifdef BHF_ADS_EXPORT_C
}
#endif
14 changes: 13 additions & 1 deletion AdsLib/standalone/AdsDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -407,12 +407,24 @@ struct AdsNotificationAttrib {
* @brief This structure is also passed to the callback function.
*/
struct AdsNotificationHeader {
/* Original TwinCAT SDK headers have
* uint32_t | uint64_t | uint32_t
* We use the same order when compiled as a shared library to allow
* consumers to dynamically link against us or the upstream TwinCAT.
*/
#ifdef BHF_ADS_USE_TWINCAT_ORDER
/** Handle for the notification. Is specified when the notification is defined. */
uint32_t hNotification;

/** Contains a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC). */
uint64_t nTimeStamp;
#else
/** Contains a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC). */
uint64_t nTimeStamp;

/** Handle for the notification. Is specified when the notification is defined. */
uint32_t hNotification;

#endif
/** Number of bytes transferred. */
uint32_t cbSampleSize;
};
Expand Down
18 changes: 18 additions & 0 deletions AdsLib/standalone/AdsLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#include "AdsLib.h"
#include "AmsRouter.h"

#ifdef BHF_ADS_EXPORT_C
extern "C" {
#endif
static AmsRouter &GetRouter()
{
static AmsRouter router;
Expand Down Expand Up @@ -286,3 +289,18 @@ long AdsSyncSetTimeoutEx(long port, uint32_t timeout)
ASSERT_PORT(port);
return GetRouter().SetTimeout((uint16_t)port, timeout);
}

long AdsAddRoute(AmsNetId netId, const char* ipAddr) {
return bhf::ads::AddLocalRoute(netId, ipAddr);
}

void AdsDelRoute(AmsNetId netId) {
bhf::ads::DelLocalRoute(netId);
}

void AdsSetLocalAddress(AmsNetId netId) {
bhf::ads::SetLocalAddress(netId);
}
#ifdef BHF_ADS_EXPORT_C
}
#endif
6 changes: 6 additions & 0 deletions AdsLib/standalone/AdsLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

#include "AdsDef.h"

#ifdef BHF_ADS_EXPORT_C
extern "C" {
#endif
/**
* The connection (communication port) to the message router is
* closed. The port to be closed must previously have been opened via
Expand Down Expand Up @@ -38,3 +41,6 @@ long AdsGetLocalAddressEx(long port, AmsAddr *pAddr);
* @return [ADS Return Code](https://infosys.beckhoff.com/content/1031/tcadscommon/html/ads_returncodes.htm?id=1666172286265530469)
*/
long AdsSyncSetTimeoutEx(long port, uint32_t timeout);
#ifdef BHF_ADS_EXPORT_C
}
#endif
13 changes: 12 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,18 @@ adslib = static_library('AdsLib',
install: true,
)

install_libs = [ adslib ]
adslib_so = shared_library('adslib',
[common_files, router_files],
cpp_args: [
'-DBHF_ADS_EXPORT_C',
'-DBHF_ADS_USE_TWINCAT_ORDER',
],
include_directories: inc,
install: true,
dependencies: libs,
)

install_libs = [ adslib, adslib_so ]

adslib_dep = declare_dependency(
include_directories : inc,
Expand Down