SOEM v1.2.5
Functions | Variables

nicdrv.h File Reference

Headerfile for nicdrv.c. More...

Functions

int ec_setupnic (const char *ifname, int secondary)
int ec_closenic (void)
void ec_setupheader (void *p)
void ec_setbufstat (uint8 idx, int bufstat)
uint8 ec_getindex (void)
int ec_outframe (uint8 idx, int sock)
int ec_outframe_red (uint8 idx)
int ec_waitinframe (uint8 idx, int timeout)
int ec_srconfirm (uint8 idx, int timeout)

Variables

ec_bufT ec_rxbuf [EC_MAXBUF]
ec_bufT ec_txbuf [EC_MAXBUF]
ec_bufT ec_txbuf2
int ec_txbuflength [EC_MAXBUF]
int ec_txbuflength2
int ec_incnt
int ec_errcnt
int ec_redstate
int hlp_txtime
int hlp_rxtime
int sockhandle
int sockhandle2
const uint16 priMAC [3]
const uint16 secMAC [3]

Detailed Description

Headerfile for nicdrv.c.


Function Documentation

int ec_closenic ( void  )

Close sockets used

Returns:
0
uint8 ec_getindex ( void  )

Get new frame identifier index and allocate corresponding rx buffer.

Returns:
new index.
int ec_outframe ( uint8  idx,
int  stacknumber 
)

Transmit buffer over socket (non blocking).

Parameters:
[in]idx= index in tx buffer array
[in]stacknumber= 0=Primary 1=Secondary stack
Returns:
socket send result
int ec_outframe_red ( uint8  idx)

Transmit buffer over socket (non blocking).

Parameters:
[in]idx= index in tx buffer array
Returns:
socket send result
void ec_setbufstat ( uint8  idx,
int  bufstat 
)

Set rx buffer status.

Parameters:
[in]idx= index in buffer array
[in]bufstat= status to set
void ec_setupheader ( void *  p)

Fill buffer with ethernet header structure. Destination MAC is allways broadcast. Ethertype is allways ETH_P_ECAT.

Parameters:
[out]p= buffer
int ec_setupnic ( const char *  ifname,
int  secondary 
)

Basic setup to connect NIC to socket.

Parameters:
[in]ifname= Name of NIC device, f.e. "eth0"
[in]secondary= if >0 then use secondary stack instead of primary
Returns:
>0 if succeeded
int ec_srconfirm ( uint8  idx,
int  timeout 
)

Blocking send and recieve frame function. Used for non processdata frames. A datagram is build into a frame and transmitted via this function. It waits for an answer and returns the workcounter. The function retries if time is left and the result is WKC=0 or no frame received.

The function calls ec_outframe_red() and ec_waitinframe_red().

Parameters:
[in]idx= index of frame
[in]timeout= timeout in us
Returns:
Workcounter or EC_NOFRAME
int ec_waitinframe ( uint8  idx,
int  timeout 
)

Blocking receive frame function. Calls ec_waitinframe_red().

Parameters:
[in]idx= requested index of frame
[in]timeout= timeout in us
Returns:
Workcounter if a frame is found with corresponding index, otherwise EC_NOFRAME.

Variable Documentation

int ec_errcnt

global error packet counter, ie non EtherCAT packets

int ec_incnt

global rx packet counter, counts only EtherCAT packets

current redundancy state

ec_bufT ec_rxbuf[EC_MAXBUF]

primary rx buffers

ec_bufT ec_txbuf[EC_MAXBUF]

transmit buffers

temporary tx buffer

int ec_txbuflength[EC_MAXBUF]

transmit buffer lenghts

temporary tx buffer length

global helper var ri count time used in rx socket

global helper var to count time used in tx socket

const uint16 priMAC[3]

Primary source MAC address used for EtherCAT. This address is not the MAC address used from the NIC. EtherCAT does not care about MAC addressing, but it is used here to differentiate the route the packet traverses through the EtherCAT segment. This is needed to find out the packet flow in redundant configurations.

const uint16 secMAC[3]

Secondary source MAC address used for EtherCAT.

primary socket handle

secondary socket handle