This commit is contained in:
zhouhuang 2025-01-13 09:26:27 +08:00
parent 27dca2295d
commit 71e4686245
2 changed files with 13 additions and 6 deletions

View File

@ -33,6 +33,7 @@ struct myAdsVariable {
{
if (!m_Route.IsConnected()) return FALSE;
uint32_t bytesRead = 0;
if (m_Handle.get() == 0) return FALSE;
auto error = m_Route.ReadReqEx2(m_IndexGroup,
*m_Handle,
size,

View File

@ -108,7 +108,7 @@ AdsHandle AdsDevice::GetHandle(const uint32_t offset) const
AdsHandle AdsDevice::GetHandle(const std::string& symbolName) const
{
if(m_Connected == true)
if (m_Connected == true)
{
uint32_t handle = 0;
uint32_t bytesRead = 0;
@ -121,9 +121,11 @@ AdsHandle AdsDevice::GetHandle(const std::string& symbolName) const
);
if (error || (sizeof(handle) != bytesRead)) {
LOG_ERROR("AdsDevice GetSymbolHandle is failed: "<<symbolName<<".");
LOG_ERROR("AdsDevice GetSymbolHandle is failed: " << symbolName << ".");
//throw AdsException(error);
}else{
}
else
{
handle = Beckhoff::letoh(handle);
return {new uint32_t {handle}, {std::bind(&AdsDevice::DeleteSymbolHandle, this, std::placeholders::_1)}};
}
@ -137,7 +139,8 @@ AdsHandle AdsDevice::GetHandle(const uint32_t indexGroup,
PAdsNotificationFuncEx callback,
const uint32_t hUser) const
{
if(m_Connected == true){
if (m_Connected == true)
{
uint32_t handle = 0;
auto error = AdsSyncAddDeviceNotificationReqEx(
*m_LocalPort, &m_Addr,
@ -146,10 +149,13 @@ AdsHandle AdsDevice::GetHandle(const uint32_t indexGroup,
callback,
hUser,
&handle);
if (error || !handle) {
if (error || !handle)
{
LOG_WARN("AdsDevice GetNotificationHandle is failed.");
//throw AdsException(error);
}else{
}
else
{
handle = Beckhoff::letoh(handle);
return {new uint32_t {handle}, {std::bind(&AdsDevice::DeleteNotificationHandle, this, std::placeholders::_1)}};
}