Classes | Typedefs | Functions
ethercatcoe.c File Reference

CAN over EtherCAT (CoE) module. More...

#include <stdio.h>
#include <string.h>
#include "osal.h"
#include "oshw.h"
#include "ethercattype.h"
#include "ethercatbase.h"
#include "ethercatmain.h"
#include "ethercatcoe.h"
Include dependency graph for ethercatcoe.c:

Go to the source code of this file.

Classes

struct  PACKED
 
struct  PACKED
 

Typedefs

typedef PACKED_END PACKED_BEGIN struct PACKED ec_SDOservicet
 
typedef PACKED_BEGIN struct PACKED ec_SDOt
 

Functions

int ec_readODdescription (uint16 Item, ec_ODlistt *pODlist)
 
int ec_readODlist (uint16 Slave, ec_ODlistt *pODlist)
 
int ec_readOE (uint16 Item, ec_ODlistt *pODlist, ec_OElistt *pOElist)
 
int ec_readOEsingle (uint16 Item, uint8 SubI, ec_ODlistt *pODlist, ec_OElistt *pOElist)
 
int ec_readPDOassign (uint16 Slave, uint16 PDOassign)
 
int ec_readPDOassignCA (uint16 Slave, uint16 PDOassign, int Thread_n)
 
int ec_readPDOmap (uint16 Slave, int *Osize, int *Isize)
 
int ec_readPDOmapCA (uint16 Slave, int Thread_n, int *Osize, int *Isize)
 
int ec_RxPDO (uint16 Slave, uint16 RxPDOnumber, int psize, void *p)
 
void ec_SDOerror (uint16 Slave, uint16 Index, uint8 SubIdx, int32 AbortCode)
 
int ec_SDOread (uint16 slave, uint16 index, uint8 subindex, boolean CA, int *psize, void *p, int timeout)
 
int ec_SDOwrite (uint16 Slave, uint16 Index, uint8 SubIndex, boolean CA, int psize, void *p, int Timeout)
 
int ec_TxPDO (uint16 slave, uint16 TxPDOnumber, int *psize, void *p, int timeout)
 
int ecx_readODdescription (ecx_contextt *context, uint16 Item, ec_ODlistt *pODlist)
 
int ecx_readODlist (ecx_contextt *context, uint16 Slave, ec_ODlistt *pODlist)
 
int ecx_readOE (ecx_contextt *context, uint16 Item, ec_ODlistt *pODlist, ec_OElistt *pOElist)
 
int ecx_readOEsingle (ecx_contextt *context, uint16 Item, uint8 SubI, ec_ODlistt *pODlist, ec_OElistt *pOElist)
 
int ecx_readPDOassign (ecx_contextt *context, uint16 Slave, uint16 PDOassign)
 
int ecx_readPDOassignCA (ecx_contextt *context, uint16 Slave, int Thread_n, uint16 PDOassign)
 
int ecx_readPDOmap (ecx_contextt *context, uint16 Slave, int *Osize, int *Isize)
 
int ecx_readPDOmapCA (ecx_contextt *context, uint16 Slave, int Thread_n, int *Osize, int *Isize)
 
int ecx_RxPDO (ecx_contextt *context, uint16 Slave, uint16 RxPDOnumber, int psize, void *p)
 
PACKED_END void ecx_SDOerror (ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubIdx, int32 AbortCode)
 
static void ecx_SDOinfoerror (ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubIdx, int32 AbortCode)
 
int ecx_SDOread (ecx_contextt *context, uint16 slave, uint16 index, uint8 subindex, boolean CA, int *psize, void *p, int timeout)
 
int ecx_SDOwrite (ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubIndex, boolean CA, int psize, void *p, int Timeout)
 
int ecx_TxPDO (ecx_contextt *context, uint16 slave, uint16 TxPDOnumber, int *psize, void *p, int timeout)
 

Detailed Description

CAN over EtherCAT (CoE) module.

SDO read / write and SDO service functions

Definition in file ethercatcoe.c.

Typedef Documentation

◆ ec_SDOservicet

SDO service structure

◆ ec_SDOt

typedef PACKED_BEGIN struct PACKED ec_SDOt

SDO structure, not to be confused with EcSDOserviceT

Function Documentation

◆ ec_readODdescription()

int ec_readODdescription ( uint16  Item,
ec_ODlistt pODlist 
)

CoE read Object Description. Adds textual description to object indexes.

Parameters
[in]Item= Item number in ODlist.
[in,out]pODlist= referencing Object Description list.
Returns
Workcounter of slave response.
See also
ecx_readODdescription

Definition at line 1483 of file ethercatcoe.c.

◆ ec_readODlist()

int ec_readODlist ( uint16  Slave,
ec_ODlistt pODlist 
)

CoE read Object Description List.

Parameters
[in]Slave= Slave number.
[out]pODlist= resulting Object Description list.
Returns
Workcounter of slave response.
See also
ecx_readODlist

Definition at line 1471 of file ethercatcoe.c.

◆ ec_readOE()

int ec_readOE ( uint16  Item,
ec_ODlistt pODlist,
ec_OElistt pOElist 
)

CoE read SDO service object entry.

Parameters
[in]Item= Item in ODlist.
[in]pODlist= Object description list for reference.
[out]pOElist= resulting object entry structure.
Returns
Workcounter of slave response.
See also
ecx_readOE

Definition at line 1501 of file ethercatcoe.c.

◆ ec_readOEsingle()

int ec_readOEsingle ( uint16  Item,
uint8  SubI,
ec_ODlistt pODlist,
ec_OElistt pOElist 
)

Definition at line 1488 of file ethercatcoe.c.

◆ ec_readPDOassign()

int ec_readPDOassign ( uint16  Slave,
uint16  PDOassign 
)

Read PDO assign structure

Parameters
[in]Slave= Slave number
[in]PDOassign= PDO assign object
Returns
total bitlength of PDO assign

Definition at line 1411 of file ethercatcoe.c.

◆ ec_readPDOassignCA()

int ec_readPDOassignCA ( uint16  Slave,
uint16  PDOassign,
int  Thread_n 
)

Read PDO assign structure in Complete Access mode

Parameters
[in]Slave= Slave number
[in]PDOassign= PDO assign object
[in]Thread_n= Calling thread index
Returns
total bitlength of PDO assign
See also
ecx_readPDOmap

Definition at line 1423 of file ethercatcoe.c.

◆ ec_readPDOmap()

int ec_readPDOmap ( uint16  Slave,
int *  Osize,
int *  Isize 
)

CoE read PDO mapping.

CANopen has standard indexes defined for PDO mapping. This function tries to read them and collect a full input and output mapping size of designated slave.

For details, see ecx_readPDOmap

Parameters
[in]Slave= Slave number
[out]Osize= Size in bits of output mapping (rxPDO) found
[out]Isize= Size in bits of input mapping (txPDO) found
Returns
>0 if mapping succesful.

Definition at line 1441 of file ethercatcoe.c.

◆ ec_readPDOmapCA()

int ec_readPDOmapCA ( uint16  Slave,
int  Thread_n,
int *  Osize,
int *  Isize 
)

CoE read PDO mapping in Complete Access mode (CA).

CANopen has standard indexes defined for PDO mapping. This function tries to read them and collect a full input and output mapping size of designated slave. Slave has to support CA, otherwise use ec_readPDOmap().

Parameters
[in]Slave= Slave number
[in]Thread_n= Calling thread index
[out]Osize= Size in bits of output mapping (rxPDO) found
[out]Isize= Size in bits of input mapping (txPDO) found
Returns
>0 if mapping succesful.
See also
ecx_readPDOmap ec_readPDOmapCA

Definition at line 1459 of file ethercatcoe.c.

◆ ec_RxPDO()

int ec_RxPDO ( uint16  Slave,
uint16  RxPDOnumber,
int  psize,
void *  p 
)

CoE RxPDO write, blocking.

A RxPDO download request is issued.

Parameters
[in]Slave= Slave number
[in]RxPDOnumber= Related RxPDO number
[in]psize= Size in bytes of PDO buffer.
[out]p= Pointer to PDO buffer
Returns
Workcounter from last slave response
See also
ecx_RxPDO

Definition at line 1384 of file ethercatcoe.c.

◆ ec_SDOerror()

void ec_SDOerror ( uint16  Slave,
uint16  Index,
uint8  SubIdx,
int32  AbortCode 
)

Report SDO error.

Parameters
[in]Slave= Slave number
[in]Index= Index that generated error
[in]SubIdx= Subindex that generated error
[in]AbortCode= Abortcode, see EtherCAT documentation for list
See also
ecx_SDOerror

Definition at line 1322 of file ethercatcoe.c.

◆ ec_SDOread()

int ec_SDOread ( uint16  slave,
uint16  index,
uint8  subindex,
boolean  CA,
int *  psize,
void *  p,
int  timeout 
)

CoE SDO read, blocking. Single subindex or Complete Access.

Only a "normal" upload request is issued. If the requested parameter is <= 4bytes then a "expedited" response is returned, otherwise a "normal" response. If a "normal" response is larger than the mailbox size then the response is segmented. The function will combine all segments and copy them to the parameter buffer.

Parameters
[in]slave= Slave number
[in]index= Index to read
[in]subindex= Subindex to read, must be 0 or 1 if CA is used.
[in]CA= FALSE = single subindex. TRUE = Complete Access, all subindexes read.
[in,out]psize= Size in bytes of parameter buffer, returns bytes read from SDO.
[out]p= Pointer to parameter buffer
[in]timeout= Timeout in us, standard is EC_TIMEOUTRXM
Returns
Workcounter from last slave response
See also
ecx_SDOread

Definition at line 1344 of file ethercatcoe.c.

◆ ec_SDOwrite()

int ec_SDOwrite ( uint16  Slave,
uint16  Index,
uint8  SubIndex,
boolean  CA,
int  psize,
void *  p,
int  Timeout 
)

CoE SDO write, blocking. Single subindex or Complete Access.

A "normal" download request is issued, unless we have small data, then a "expedited" transfer is used. If the parameter is larger than the mailbox size then the download is segmented. The function will split the parameter data in segments and send them to the slave one by one.

Parameters
[in]Slave= Slave number
[in]Index= Index to write
[in]SubIndex= Subindex to write, must be 0 or 1 if CA is used.
[in]CA= FALSE = single subindex. TRUE = Complete Access, all subindexes written.
[in]psize= Size in bytes of parameter buffer.
[out]p= Pointer to parameter buffer
[in]Timeout= Timeout in us, standard is EC_TIMEOUTRXM
Returns
Workcounter from last slave response
See also
ecx_SDOwrite

Definition at line 1367 of file ethercatcoe.c.

◆ ec_TxPDO()

int ec_TxPDO ( uint16  slave,
uint16  TxPDOnumber,
int *  psize,
void *  p,
int  timeout 
)

CoE TxPDO read remote request, blocking.

A RxPDO download request is issued.

Parameters
[in]slave= Slave number
[in]TxPDOnumber= Related TxPDO number
[in,out]psize= Size in bytes of PDO buffer, returns bytes read from PDO.
[out]p= Pointer to PDO buffer
[in]timeout= Timeout in us, standard is EC_TIMEOUTRXM
Returns
Workcounter from last slave response
See also
ecx_TxPDO

Definition at line 1401 of file ethercatcoe.c.

◆ ecx_readODdescription()

int ecx_readODdescription ( ecx_contextt context,
uint16  Item,
ec_ODlistt pODlist 
)

CoE read Object Description. Adds textual description to object indexes.

Parameters
[in]context= context struct
[in]Item= Item number in ODlist.
[in,out]pODlist= referencing Object Description list.
Returns
Workcounter of slave response.

Definition at line 1117 of file ethercatcoe.c.

◆ ecx_readODlist()

int ecx_readODlist ( ecx_contextt context,
uint16  Slave,
ec_ODlistt pODlist 
)

CoE read Object Description List.

Parameters
[in]context= context struct
[in]Slave= Slave number.
[out]pODlist= resulting Object Description list.
Returns
Workcounter of slave response.

Definition at line 998 of file ethercatcoe.c.

◆ ecx_readOE()

int ecx_readOE ( ecx_contextt context,
uint16  Item,
ec_ODlistt pODlist,
ec_OElistt pOElist 
)

CoE read SDO service object entry.

Parameters
[in]context= context struct
[in]Item= Item in ODlist.
[in]pODlist= Object description list for reference.
[out]pOElist= resulting object entry structure.
Returns
Workcounter of slave response.

Definition at line 1294 of file ethercatcoe.c.

◆ ecx_readOEsingle()

int ecx_readOEsingle ( ecx_contextt context,
uint16  Item,
uint8  SubI,
ec_ODlistt pODlist,
ec_OElistt pOElist 
)

CoE read SDO service object entry, single subindex. Used in ec_readOE().

Parameters
[in]context= context struct
[in]Item= Item in ODlist.
[in]SubI= Subindex of item in ODlist.
[in]pODlist= Object description list for reference.
[out]pOElist= resulting object entry structure.
Returns
Workcounter of slave response.

Definition at line 1203 of file ethercatcoe.c.

◆ ecx_readPDOassign()

int ecx_readPDOassign ( ecx_contextt context,
uint16  Slave,
uint16  PDOassign 
)

Read PDO assign structure

Parameters
[in]context= context struct
[in]Slave= Slave number
[in]PDOassign= PDO assign object
Returns
total bitlength of PDO assign

Definition at line 675 of file ethercatcoe.c.

◆ ecx_readPDOassignCA()

int ecx_readPDOassignCA ( ecx_contextt context,
uint16  Slave,
int  Thread_n,
uint16  PDOassign 
)

Read PDO assign structure in Complete Access mode

Parameters
[in]context= context struct
[in]Slave= Slave number
[in]Thread_n= Calling thread index
[in]PDOassign= PDO assign object
Returns
total bitlength of PDO assign

Definition at line 740 of file ethercatcoe.c.

◆ ecx_readPDOmap()

int ecx_readPDOmap ( ecx_contextt context,
uint16  Slave,
int *  Osize,
int *  Isize 
)

CoE read PDO mapping.

CANopen has standard indexes defined for PDO mapping. This function tries to read them and collect a full input and output mapping size of designated slave.

Principal structure in slave:
1C00:00 is number of SM defined
1C00:01 SM0 type -> 1C10
1C00:02 SM1 type -> 1C11
1C00:03 SM2 type -> 1C12
1C00:04 SM3 type -> 1C13
Type 0 = unused, 1 = mailbox in, 2 = mailbox out, 3 = outputs (RxPDO), 4 = inputs (TxPDO).

1C12:00 is number of PDO's defined for SM2
1C12:01 PDO assign SDO #1 -> f.e. 1A00
1C12:02 PDO assign SDO #2 -> f.e. 1A04\

1A00:00 is number of object defined for this PDO
1A00:01 object mapping #1, f.e. 60100710 (SDO 6010 SI 07 bitlength 0x10)

Parameters
[in]context= context struct
[in]Slave= Slave number
[out]Osize= Size in bits of output mapping (rxPDO) found
[out]Isize= Size in bits of input mapping (txPDO) found
Returns
>0 if mapping successful.

Definition at line 810 of file ethercatcoe.c.

◆ ecx_readPDOmapCA()

int ecx_readPDOmapCA ( ecx_contextt context,
uint16  Slave,
int  Thread_n,
int *  Osize,
int *  Isize 
)

CoE read PDO mapping in Complete Access mode (CA).

CANopen has standard indexes defined for PDO mapping. This function tries to read them and collect a full input and output mapping size of designated slave. Slave has to support CA, otherwise use ec_readPDOmap().

Parameters
[in]context= context struct
[in]Slave= Slave number
[in]Thread_n= Calling thread index
[out]Osize= Size in bits of output mapping (rxPDO) found
[out]Isize= Size in bits of input mapping (txPDO) found
Returns
>0 if mapping successful.

Definition at line 910 of file ethercatcoe.c.

◆ ecx_RxPDO()

int ecx_RxPDO ( ecx_contextt context,
uint16  Slave,
uint16  RxPDOnumber,
int  psize,
void *  p 
)

CoE RxPDO write, blocking.

A RxPDO download request is issued.

Parameters
[in]context= context struct
[in]Slave= Slave number
[in]RxPDOnumber= Related RxPDO number
[in]psize= Size in bytes of PDO buffer.
[out]p= Pointer to PDO buffer
Returns
Workcounter from last slave response

Definition at line 552 of file ethercatcoe.c.

◆ ecx_SDOerror()

PACKED_END void ecx_SDOerror ( ecx_contextt context,
uint16  Slave,
uint16  Index,
uint8  SubIdx,
int32  AbortCode 
)

Report SDO error.

Parameters
[in]context= context struct
[in]Slave= Slave number
[in]Index= Index that generated error
[in]SubIdx= Subindex that generated error
[in]AbortCode= Abortcode, see EtherCAT documentation for list

Definition at line 66 of file ethercatcoe.c.

◆ ecx_SDOinfoerror()

static void ecx_SDOinfoerror ( ecx_contextt context,
uint16  Slave,
uint16  Index,
uint8  SubIdx,
int32  AbortCode 
)
static

Report SDO info error

Parameters
[in]context= context struct
[in]Slave= Slave number
[in]Index= Index that generated error
[in]SubIdx= Subindex that generated error
[in]AbortCode= Abortcode, see EtherCAT documentation for list

Definition at line 89 of file ethercatcoe.c.

◆ ecx_SDOread()

int ecx_SDOread ( ecx_contextt context,
uint16  slave,
uint16  index,
uint8  subindex,
boolean  CA,
int *  psize,
void *  p,
int  timeout 
)

CoE SDO read, blocking. Single subindex or Complete Access.

Only a "normal" upload request is issued. If the requested parameter is <= 4bytes then a "expedited" response is returned, otherwise a "normal" response. If a "normal" response is larger than the mailbox size then the response is segmented. The function will combine all segments and copy them to the parameter buffer.

Parameters
[in]context= context struct
[in]slave= Slave number
[in]index= Index to read
[in]subindex= Subindex to read, must be 0 or 1 if CA is used.
[in]CA= FALSE = single subindex. TRUE = Complete Access, all subindexes read.
[in,out]psize= Size in bytes of parameter buffer, returns bytes read from SDO.
[out]p= Pointer to parameter buffer
[in]timeout= Timeout in us, standard is EC_TIMEOUTRXM
Returns
Workcounter from last slave response

Definition at line 120 of file ethercatcoe.c.

◆ ecx_SDOwrite()

int ecx_SDOwrite ( ecx_contextt context,
uint16  Slave,
uint16  Index,
uint8  SubIndex,
boolean  CA,
int  psize,
void *  p,
int  Timeout 
)

CoE SDO write, blocking. Single subindex or Complete Access.

A "normal" download request is issued, unless we have small data, then a "expedited" transfer is used. If the parameter is larger than the mailbox size then the download is segmented. The function will split the parameter data in segments and send them to the slave one by one.

Parameters
[in]context= context struct
[in]Slave= Slave number
[in]Index= Index to write
[in]SubIndex= Subindex to write, must be 0 or 1 if CA is used.
[in]CA= FALSE = single subindex. TRUE = Complete Access, all subindexes written.
[in]psize= Size in bytes of parameter buffer.
[out]p= Pointer to parameter buffer
[in]Timeout= Timeout in us, standard is EC_TIMEOUTRXM
Returns
Workcounter from last slave response

Definition at line 330 of file ethercatcoe.c.

◆ ecx_TxPDO()

int ecx_TxPDO ( ecx_contextt context,
uint16  slave,
uint16  TxPDOnumber,
int *  psize,
void *  p,
int  timeout 
)

CoE TxPDO read remote request, blocking.

A RxPDO download request is issued.

Parameters
[in]context= context struct
[in]slave= Slave number
[in]TxPDOnumber= Related TxPDO number
[in,out]psize= Size in bytes of PDO buffer, returns bytes read from PDO.
[out]p= Pointer to PDO buffer
[in]timeout= Timeout in us, standard is EC_TIMEOUTRXM
Returns
Workcounter from last slave response

Definition at line 599 of file ethercatcoe.c.



soem
Author(s): Arthur Ketels and M.J.G. van den Molengraft
autogenerated on Wed Mar 2 2022 01:01:49