ethercatcoe.c File Reference

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

#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
#include "ethercattype.h"
#include "nicdrv.h"
#include "ethercatbase.h"
#include "ethercatmain.h"
#include "ethercatcoe.h"

Data Structures

struct  ec_SDOt
struct  ec_SDOservicet
struct  ec_PDOassignt
struct  ec_PDOdesct

Functions

void ec_SDOerror (uint16 Slave, uint16 Index, uint8 SubIdx, int32 AbortCode)
static void ec_SDOinfoerror (uint16 Slave, uint16 Index, uint8 SubIdx, int32 AbortCode)
static void ec_packeterror (uint16 Slave, uint16 Index, uint8 SubIdx, uint16 ErrorCode)
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_RxPDO (uint16 Slave, uint16 RxPDOnumber, int psize, void *p)
int ec_TxPDO (uint16 slave, uint16 TxPDOnumber, int *psize, void *p, int timeout)
int ec_readPDOmap (uint16 Slave, int *Osize, int *Isize)
int ec_readPDOmapCA (uint16 Slave, int *Osize, int *Isize)
int ec_readODlist (uint16 Slave, ec_ODlistt *pODlist)
int ec_readODdescription (uint16 Item, ec_ODlistt *pODlist)
static int ec_readOEsingle (uint16 Item, uint8 SubI, ec_ODlistt *pODlist, ec_OElistt *pOElist)
int ec_readOE (uint16 Item, ec_ODlistt *pODlist, ec_OElistt *pOElist)

Variables

static ec_PDOassignt ec_PDOassign
static ec_PDOdesct ec_PDOdesc

Detailed Description

CAN over EtherCAT (CoE) module.

SDO read / write and SDO service functions


Function Documentation

static void ec_packeterror ( uint16  Slave,
uint16  Index,
uint8  SubIdx,
uint16  ErrorCode 
) [static]

Report packet error

Parameters:
[in] Slave = Slave number
[in] Index = Index that generated error
[in] SubIdx = Subindex that generated error
[in] ErrorCode = Error code
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.
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.
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.
static int ec_readOEsingle ( uint16  Item,
uint8  SubI,
ec_ODlistt pODlist,
ec_OElistt pOElist 
) [static]

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

Parameters:
[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.
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.

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.
int ec_readPDOmapCA ( uint16  Slave,
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
[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.
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
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
static void ec_SDOinfoerror ( uint16  Slave,
uint16  Index,
uint8  SubIdx,
int32  AbortCode 
) [static]

Report SDO info 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
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
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.

Only a "normal" download request is issued. If the paramater 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
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

Variable Documentation

PDO assign struct to store data of one slave

PDO description struct to store data of one slave


Generated on Mon Feb 22 22:00:22 2010 for SOEM by  doxygen 1.6.1