Hello ,
I try to opne a class 3 connection, but I always get am error message:
TLR_E_EIP_ENCAP_INVALID_TRANSP(0xC01E001E) -->Invalid transport type
Here is my source code:
TLR_PACKET_HEADER_T tHead_test9_openclass3={
0x00000020,//ulDest
0,//ulSrc
0,//ulDestId
0,//ulSrcId
12,//ulLen
0,//ulId
0,//ulSta
0x1a38,//ulCmd
0,//ulExt
0,//ulRout
};
TLR_PACKET_HEADER_T tHead_test9_class3_sendMessage={
0x00000020,//ulDest
0,//ulSrc
0,//ulDestId
0,//ulSrcId
12,//ulLen
0,//ulId
0,//ulSta
0x1a3a,//ulCmd
0,//ulExt
0,//ulRout
};
TLR_PACKET_HEADER_T tHead_test9_closeclass3={
0x00000020,//ulDest
0,//ulSrc
0,//ulDestId
0,//ulSrcId
12,//ulLen
0,//ulId
0,//ulSta
0x1a3C,//ulCmd
0,//ulExt
0,//ulRout
};
EIP_OBJECT_OPEN_CL3_REQ_Ttag tTest9_Class3;
tTest9_Class3.ulIPAddr = EIP_testparm.uIPAdress_EIP;
tTest9_Class3.ulTime = 1000;
tTest9_Class3.ulTimeoutMult = 0x02;
EIP_OBJECT_PACKET_OPEN_CL3_REQ_Ttag Test9_Class3={
tHead_test9_openclass3,
tTest9_Class3,
};
EIP_OBJECT_CONNECT_MESSAGE_REQ_Ttag tTest9_class3message;
tTest9_class3message.ulConnection = 0;
tTest9_class3message.bService = 0x0e;
tTest9_class3message.usClass = 0x64;
tTest9_class3message.usInstance = 0x01;
tTest9_class3message.usAttribute = 0x01;
EIP_OBJECT_PACKET_CONNECT_MESSAGE_REQ_Ttag class3_message= {
tHead_test9_class3_sendMessage,
tTest9_class3message
};
EIP_OBJECT_CLOSE_CL3_REQ_T tTest9_closeclass3;
tTest9_closeclass3.ulConnection = 0;
EIP_OBJECT_PACKET_CLOSE_CL3_REQ_T test9_closeclass3 = {
tHead_test9_closeclass3,
tTest9_closeclass3
};//Open Class 3 Connection
printf("Open Class 3 Connection\n");
if(CIFX_NO_ERROR != (lRet=xChannelPutPacket(Hilscher_parm.hChannel,(CIFX_PACKET*)&Test9_Class3,PACKET_WAIT_TIMEOUT)))
{
eip_Util.showError(lRet);
}
Sleep(1000);
if(CIFX_NO_ERROR != (lRet=xChannelGetPacket(Hilscher_parm.hChannel,sizeof(helpPacket),&helpPacket,PACKET_WAIT_TIMEOUT)))
{
eip_Util.showError(lRet);
}
else
{
printf("Antwortpacket:\r\n");
eip_Util.DumpPacket_EIP((CIFX_PACKET*)&helpPacket);
}
//send Class 3 Message
EIP_OBJECT_OPEN_CL3_CNF_Ttag* pp = (EIP_OBJECT_OPEN_CL3_CNF_Ttag*)helpPacket.abData;
TLR_UINT32 class3_connectionhandle = pp->ulConnection;
tTest9_class3message.ulConnection = class3_connectionhandle;
tTest9_closeclass3.ulConnection = class3_connectionhandle;
printf("Connection Handle:%X\n",tTest9_class3message.ulConnection);
Sleep(2000);
printf("Send Class 3 Message(0x64,0x01,0x01)\n");
if(CIFX_NO_ERROR != (lRet=xChannelPutPacket(Hilscher_parm.hChannel,(CIFX_PACKET*)&class3_message,PACKET_WAIT_TIMEOUT)))
{
eip_Util.showError(lRet);
}
Sleep(1000);
if(CIFX_NO_ERROR != (lRet=xChannelGetPacket(Hilscher_parm.hChannel,sizeof(helpPacket),&helpPacket,PACKET_WAIT_TIMEOUT)))
{
eip_Util.showError(lRet);
}
else
{
printf("Antwortpacket:\r\n");
eip_Util.DumpPacket_EIP((CIFX_PACKET*)&helpPacket);
eip_Util.DumphexData(helpPacket.abData,helpPacket.tHeader.ulLen);
}
Sleep(2000);
//Close Class 3 Connection
printf("Close Class 3 Connection:\n");
if(CIFX_NO_ERROR != (lRet=xChannelPutPacket(Hilscher_parm.hChannel,(CIFX_PACKET*)&test9_closeclass3,PACKET_WAIT_TIMEOUT)))
{
eip_Util.showError(lRet);
}
Sleep(1000);
if(CIFX_NO_ERROR != (lRet=xChannelGetPacket(Hilscher_parm.hChannel,sizeof(helpPacket),&helpPacket,PACKET_WAIT_TIMEOUT)))
{
eip_Util.showError(lRet);
}
else
{
printf("Antwortpacket:\r\n");
eip_Util.DumpPacket_EIP((CIFX_PACKET*)&helpPacket);
eip_Util.DumphexData(helpPacket.abData,helpPacket.tHeader.ulLen);
}
Sleep(5000);Hope that someone can help me
Regards C.Huiskens
Hi
This might be a silly newbie question here goes.
Anyone who can explain what is really required in the NetX50 (EIPDemo - project) in order to establish a class 3 connection? I have been looking at the EIP_OBJECT_CL3_SERVICE_IND/RES but need someething else in order to get things working.
in the EIPDemo_Process.C, switch(((TLR_PACKET_HEADER_T*)pvPck)->ulCmd)
I have added the following:
case EIP_OBJECT_CL3_SERVICE_IND:
Eip_Class3_Ind(ptRsc); //Handle all class3 explicit messages
break;
But I never get so far as calling the Eip_Class3_Ind(ptRsc); -function (using breakpoints as an indication).
Regards
HC
Hi,
you will only get Cl3 service indications to registered objects.
Register an object can be done at the following way for a cifX
void EIS_RegisterObject ( void )
{
unsigned long ulErr;
unsigned long ulFlags = 0;
EIP_OBJECT_MR_PACKET_REGISTER_REQ_T tReq;
tReq.tHead.ulSrc = 0x10;
tReq.tHead.ulSrcId = 0x41;
tReq.tHead.ulDest = 0x20;
tReq.tHead.ulLen = sizeof(EIP_OBJECT_MR_REGISTER_REQ_T);
tReq.tHead.ulCmd = EIP_OBJECT_MR_REGISTER_REQ;
tReq.tHead.ulSta = 0;
tReq.tHead.ulExt = 0;
tReq.tData.ulClass = 100;
ulErr = xChannelPutPacket( hChannel, (CIFX_PACKET*)&tReq, 0);
} /* EIS_RegisterObject */
Regards
RH
Thx. for quick response I guessed something like that was missing, but I am still confused since the class 3 object was supposed to be supported by the stack already so there shouldnt be any reason to re-register the class again.
I am currently not using the CifX -driver approach but I will try re-register the class again and test this.
Thx. again rh.
regards.
Nevertheless... It works when the class is registered. Only thing I cant get an RES-message through, it seems like the class 3 connection crashes.
my code:
void FAR Eip_Class3_Ind(EIP_DEMO_RSC_T FAR* ptRsc, EIP_OBJECT_PACKET_CL3_SERVICE_IND_T FAR* pvPck)
{
EIP_OBJECT_PACKET_CL3_SERVICE_RES_T FAR* ptRespPck;
ptRespPck->tHead.ulDest = (UINT32)0x20;
ptRespPck->tHead.ulSrc = (UINT32)0x10;
ptRespPck->tHead.ulDestId = 0;
ptRespPck->tHead.ulSrcId = 0;
ptRespPck->tHead.ulLen = EIP_OBJECT_CL3_SERVICE_RES_SIZE;
ptRespPck->tHead.ulId = 1;
ptRespPck->tHead.ulSta = 0;
ptRespPck->tHead.ulCmd = EIP_OBJECT_CL3_SERVICE_RES;
ptRespPck->tHead.ulExt = 0;
ptRespPck->tData.ulConnectionId = pvPck->tData.ulConnectionId;
ptRespPck->tData.ulService = pvPck->tData.ulService;
ptRespPck->tData.ulObject = pvPck->tData.ulObject;
ptRespPck->tData.ulInstance = pvPck->tData.ulInstance;
ptRespPck->tData.ulAttribute = pvPck->tData.ulAttribute;
ptRespPck->tData.ulGRC = 0;
ptRespPck->tData.ulERC = 0;
ptRespPck->tData.abData[0] = 0xAA;
//Send response package back
TLR_QUE_RETURNPACKET( ptRespPck );
Is there anyone who has an ideer?
Regards,
Hilscher Gesellschaft für Systemautomation mbH
Hi hc@jvl.dk,
Can you tell me the error code you get when you try to send the response packet?
I'm not sure if that yould be the problem, but actually you have to add the length of the data you want to send with that packet:
For example: ptRespPck->tHead.ulLen = EIP_OBJECT_CL3_SERVICE_RES_SIZE + 1 , since you only send one byte of data.
If nothing helps, try not to adapt the fields ulDest, ulSrc, ulSrcId and ulDestId. Actually never change these fields when receiving indications. Otherwise the routing could fail.
I hope this helps. :-)
hi Kai,
in the "ethernetip adapter protocol api", the"eip_object_packet_cl3_service_res_t"--"ullen" is 56+n .
but
in the "ethernetip scanner protocol api", the"eip_object_packet_cl3_service_res_t"--"ullen" is 28+n .
why they are different?
Hilscher Gesellschaft für Systemautomation mbH
Hi williams,
This seems to be a mistake in the manual. Actually both should be 56+n.
7 * uint32 = 28 bytes . why should set ulen = 56?
Hilscher Gesellschaft für Systemautomation mbH
Apparently I wasn't able to do this calculation correctly.
Of course, you're right...
i have register a object to MR,and can receive the set single attribute service packet from dpm. but my response packet to dpm cannot work in the stack. could you show me the example code to response a "set attribute single" request ?
hc@jvl.dk meet the same problem as mine. i wanner know whether it is a bug for cifxeis.nxf to send res packet of cl3 ???
Hilscher Gesellschaft für Systemautomation mbH
hi williams,
here is some example code:
unsigned char g_abUserObjData[2048];
void EIS_Handle_Cl3_Service_Indication(void* hChannel, EIP_OBJECT_PACKET_CL3_SERVICE_IND_T *ptInd)
{
unsigned long ulGRC = 0;
unsigned long ulERC = 0;
EIP_OBJECT_PACKET_CL3_SERVICE_RES_T *ptRes;
ptRes = (EIP_OBJECT_PACKET_CL3_SERVICE_RES_T *)ptInd;
switch (ptInd->tData.ulService)
{
case 0x10: /* Set attribute single */
/* Get length of data included in the indication paket */
ulUserObjLength = ptInd->tHead.ulLen - EIP_OBJECT_CL3_SERVICE_IND_SIZE;
/* store data */
memcpy(&g_abUserObjData[0], &ptInd->tData.abData[0], ulUserObjLength);
/* Set paket length for response paket */
ptRes->tHead.ulLen = EIP_OBJECT_CL3_SERVICE_RES_SIZE;
break;
default:
ulGRC = 0x08; /* bad service */
ptRes->tHead.ulLen = EIP_OBJECT_CL3_SERVICE_RES_SIZE;
break;
}
ptRes->tHead.ulSta = 0;
ptRes->tHead.ulCmd = EIP_OBJECT_CL3_SERVICE_RES;
ptRes->tData.ulGRC = ulGRC,
ptRes->tData.ulERC = ulERC;
ulErr = xChannelPutPacket( hChannel, (CIFX_PACKET*)ptRes, 0);
}
If this does not work, let me know the error code you get or the behavior you observe.
Hi all,
I actually got it to work without any errors, but the response package size :
ptRes->tHead.ulLen
Should be EIP_OBJECT_CL3_SERVICE_RES_SIZE + n
Where n = bytes in service data, shouldnt it?
So if I have let's say 4 bytes of service data then n = 4
I will not post my code yet, since I still have some minor errors that needs to be corrected.
regards
HC
Hilscher Gesellschaft für Systemautomation mbH
I am trying to establishi the Class 3 connection with NetX Evalution baord. I am not getting the vaules for Service, Class, Attribute and Instance. Can you please help me ?
Thanks in advance..
Hilscher Gesellschaft fuer Systemautomation mbH
Please see this topic
Ralf Hornung
Hilscher
Hi Huiskens,
I believe your connection runs into timeout. When you open the connection you set the time to 1000 (means 1ms) and you have a timeout multiplier from 16. After 16 ms the connection will timeout if no request is send.
At the upper code there are Sleep statments of 1 sec.
Regards
rh