AB&T / SOEM

Dependents:   EasyCAT_LAB_simple EasyCAT_LAB_very_simple EasyCAT_LAB

Embed: (wiki syntax)

« Back to documentation index

nicdrv.h File Reference

nicdrv.h File Reference

Headerfile for nicdrv.c. More...

Go to the source code of this file.

Data Structures

struct  ec_stackT
 pointer structure to Tx and Rx stacks More...
struct  ecx_redportt
 pointer structure to buffers for redundant port More...
struct  ecx_portt
 pointer structure to buffers, vars and mutexes for port instantiation More...

Functions

void ec_setupheader (void *p)
 Fill buffer with ethernet header structure.
int ecx_setupnic (ecx_portt *port, const char *ifname, int secondary)
 Basic setup to connect NIC to socket.
int ecx_closenic (ecx_portt *port)
 Close sockets used.
void ecx_setbufstat (ecx_portt *port, int idx, int bufstat)
 Set rx buffer status.
int ecx_getindex (ecx_portt *port)
 Get new frame identifier index and allocate corresponding rx buffer.
int ecx_outframe (ecx_portt *port, int idx, int stacknumber)
 Transmit buffer over socket (non blocking).
int ecx_outframe_red (ecx_portt *port, int idx)
 Transmit buffer over socket (non blocking).
int ecx_waitinframe (ecx_portt *port, int idx, int timeout)
 Blocking receive frame function.
int ecx_srconfirm (ecx_portt *port, int idx, int timeout)
 Blocking send and receive frame function.

Variables

const uint16 priMAC [3]
 Primary source MAC address used for EtherCAT.
const uint16 secMAC [3]
 Secondary source MAC address used for EtherCAT.

Detailed Description

Headerfile for nicdrv.c.

Definition in file nicdrv.h.


Function Documentation

void ec_setupheader ( void *  p )

Fill buffer with ethernet header structure.

Destination MAC is always broadcast. Ethertype is always ETH_P_ECAT.

Parameters:
[out]p= buffer

Definition at line 315 of file nicdrv.cpp.

int ecx_closenic ( ecx_portt port )

Close sockets used.

Parameters:
[in]port= port context struct
Returns:
0

Definition at line 296 of file nicdrv.cpp.

int ecx_getindex ( ecx_portt port )

Get new frame identifier index and allocate corresponding rx buffer.

Parameters:
[in]port= port context struct
Returns:
new index.

Definition at line 335 of file nicdrv.cpp.

int ecx_outframe ( ecx_portt port,
int  idx,
int  stacknumber 
)

Transmit buffer over socket (non blocking).

Parameters:
[in]port= port context struct
[in]idx= index in tx buffer array
[in]stacknumber= 0=Primary 1=Secondary stack
Returns:
socket send result

Definition at line 391 of file nicdrv.cpp.

int ecx_outframe_red ( ecx_portt port,
int  idx 
)

Transmit buffer over socket (non blocking).

Parameters:
[in]port= port context struct
[in]idx= index in tx buffer array
Returns:
socket send result

Definition at line 417 of file nicdrv.cpp.

void ecx_setbufstat ( ecx_portt port,
int  idx,
int  bufstat 
)

Set rx buffer status.

Parameters:
[in]port= port context struct
[in]idx= index in buffer array
[in]bufstat= status to set

Definition at line 376 of file nicdrv.cpp.

int ecx_setupnic ( ecx_portt port,
const char *  ifname,
int  secondary 
)

Basic setup to connect NIC to socket.

Parameters:
[in]port= port context struct
[in]ifname= Name of NIC device, f.e. "eth0"
[in]secondary= if >0 then use secondary stack instead of primary
Returns:
>0 if succeeded

Definition at line 230 of file nicdrv.cpp.

int ecx_srconfirm ( ecx_portt port,
int  idx,
int  timeout 
)

Blocking send and receive 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]port= port context struct
[in]idx= index of frame
[in]timeout= timeout in us
Returns:
Workcounter or EC_NOFRAME

Definition at line 712 of file nicdrv.cpp.

int ecx_waitinframe ( ecx_portt port,
int  idx,
int  timeout 
)

Blocking receive frame function.

Calls ec_waitinframe_red().

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

Definition at line 689 of file nicdrv.cpp.


Variable Documentation

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.

Definition at line 64 of file nicdrv.cpp.

const uint16 secMAC[3]

Secondary source MAC address used for EtherCAT.

Definition at line 66 of file nicdrv.cpp.