/*------------------------------------------------------------------- ModbusProtocolDLL.cpp ------------------------------------------------------------------- (c) 2009 Vector Informatik GmbH. All rights reserved. ------------------------------------------------------------------- */ #include "StdAfx.h" #include "ModbusProtocolDLL.h" #include "ModbusProtocolAddOn.h" #include "ModbusProtocol.h" #include //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------*/ //! Reply new ProtocolManager instance /*! This function is called on loading of this DLL by the IPB Packet API. It must register the protocol of this DLL. */ STDAPI DllRegisterAddOn( NIPB::IAddOnRegistrar* registrar ) { if (registrar == NULL) { return E_INVALIDARG; } std::ofstream log; log.open("log.txt", std::ofstream::out); // // register the signal protocol at the IPB Packet Lib. For the protocol // UDP is used. // ModbusProtocolAddOn *mbpao = new ModbusProtocolAddOn(); if (registrar->RegisterProtocol( "modbus", mbpao, "udp", ModbusProtocol::kServerPort, ModbusProtocol::kClientPort ) != NIPB::kOK) { log << "Could not register UDP 502 -> 50002\n"; log.close(); mbpao->Release(); return NIPB::kError; } /*if (registrar->RegisterProtocol( "modbus", mbpao, "udp", 0xFFFFFFFF, ModbusProtocol::kServerPort ) != NIPB::kOK) { log << "Could not register UDP 50002 -> 502\n"; log.close(); mbpao->Release(); return NIPB::kError; }*/ log << "Registered Modbus for UDP\n"; log.close(); return S_OK; } /*--------------------------------------------------------------------*/ //! Return interface version /*! This DLL must support a proper version of the IBP Packet API. */ STDAPI DllGetApiVersion( unsigned long /*out*/*major, unsigned long /*out*/*minor, unsigned long /*out*/*structVersion ) { if (major) { *major = IPB_PACKET_LIB_INTERFACE_VERSION_MAJOR; } if (minor) { *minor = IPB_PACKET_LIB_INTERFACE_VERSION_MINOR; } if (structVersion) { *structVersion = IPB_PACKET_LIB_STRUCT_VERSION; } return S_OK; } //////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////