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