industrialNETworXnetx

DrunkenHero

DrunkenHero

| 18.12.2009 | 10:50 | 12 replies

Open Class 1 Connection

Hi ,

I have a CIFX 50 RE as master and a slave, the used protocoll is Ethernet IP.

Now I want to open a Class 1 Connection with two assemblys (100,101).
But in the documentation of the EIP Scanner Protocoll I just found a way to open a
Class 3 connection (EtherNetIP Scanner Protocol API.pdf,page147).
Can somebody help me?

Regards
C.Huiskens

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 18.12.2009 | 15:01

Hi,

the Hilscher stack does not support Class 1 connections.
Only Class 0 / 3.

To open a Class 0 connection you have to perform a EIP_OBJECT_REGISTER_CONNECTION_REQ/CNF.

dlickay

dlickay

| 14.07.2010 | 11:33

Hi,

I'm also working with this card and would like
to know whether Class1 connections are now supported. Could you tell me how to open a Class1 connection using the cifx32DLL? I tried using EIP_OBJECT_CM_PACKET_OPEN_CONN_REQ_T but the API always returns TLR_E_EIP_OBJECT_UNKNOWN_CONNECTION.

Regards!

Here is my code:

CIFX_PACKET sCnReq = {0};
CIFX_PACKET sCnRsp = {0};
EIP_OBJECT_CM_PACKET_OPEN_CONN_REQ_T* psCnReq = (EIP_OBJECT_CM_PACKET_OPEN_CONN_REQ_T*) &sCnReq;
EIP_OBJECT_CM_PACKET_OPEN_CONN_CNF_T* psCnRsp = (EIP_OBJECT_CM_PACKET_OPEN_CONN_CNF_T*) &sCnRsp;
char pbString[100] = {0};
unsigned char* pbData;
char pbIpAddr[25] = {0};

unsigned char pbCnPath[] = {
0x34, /* Key segment */
0x04, /* Key format */
0x00, 0x00, /* VendorID */
0x00, 0x00, /* Device type */
0x00, 0x00, /* Product code */
0x00, 0x00, /* Major/Minor revision (Compatibility bit: 7 of major) */
0x20, 0x04, /* Logical class segment, class assembly */
0x24, 0x01, /* Logical instance segment */
0x2C, 0x64, /* Logical connection point segment */
0x2C, 0x74 /* Logical connection point segment */
};

sprintf(pbIpAddr, "%d.%d.%d.%d",
(0xC0A86407 >> 24) & 0xFF,
(0xC0A86407 >> 16) & 0xFF,
(0xC0A86407 >> 8) & 0xFF,
(0xC0A86407 & 0xFF));

// Fill packet header content
psCnReq->tHead.ulDest = RCX_PKT_COMM_CHANNEL_TOKEN;
psCnReq->tHead.ulSrc = 0;
psCnReq->tHead.ulDestId = 0;
psCnReq->tHead.ulSrcId = 0;
psCnReq->tHead.ulLen = (TLR_UINT32) (EIP_OBJECT_CM_OPEN_CONN_REQ_SIZE
+ sizeof(pbCnPath) + strlen(pbIpAddr));
psCnReq->tHead.ulId = 0xFFBB0000;
psCnReq->tHead.ulSta = 0;
psCnReq->tHead.ulCmd = EIP_OBJECT_CM_CLOSE_CONN_REQ;

// Fill CIP packet content
psCnReq->tData.ulConnectionSn = 0x01;
psCnReq->tData.ulTimeoutMult = 6;
psCnReq->tData.ulClassTrigger = 0x01;
psCnReq->tData.ulProRpi = 10000;
psCnReq->tData.ulProParams = 0x4808;
psCnReq->tData.ulConRpi = 10000;
psCnReq->tData.ulConParams = 0x2804;

pbData = &sCnReq.abData[0];
pbData += EIP_OBJECT_CM_OPEN_CONN_REQ_SIZE;

psCnReq->tData.ulHostDestSize = (TLR_UINT32) strlen(pbIpAddr);
psCnReq->tData.ulHostDestOffs = (TLR_UINT32) (pbData - &sCnReq.abData[0]);
memcpy(pbData, pbIpAddr, psCnReq->tData.ulHostDestSize);
pbData += psCnReq->tData.ulHostDestSize;

psCnReq->tData.ulPort = 0;
psCnReq->tData.ulOpenPathSize = sizeof(pbCnPath) / 2;
psCnReq->tData.ulClosePathSize = sizeof(pbCnPath) / 2;
psCnReq->tData.ulPathOffs = (TLR_UINT32) (pbData - &sCnReq.abData[0]);
memcpy(pbData, pbCnPath, sizeof(pbCnPath));
pbData += sizeof(pbCnPath);

psCnReq->tData.ulProConnPoint = 0x74;
psCnReq->tData.ulConConnPoint = 0x64;

dwRet = xChannelPutPacket(phChnHdl, &sCnReq, 1000);
dwRet = xChannelGetPacket(phChnHdl, sizeof(sCnRsp), &sCnRsp, 1000);
Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 14.07.2010 | 15:39

Hi,

the problem is, that the command does not match to the used package.

Please use "EIP_OBJECT_REGISTER_CONNECTION_REQ/CNF"

Regards
AJ

dlickay

dlickay

| 19.07.2010 | 19:07

Hi AJ,

that was a dumb error from my side, sorry!

Now I opened a Class1 connection and see the traffic on the wire. But I'm not able to write nor read data from and to the I/O segment from scanner side. The error 0x800C0021 is returned (COM-flag not set).

What requirements to the connection settings do I have to fulfill in order to successfully communicate with the target device in both directions? What is the source of the COM-flag error? I mean, both devices (the scanner and the adapter) are sending Class1 messages cyclically but I'm not able to write data from the scanner!

Hope you can help me!

Regards,
dlickay

p.s. I opened the connection using EIP_OBJECT_CM_OPEN_CONN_REQ because EIP_OBJECT_REGISTER_CONNECTION_REQ always returns 0xC0000124 (TLR_E_PARAMETER_ERROR) either using the same parameters as with EIP_OBJECT_CM_OPEN_CONN_REQ!

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 21.07.2010 | 08:46

Hi dlickay,

the function "EIP_OBJECT_CM_OPEN_CONN_REQ" is not the right choice. With this function you did not get the information if a connection is established. This works only for registered connections.

Regards
AJ

dlickay

dlickay

| 22.07.2010 | 17:23

Hi AJ,

okay, so you mean I should use EIP_OBJECT_REGISTER_CONNECTION_REQ. Using this packet I always get the error 0xC0000124 (TLR_E_PARAMETER_ERROR). I think the problem are the usImpDefLen, bImpDefSize and abImpDef fields. What do they stand for? The EtherNet/IP Protocol API do not realy describe how to fill them. Can you take a look at this code and maybe you find my error!

Thanks!

How do I close this connection? Which packet should I take?

CIFX_PACKET sCnReq = {0};
CIFX_PACKET sCnRsp = {0};
EIP_OBJECT_PACKET_REGISTER_CONNECTION_REQ_T* psCnReq = NULL;
EIP_OBJECT_PACKET_REGISTER_CONNECTION_CNF_T* psCnRsp = NULL;
unsigned char* pbData;

psCnReq = (EIP_OBJECT_PACKET_REGISTER_CONNECTION_REQ_T*) &sCnReq;
psCnRsp = (EIP_OBJECT_PACKET_REGISTER_CONNECTION_CNF_T*) &sCnRsp;

unsigned char pbCnPath[] = {
0x34, /* Key segment */
0x04, /* Key format */
0x64, 0x00, /* VendorID */
0x0C, 0x00, /* Device type */
0xab, 0xab, /* Product code */
0x01, 0x02, /* Major/Minor revision (Compatibility bit: 7 of major) */
0x20, 0x04, /* Logical class segment, class assembly */
0x24, 0x01, /* Logical instance segment */
0x2C, 0x64, /* Logical connection point segment */
0x2C, 0x74 /* Logical connection point segment */
};

// Fill packet header content
psCnReq->tHead.ulDest = RCX_PKT_COMM_CHANNEL_TOKEN;
psCnReq->tHead.ulSrc = 0;
psCnReq->tHead.ulDestId = 0;
psCnReq->tHead.ulSrcId = 0;
psCnReq->tHead.ulLen = EIP_OBJECT_REGISTER_CONNECTION_REQ_SIZE + sizeof(pbCnPath);
psCnReq->tHead.ulId = 0x001;
psCnReq->tHead.ulSta = 0;
psCnReq->tHead.ulCmd = EIP_OBJECT_REGISTER_CONNECTION_REQ;

pbData = &sCnReq.abData[0];
pbData += EIP_OBJECT_REGISTER_CONNECTION_REQ_SIZE;

psCnReq->tData.usConnectionFlags = (2 << 4);
psCnReq->tData.usVendorID = 0x64;
psCnReq->tData.usProductType = 0x0c;
psCnReq->tData.usProductCode = 0xabab;
psCnReq->tData.bMinRev = 2;
psCnReq->tData.bMajRev = 1;
psCnReq->tData.bConnMultiplier = 6;
psCnReq->tData.bClassTrigger = 0x01;
psCnReq->tData.ulRpiOT = 100000;
psCnReq->tData.usNetParamOT = 0x4808;
psCnReq->tData.ulRpiTO = 100000;
psCnReq->tData.usNetParamTO = 0x4808;
psCnReq->tData.bOpenPathSize = sizeof(pbCnPath) / 2;
psCnReq->tData.ulPathOffset = EIP_OBJECT_REGISTER_CONNECTION_REQ_SIZE;

psCnReq->tData.ulConnHandle = 0x12345678;
memcpy(&psCnReq->tData.abConnName[0], "CONN1", sizeof("CONN1"));
psCnReq->tData.bNameSize = sizeof("CONN1") / 2;
psCnReq->tData.usConnNameLen = sizeof("CONN1");

memcpy(pbData, pbCnPath, sizeof(pbCnPath));
vinay

vinay

| 03.08.2010 | 11:19

Hi

Hi AJ,

I used following code to register the connection with assembly instance 100 & 150 but getting error com-flag not set.. i think my parameters are not set properly. can anybody guide me?

struct

{

EIP_OBJECT_PACKET_REGISTER_CONNECTION_REQ_T tPacket;

 

unsigned char abData[1600 - sizeof

(EIP_OBJECT_PACKET_REGISTER_CONNECTION_REQ_T)];

} tPkt;

 

unsigned long

ulErr;

 

unsigned char

abPath[] = {

 

/* Port Segment IP Address 192.168.00.2 */

0x12, 0x0C, 0x31, 0x39, 0x32, 0x2E, 0x31, 0x36, 0x38, 0x2E, 0x30, 0x30, 0x2E, 0x32,

 

/* electrical key */

 

/*0x34, 0x04, 0x1B, 0x01, 0x0C, 0x00, 0x01, 0x10, 0x01, 0x01,*/

 

0x34, 0x04, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00,

 

 

/* connection path */

0x20, 0x04, 0x24, 0x01, 0x2C, 0x96, 0x2C, 0x64};

// I/P instance 150(96) & O/P instance 100(64)

 

tPkt.tPacket.tHead.ulSrc = (UINT32)0x10;

tPkt.tPacket.tHead.ulSrcId = 0;

tPkt.tPacket.tHead.ulDest = (UINT32)0x20;

tPkt.tPacket.tHead.ulDestId = 0;

tPkt.tPacket.tHead.ulSta = 0;

tPkt.tPacket.tHead.ulCmd = EIP_OBJECT_REGISTER_CONNECTION_REQ;

tPkt.tPacket.tHead.ulId = 1;

tPkt.tPacket.tHead.ulExt = 0;

 

/* connection Handle = unical number given by configuration software */

tPkt.tPacket.tData.ulConnHandle = atChannel[USED_EIMCFG_CHANNEL].hChannel;

//0x12345678;

 

/* Values can set to 0 are reserved at the moment */

tPkt.tPacket.tData.bGeneralStatus = 0x00;

tPkt.tPacket.tData.bReserved1 = 0x00;

tPkt.tPacket.tData.usExtendedStatus = 0x0000;

tPkt.tPacket.tData.usConnectionFlags = 0x0000;

 

/* Device Data of Adapter */

tPkt.tPacket.tData.usVendorID = 0x011B;

tPkt.tPacket.tData.usProductType = 0x000C;

tPkt.tPacket.tData.usProductCode = 0x0101;

tPkt.tPacket.tData.bMinRev = 0x01;

tPkt.tPacket.tData.bMajRev = 0x01;

 

/* not used */

tPkt.tPacket.tData.ulCSDataIdx = 0x00000000;

tPkt.tPacket.tData.bConnMultiplier = 0x03;

tPkt.tPacket.tData.bClassTrigger = 0x81;

tPkt.tPacket.tData.ulRpiOT = 1000;

//max its 3 sec

tPkt.tPacket.tData.usNetParamOT = 0x4804;

tPkt.tPacket.tData.ulRpiTO = 1000;

tPkt.tPacket.tData.usNetParamTO = 0x2804;

//max its 3 sec

tPkt.tPacket.tData.bOpenPathSize = 0x10;

//instead of 0x10

tPkt.tPacket.tData.bReserved2 = 0;

tPkt.tPacket.tData.ulPathOffset = EIP_OBJECT_REGISTER_CONNECTION_REQ_SIZE;

tPkt.tPacket.tData.usConfig1Size = 0;

tPkt.tPacket.tData.ulConfig1Offset = 0;

tPkt.tPacket.tData.bNameSize = 0x08;

tPkt.tPacket.tData.bReserved3 = 0x00;

tPkt.tPacket.tData.usConnNameLen = 0x0008;

memcpy(&tPkt.tPacket.tData.abConnName[0],

"Connect1"

,8);

tPkt.tPacket.tData.usFormatNumber = 0x0001;

tPkt.tPacket.tData.bImpDefSize = 0x10;

tPkt.tPacket.tData.usImpDefLen = 0x0010;

 

 

/* Data of the connection are mapped into assemblies of the scanner */

 

tPkt.tPacket.tData.abImpDef[0] = 100;

tPkt.tPacket.tData.abImpDef[1] = 0;

tPkt.tPacket.tData.abImpDef[2] = 0;

tPkt.tPacket.tData.abImpDef[3] = 0;

tPkt.tPacket.tData.abImpDef[4] = 0;

tPkt.tPacket.tData.abImpDef[5] = 0;

tPkt.tPacket.tData.abImpDef[6] = 0;

tPkt.tPacket.tData.abImpDef[7] = 0;

tPkt.tPacket.tData.abImpDef[8] = 150;

tPkt.tPacket.tData.abImpDef[9] = 0;

tPkt.tPacket.tData.abImpDef[10] = 0;

tPkt.tPacket.tData.abImpDef[11] = 0;

tPkt.tPacket.tData.abImpDef[12] = 0;

tPkt.tPacket.tData.abImpDef[13] = 0;

tPkt.tPacket.tData.abImpDef[14] = 0;

tPkt.tPacket.tData.abImpDef[15] = 0;

 

 

tPkt.tPacket.tData.usConfig2Size = 0x0000;

tPkt.tPacket.tData.ulConfig2Offset = 0x00000000;

 

/* reserved shall be 0 */

tPkt.tPacket.tData.usProxyVendorID = 0x0000;

tPkt.tPacket.tData.usProxyProductType = 0x0000;

tPkt.tPacket.tData.usProxyProductCode = 0x0000;

tPkt.tPacket.tData.bProxyMinRev = 0x00;

tPkt.tPacket.tData.bProxyMajRev = 0x00;

 

memcpy(&tPkt.abData[0], &abPath[0],

sizeof

(abPath));

tPkt.tPacket.tHead.ulLen = EIP_OBJECT_REGISTER_CONNECTION_REQ_SIZE +

(tPkt.tPacket.tData.bOpenPathSize << 1) +

tPkt.tPacket.tData.usConfig1Size +

tPkt.tPacket.tData.usConfig2Size;

ulErr = xChannelPutPacket( atChannel[USED_EIMCFG_CHANNEL].hChannel, (CIFX_PACKET*)&tPkt.tPacket, 0);

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 03.08.2010 | 12:51

Hi vinay,

I think there is a problem in your used package. I compared your code with the one I have and it is at some parts different (no I do not mean the IP-Address ;-) )

Please compare my code snippet with yours.

void EIMCFG_RegisterConnection1 ( void )
{
  struct {
    EIP_OBJECT_PACKET_REGISTER_CONNECTION_REQ_T tPacket;
    unsigned char abData[1600 - sizeof(EIP_OBJECT_PACKET_REGISTER_CONNECTION_REQ_T)];
  } tPkt;
  unsigned long ulErr;
  unsigned char abPath[] = {
    /* Port Segment IP Address 192.168.10.2 */
    0x12, 0x0C, 0x31, 0x39, 0x32, 0x2E, 0x31, 0x36, 0x38, 0x2E, 0x31, 0x30, 0x2E, 0x32,
    /* electrical key */
    0x34, 0x04, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00,
    /* connection path */
    0x20, 0x04, 0x24, 0x01, 0x2C, 0x64, 0x2C, 0x65};



  tPkt.tPacket.tHead.ulSrc = (UINT32)0x10;
  tPkt.tPacket.tHead.ulSrcId = 0;
  tPkt.tPacket.tHead.ulDest = (UINT32)0x20;
  tPkt.tPacket.tHead.ulDestId = 0;
  tPkt.tPacket.tHead.ulSta = 0;
  tPkt.tPacket.tHead.ulCmd = EIP_OBJECT_REGISTER_CONNECTION_REQ;
  tPkt.tPacket.tHead.ulId  = 1;
  tPkt.tPacket.tHead.ulExt  = 0;

  /* connection Handle = unical number given by configuration software */
  tPkt.tPacket.tData.ulConnHandle = 1;
  /* Values can set to 0 are reserved at the moment */ 
  tPkt.tPacket.tData.bGeneralStatus                      = 0x00;
  tPkt.tPacket.tData.bReserved1                          = 0x00;
  tPkt.tPacket.tData.usExtendedStatus                    = 0x0000;
  tPkt.tPacket.tData.usConnectionFlags                   = 0x0000;

  /* Device Data of Adapter */
  tPkt.tPacket.tData.usVendorID                          = 0x011B;     
  tPkt.tPacket.tData.usProductType                       = 0x000C;
  tPkt.tPacket.tData.usProductCode                       = 0x0101;
  tPkt.tPacket.tData.bMinRev                             = 0x01;
  tPkt.tPacket.tData.bMajRev                             = 0x01;
  /* not used */
  tPkt.tPacket.tData.ulCSDataIdx                         = 0x00000000;
  tPkt.tPacket.tData.bConnMultiplier                     = 0x03;
  tPkt.tPacket.tData.bClassTrigger                       = 0x01;
  tPkt.tPacket.tData.ulRpiOT                             = 0x000186A0;
  tPkt.tPacket.tData.usNetParamOT                        = 0x4826;
  tPkt.tPacket.tData.ulRpiTO                             = 0x000186A0;
  tPkt.tPacket.tData.usNetParamTO                        = 0x2826;
  tPkt.tPacket.tData.bOpenPathSize                       = 0x10;
  tPkt.tPacket.tData.bReserved2                          = 0;
  tPkt.tPacket.tData.ulPathOffset                        = EIP_OBJECT_REGISTER_CONNECTION_REQ_SIZE;
  tPkt.tPacket.tData.usConfig1Size                       = 0;
  tPkt.tPacket.tData.ulConfig1Offset                     = 0;
  tPkt.tPacket.tData.bNameSize                           = 0x08;
  tPkt.tPacket.tData.bReserved3                          = 0x00;
  tPkt.tPacket.tData.usConnNameLen                       = 0x0008; 
  memcpy(&tPkt.tPacket.tData.abConnName[0], "Connect1",8);
  tPkt.tPacket.tData.usFormatNumber                      = 0x0001;
  tPkt.tPacket.tData.bImpDefSize                         = 0x10;
  tPkt.tPacket.tData.usImpDefLen                         = 0x0010;
 
  /* Data of the connection are mapped into assemblies of the scanner */
  ((EIP_CC_USER_ATTR_DATA_T*)&tPkt.tPacket.tData.abImpDef[0])->ulInstanceOT = 101;
  ((EIP_CC_USER_ATTR_DATA_T*)&tPkt.tPacket.tData.abImpDef[0])->ulInstanceTO = 100;
  tPkt.tPacket.tData.usConfig2Size                       = 0x0000;
  tPkt.tPacket.tData.ulConfig2Offset                     = 0x00000000;
  /* reserved shall be 0 */
  tPkt.tPacket.tData.usProxyVendorID                     = 0x0000;
  tPkt.tPacket.tData.usProxyProductType                  = 0x0000;
  tPkt.tPacket.tData.usProxyProductCode                  = 0x0000;
  tPkt.tPacket.tData.bProxyMinRev                        = 0x00;
  tPkt.tPacket.tData.bProxyMajRev                        = 0x00;
 
  memcpy(&tPkt.abData[0], &abPath[0], sizeof(abPath));

  tPkt.tPacket.tHead.ulLen = EIP_OBJECT_REGISTER_CONNECTION_REQ_SIZE +
                                                  (tPkt.tPacket.tData.bOpenPathSize << 1) +
                                                  tPkt.tPacket.tData.usConfig1Size +
                                                  tPkt.tPacket.tData.usConfig2Size;
  ulErr = xChannelPutPacket( atChannel[USED_EIMCFG_CHANNEL].hChannel, (CIFX_PACKET*)&tPkt.tPacket, 0); 
}

Regards
AJ

vinay

vinay

| 10.08.2010 | 11:32

AJ can you tell me about the parameter below! what should be the unical number given?

 

 

/* connection Handle = unical number given by configuration software */

 

tPkt.tPacket.tData.ulConnHandle =atChannel[bChannel].hChannel;

 

 

should this handle be the same as u get at the time of opening a channel? as shown below:

 

ulErr = xChannelOpen ( hDriver, uBoardInfo.tBoardInfo.abBoardName, bChannel, &atChannel[bChannel].hChannel);//handle (atChannel[bChannel].hChannel)

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 10.08.2010 | 11:36

Hi vinay,

for ulConnHandle you can try "2".

 

Regards
AJ

vinay

vinay

| 03.09.2010 | 08:25

with the help of EIP_OBJECT_REGISTER_CONNECTION_REQ/CNF-1A34 I have open class 1 cyclic connection. how to close the connection I have tried using EIP_OBJECT_CM_CLOSE_CONN_REQ/CNF – Close a Connection. But once i reopen or re-register the cyclic connection i'm getting error 0xC00000124. Can anyone tell me

how to close class 1 cyclic connection or unregister the connection?

thanks in advance

Kai

Kai

| 03.09.2010 | 10:34

Hi vinay,

actually you're doing the right things.

Just try using another value for ulConnHandle when re-registering the connection with EIP_OBJECT_REGISTER_CONNECTION_REQ.

 

 

Login