industrialNETworXnetx

DrunkenHero

DrunkenHero

| 05.10.2009 | 12:00 | 17 replies

CIFX 50 RE + Beginner Question

Hello,

I am an absolut beginner with the CIFX 50 RE. I never worked with it before and I need some help.
At the moment I am trying to write a little C Programm(Visual Studio 2005 C++), which has to send a packet to an ethernet device(PING).
I connected the ehternet device(Ethernet/IP) over a HUB to the CIFX Card.
Can someone please post a little example code, so that I can see how I have to programm the CIFX Card.
Especially I want to know how to tell the CIFX Card , the Destination IP of the Packet.

Regards
Christian Huiskens
(Sorry my english isn't so good :D )

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 05.10.2009 | 14:05

Hi,

at first you should start to configure your cifX card as an EtherNet/IP card. There for you can use several tools.
Sycon.Net
cifX Setup
or the netX Configuration and Diagnostic Utility.

The best way is to have a look into the CIFX-RE_usermanual_en.pdf manual. It describes all necessary steps.
When you have installed the card you should read the EtherNet/IP Protocol API manual. It is also included on the CD.
This manual will help you to communicate with the stack over your application.

DrunkenHero

DrunkenHero

| 05.10.2009 | 17:08

Hi AJ,
thanks for the quick answer.

I did everything you said but now I have another problem.
I am looking for a function , to send a predefined packet to the Ethernet Device.
The only function I found is "TLR_QUE_SEND_PACKET_FIFO()", but when I try to compile the programm, following error message appears" error C3861: "TLR_QUE_SEND_PACKET_FIFO": Bezeichner wurde nicht gefunden.", is there a special header file which I have to include first?Or is there another function to sned a packet?

Regards
Christian Huiskens

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 06.10.2009 | 08:07

Hi,

where did you find the function "TLR_QUE_SEND_PACKET_FIFO()"?

DrunkenHero

DrunkenHero

| 06.10.2009 | 09:06

HI,
I found it int the "EtherNetIP Scanner Protocol API.pdf",page 161(Using the macro TLR_QUE_SEND_PACKET_FIFO() will send the packet to the EipEncap-Task process queue).
Because of your reaction I think ,that that was the wrong idea to send a packet.
Could you tell me which basic steps I have to programm to communicate with an ethernet device over the CIFX card?

regards
C.Huiskens

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 06.10.2009 | 14:21

Hi,

the reason, why I am struggling is that you are using a cifX card. You do not write any code directly on the netX.
The command "TLR_QUE_SEND_PACKET_FIFO()" must be used in the case you are writing an application directly on the netX.

But in case of the cifX card you are using the cifX driver to communicate with the device. Here for is the "xChannelPutPacket" the right command to sent a package.

DrunkenHero

DrunkenHero

| 06.10.2009 | 16:30

Hi,
first of all thanks that you have patience with me, but I think step by tep I get into it.

So did I undestand you right that it is impossible to programm the netx of a cifx card??
And I still have the problem that I dont know how to tell the CIFX card , at which IP it should send the packets?

Example:
Get a ping from the device:

|CIFX 50RE(EIP Scanner)|------------>|EthernetDevice(Slave)|
(192.168.1.126)______________________(192.168.1.123)

Regards
C.Huiskens

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 07.10.2009 | 08:58

Hi,

I think you miss one more manual which is not on the delivered CD :|

Please download from the Hilscher web page in the Download section the Protocol API manual for the TCP/IP stack. This manual includes the commands for your need

DrunkenHero

DrunkenHero

| 07.10.2009 | 16:31

Hi AJ,

today I tried to write a programm using the CIFX device driver.

HANDLE hDriver = NULL;
	HANDLE hSys = NULL;
	long lRet =CIFX_NO_ERROR;

lRet = xDriverOpen(&hDriver);

if(CIFX_NO_ERROR != lRet)
{
printf("Error opening driver. lRet=0x%08X\r\n", lRet);
}
else{
HANDLE hChannel = NULL;
lRet = xChannelOpen(hDriver, "cifX0", 0, &hChannel);
if(CIFX_NO_ERROR != lRet)
{
printf("Error opening Channel!");
}
else{
// xChannelReset(hChannel,CIFX_SYSTEMSTART,1000000);
CIFX_PACKET sendPacket={

0,//ulDest /*!< destination of packet, process queue */
0,//ulSrc /*!< source of packet, process queue */
0,//ulDestId /*!< destination reference of packet */
0,//ulSrcId /*!< source reference of packet */
0,//ulLen /*!< length of packet data without header */
0,//ulId /*!< identification handle of sender */
0,//ulState /*!< status code of operation */
0,//ulCmd /*!< packet command defined in TLR_Commands.h */
0,//ulExt /*!< extension */
0,//ulRout /*!< router */
};

CIFX_PACKET recPacket={

0,//printf("%u\n",tSendPkt.tHeader.ulDest );//=0; /*!< destination of packet, process queue */
0,//printf("%u\n",tSendPkt.tHeader.ulSrc );//=0; /*!< source of packet, process queue */
0,//printf("%u\n",tSendPkt.tHeader.ulDestId );//=0; /*!< destination reference of packet */
0,//printf("%u\n",tSendPkt.tHeader.ulSrcId );//=0; /*!< source reference of packet */
0,//printf("%u\n",tSendPkt.tHeader.ulLen );//=0; /*!< length of packet data without header */
0,//printf("%u\n",tSendPkt.tHeader.ulId );//=0; /*!< identification handle of sender */
0,//printf("%u\n",tSendPkt.tHeader.ulState );//=0; /*!< status code of operation */
0,//printf("%u\n",tSendPkt.tHeader.ulCmd );//=0; /*!< packet command defined in TLR_Commands.h */
0,//printf("%u\n",tSendPkt.tHeader.ulExt );//=0; /*!< extension */
0,//printf("%u\n",tSendPkt.tHeader.ulRout );//=0; /*!< router */
};
if(CIFX_NO_ERROR != (lRet = xChannelPutPacket(hChannel, &sendPacket, PACKET_WAIT_TIMEOUT)))
{
printf("Error sending packet to device!\r\n");
} else
{
printf("Send Packet:\r\n");
DumpPacket(&sendPacket);
if(CIFX_NO_ERROR != (lRet = xChannelGetPacket(hChannel, sizeof(recPacket), &recPacket, PACKET_WAIT_TIMEOUT)) )
{
printf("Error getting packet from device!\r\n");
} else
{
printf("Received Packet:\r\n");
DumpPacket(&recPacket);
}
lRet=xChannelIOWrite(hChannel,0,0,0,0,0);
if((lRet==CIFX_NO_ERROR))
printf("gut");
else{
char szError[1024] ={0};
xDriverGetErrorDescription(lRet,szError,sizeof(szError));
printf("%s\n",szError);
}


}
printf("hat geklappt");
}
}
getchar();
return 0;



My Problem is that the last funtion I used(xChannelIOWrite(hChannel,0,0,0,0,0)) always returns an error message

(Com Flag not set). I have this problem also when I try to start a communication with sycon.net.

Can you help me with that problem?

Regards
C.Huiskens

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 08.10.2009 | 07:05

Hi,

COM FLAG not set, means that the communication flag is not set. This tells you, that you have not established a communication between the master and the slave.
Before you start to write your own application, you should try to establish a communication with the delivered applications. When this is working you should start with your own application. Very helpful for you will also the C-Toolkit. This is also on the CD.

fedul

fedul

| 17.03.2010 | 18:06

 

Hi

 

I got a
similar problem «Communication flag not set»! After tuning cifx RE 50 Scanner
in SYCON, and Adapter to netX Configuration Tool status LEDs on the Adapter and
Scaner is SYS: green; MS: green, NS: flashing green. Adapter and Scanner
connected via a hub. No errors. However, in the dialogue «Diagnostic»:

Extended
Diagnosis-> RX_SYSTEM-> InitBatch Status-> Current state = Error

Extended
Diagnosis-> RX_SYSTEM-> InitBatch Status-> InitBatch Result = No DBM
file

does not
work «Start Communication» because «COM-flag not set»
. Why? 

 

And when
you run the examples from the Toolkit error occurs in the line xChannelIORead
(hChannel, 0, 0, sizeof (abRecvData), abRecvData, 10).

 

Please
specify the reason for the problem.

 

 

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 18.03.2010 | 08:56

Hi,

that means, that the stack is not configured.

fedul wrote:
And when
you run the examples from the Toolkit error occurs in the line
xChannelIORead
(hChannel, 0, 0, sizeof (abRecvData), abRecvData, 10)

Nice, could you tell us which error do you get?!

Regards
AJ

fedul

fedul

| 18.03.2010 | 09:57

Hi

It is clear, but how can I configure the stack? With the help of utilities SYCON.net or netX Configuration Tool? Is it possible somewhere to take the example of setting up the stack?

Andreas Jacob wrote:

Nice, could you tell us which error do you get?!

If I may I will complete withdrawal of the application:
Quote:

Error opening configuration file 'C:\Program Files\cifX Device Driver\config.nxd'!
Error opening configuration file 'C:\Program Files\cifX Device Driver\nwid.nxd'!
---------- Board/Channel enumeration demo ----------
Found Board cifX0
DeviceNumber : 1250100
SerialNumber : 20912
Board ID : 0
System Error : 0x00000000
Channels : 1
DPM Size : 65536
- Channel 0:
Firmware : EtherNet/IP Scanner
Version : 2.1.0 build 19
Date : 01/16/2009 State = 0x00000000
----------------------------------------------------
---------- System Device handling demo ----------
System Channel Info Block:
DPM Size : 16384
Device Number : 1250100
Serial Number : 20912
Manufacturer : 1
Production Date : 2346
Device Class : 3
HW Revision : 2
HW Compatibility : 0
System Mailbox State: MaxSend = 16, Pending Receive = 0
Send Packet:
Dest : 0x00000000 ID : 0x00000000
Src : 0x00000000 Sta : 0x00000000
DestID : 0x00000000 Cmd : 0x00000000
SrcID : 0x00000000 Ext : 0x00000000
Len : 0x00000000 Rout : 0x00000000
Data: System Mailbox State: MaxSend = 15, Pending Receive = 0
Received Packet:
Dest : 0x00000000 ID : 0x00000000
Src : 0x00000000 Sta : 0xC0000004
DestID : 0x00000000 Cmd : 0x00000001
SrcID : 0x00000000 Ext : 0x00000000
Len : 0x00000000 Rout : 0x00000000
Data: System Mailbox State: MaxSend = 16, Pending Receive = 0 State = 0x00000000 ----------------------------------------------------
---------- Communication Channel demo ----------
Communication Channel Info:
Device Number : 1250100
Serial Number : 20912
Firmware : EtherNet/IP Scanner
FW Version : 2.1.0 build 19
FW Date : 01/16/2009
Mailbox Size : 1596
Send Packet:
Dest : 0x00000000 ID : 0x00000000
Src : 0x00000000 Sta : 0x00000000
DestID : 0x00000000 Cmd : 0x00000000
SrcID : 0x00000000 Ext : 0x00000000
Len : 0x00000000 Rout : 0x00000000
Data: Received Packet:
Dest : 0x00000000 ID : 0x00000000
Src : 0x00000000 Sta : 0xC0000004
DestID : 0x00000000 Cmd : 0x00000001
SrcID : 0x00000000 Ext : 0x00000000
Len : 0x00000000 Rout : 0x00000000
Data: Error reading IO Data area! Error 800C0021 State = 0x800C0021

----------------------------------------------------
--- Read / Write Block Information ---
Read CONTROL Block

00 00 00 00
Write CONTROL Block
Read COMMON Status Block

07 00 00 00
Write COMMON Status Block
Error writing to common status block. lRet = 0x800a0006
Read EXTENDED Status Block

00 00 00 00
Write EXTENDED Status Block
Error writing to extended status block. lRet = 0x800a0006

Error 800C0021 -  Communication flag not set

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 18.03.2010 | 10:22

Hi,

I could saw in your trace that you are using the EtherNetIP Scanner. In that case you have to do the configuration with Sycon.net. But please do not forget to download the config to the card at the end ;-)

Regards
AJ

fedul

fedul

| 18.03.2010 | 11:13

I do
configuration by SYCON.net, in the end push on "Apply" and “Download”
(menu shortcut). Recording on the device is made, it is seen by a flashing LED.
May be to do
something else?

 Where can I
download the example of configuration file and how to download it into the
device?

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 18.03.2010 | 11:42

have you connected a slave?

fedul

fedul

| 18.03.2010 | 12:01

 

They are connected by cable and in SYCON.net project, but in diagnostic windows connection disable.

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 18.03.2010 | 13:20

and physically? Maybe you should get in contact with the hotline.

Login