This commit is contained in:
zhouhuang 2024-12-13 20:11:21 +08:00
parent 23d24127c1
commit 60fa5d14f4

View File

@ -7,6 +7,8 @@
#include "AdsException.h"
#include "AdsLib.h"
#include "Log.h"
#include <error.h>
#include <string.h>
#include <limits>
namespace Beckhoff
@ -18,7 +20,7 @@ static AmsNetId* Connect(AmsNetId ams, const char* ip)
const auto error = ConnectTarget(ams, ip);
if (error) {
if(error == ROUTERERR_PORTALREADYINUSE){
LOG_INFO("Connection["<<ip<<"] has been built.");
LOG_INFO("Connection[" << ip << "] has been built.");
return new AmsNetId { ams };
}
@ -166,7 +168,7 @@ AdsDeviceState AdsDevice::GetState() const
if(m_Connected == true){
auto error = AdsSyncReadStateReqEx(GetLocalPort(), &m_Addr, &state[0], &state[1]);
if (error) {
LOG_ERROR("AdsDevice can not read device state.");
LOG_ERROR("AdsDevice can not read device state. \n" << error << strerror(errno));
//throw AdsException(error);
return {static_cast<ADSSTATE>(state[0]), static_cast<ADSSTATE>(state[1])};
}