EtherNetIP (Un)connected Message with AsNxEipS using X20IF10D1_1

Hi Community,
I want to read out the VendorID and SerialNumber of an EIP-Adapter-Device which is connected to my X20 PLC using an EthernetIP Scanner interface (X20IF10D1_1).
The communication of cyclic I/O process data works fine, but i have no success with a-cylic reading out attributes like VendorID, ProductCode or SerialNumberof the Identity-Object (class Code 0x01) using Unconnected Message with the FunctionBlock eipsObjUnconnectMessage() of AsNxEipS library.

here are some (pseudo)code snippets in C:
eipRxBuffer USINT[0…80];
eipTxBuffer USINT[0…80];
EtherNetIpScannerFSM_state = EIPS_SUBSCRIBE;

void _CYCLIC ProgramCyclic(void)
{
//working state machine
switch (EtherNetIpScannerFSM_state) {
case EIPS_SUBSCRIBE:
eipsSubscribe_instance.enable = 1;
eipsSubscribe_instance.pDevice = (UDINT)&eipScanner_station;
eipsSubscribe(&eipsSubscribe_instance); //call function block
if(eipsSubscribe_instance.status != ERR_FUB_BUSY){
fub_status = eipsSubscribe_instance.status;
check_status = 1;
instruction_ready = 1;
}
break;
case EIPS_READ_IDENTITY_INFORMATION:
eipsObjUnconnectMsg_instance.enable = 1;
eipsObjUnconnectMsg_instance.pDevice = (UDINT)&eipScanner_station;
eipsObjUnconnectMsg_instance.pIpAddress = “192.168.210.10”;
//eipsObjUnconnectMsg_instance.service = 0x01; //Get_Attributes_All
eipsObjUnconnectMsg_instance.service = 0x0E; //Get_Attribute_Single
eipsObjUnconnectMsg_instance.class = 0x0001; //Identity Object (Class code: 0x01)
eipsObjUnconnectMsg_instance.instance = 1;
eipsObjUnconnectMsg_instance.attribute = 1; //VendorID
//eipsObjUnconnectMsg_instance.attribute = 6; //SerialNumber
eipsObjUnconnectMsg_instance.dataCount = sizeof(eipTxBuffer);
eipsObjUnconnectMsg_instance.pData = (UDINT)eipTxBuffer; //buffer is empty because i have no payload to send to the device…
eipsObjUnconnectMsg_instance.pResData = (UDINT)eipRxBuffer;
eipsObjUnconnectMessage(&eipsObjUnconnectMsg_instance); //call function block
if(eipsObjUnconnectMsg_instance.status != ERR_FUB_BUSY){
fub_status = eipsObjUnconnectMsg_instance.status;
check_status = 1;
instruction_ready = 1;
}
break;
case EIPS_DO_NOTHING:
break;
default:
// this should not happen
break;
}

//EtherNetIP error handling
if(check_status){
	if (fub_status == ERR_OK){
		//no error
	}else if (fub_status == eipsERR_SEND_MESSAGE){
		EtherNetIpScannerFSM_state = EIPS_DO_NOTHING;
	}else if (fub_status == eipsERR_EIP_STACK){  //37813
		//error - check eipStatus of currently active FB			
               if(EtherNetIpScannerFSM_state == EIPS_READ_IDENTITY_INFORMATION){
			//error message belongs to other FB... todo
			EtherNetIpScannerFSM_state = EIPS_DO_NOTHING;
		}
		else{
			//error message belomgs to other FB... todo
			EtherNetIpScannerFSM_state = EIPS_DO_NOTHING;
		}								
	}else if (fub_status == eipsERR_PARAMETER){
		EtherNetIpScannerFSM_state = EIPS_DO_NOTHING;
	}else if (fub_status == eipsERR_SUBSCRIBE_LISTENER){ 
		EtherNetIpScannerFSM_state = EIPS_DO_NOTHING;
	}else{
		//do other error handling here
	}
	check_status = 0; //stop checking
}

//EtherNetIP state machine control
//if(instruction_ready && fub_status == ERR_OK){
if(instruction_ready){
	instruction_ready = 0;
	
	if(fub_status == ERR_OK){					
		switch (EtherNetIpScannerFSM_state) {
			case EIPS_SUBSCRIBE:
				EtherNetIpScannerFSM_state =EIPS_READ_IDENTITY_INFORMATION;
				break;
			case EIPS_READ_IDENTITY_INFORMATION:
				//here i would expect to read out the desired data from eipRxBuffer... 
                                   EtherNetIpScannerFSM_state = EIPS_DO_NOTHING;
				break;
			case EIPS_DO_NOTHING:	
				break;
			default:
				// this should not happen
				break;
		}		
	}else{
		//we have a problem, fub_status != ERR_OK
		EtherNetIpScannerFSM_state = EIPS_DO_NOTHING;
	}
}

}
}

In state EIPS_READ_IDENTITY_INFORMATION i always get the FBstatus “37813” ( eipsERR_EIP_STACK) and eipsObjUnconnectMsg_instance.eipStatus results to 16#C000_0001. Unfortunately i cannot find this error code in the Hilscher netX Ethernet-IP-Scanner-Stack-Status.
What can be wrong here?

Any help appreciated, kind regards
Albert

Hello Albert,

Very quickly looking over your code, I found one point of possible issue.

You should set eipsObjUnconnectMsg_instance.dataCount to 0 if you are making a Get request. If I recall correctly, EthernetIP explicit message Get requests should have 0 bytes of payload data. You are transmitting 81 bytes of data in your Get request (size of your Tx buffer), which is not what you are intending.

Give that a try and let us know how it goes.

-Austin

Hello, the error you get is according to Hilscher NetX documentation:
image

As it is a “general” error it might not be mentioned in the EIP documentation but in the “common” part of the documentation

1 Like

Hello Austin and Oliver,
Many thanks to both of you for your valuable and quick support. I was now able to successfully read the attributes of the IdentityObject (such as VendorID or SerialNumber) of my device using eipsObjUnconnectMessage(). The first problem was indeed, as Austin suspected, the incorrect specification of dataCount with a value other than 0 (-> resulting in the general error 16#C000_0001 (ERR_HIL_FAIL)).

The second problem was that the attributes in my device could apparently only be read with ServiceCode ‘Get_Attribute_Single’ (0x0E) but not with ‘Get_Attributes_All’ (0x01).
My device also does not support reading with an eipsObjConnectMessage().
The Hilscher EtherNet/IP Tool was very helpful for finding this errors.
Thanks again & best regards,
Albert

1 Like