Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
ethercat_hardware::WGMailbox Class Reference

#include <wg_mailbox.h>

Public Member Functions

bool initialize (EtherCAT_SlaveHandler *sh)
 
void publishMailboxDiagnostics (diagnostic_updater::DiagnosticStatusWrapper &d)
 
int readMailbox (EthercatCom *com, unsigned address, void *data, unsigned length)
 Read data from WG0X local bus using mailbox communication. More...
 
 WGMailbox ()
 
int writeMailbox (EthercatCom *com, unsigned address, void const *data, unsigned length)
 Write data to WG0X local bus using mailbox communication. More...
 

Static Public Attributes

static const unsigned MBX_COMMAND_PHY_ADDR = 0x1400
 
static const unsigned MBX_COMMAND_SIZE = 512
 
static const unsigned MBX_COMMAND_SYNCMAN_NUM = 2
 
static const unsigned MBX_STATUS_PHY_ADDR = 0x2400
 
static const unsigned MBX_STATUS_SIZE = 512
 
static const unsigned MBX_STATUS_SYNCMAN_NUM = 3
 

Protected Member Functions

bool _readMailboxRepeatRequest (EthercatCom *com)
 
bool clearReadMailbox (EthercatCom *com)
 Clears read mailbox by reading first and last byte. More...
 
void diagnoseMailboxError (EthercatCom *com)
 Runs diagnostic on read and write mailboxes. More...
 
bool lockMailbox ()
 
int readMailbox_ (EthercatCom *com, unsigned address, void *data, unsigned length)
 Internal function. More...
 
bool readMailboxInternal (EthercatCom *com, void *data, unsigned length)
 Reads data from read mailbox. More...
 
bool readMailboxRepeatRequest (EthercatCom *com)
 
void unlockMailbox ()
 
bool verifyDeviceStateForMailboxOperation ()
 
bool waitForReadMailboxReady (EthercatCom *com)
 Waits until read mailbox is full or timeout. More...
 
bool waitForWriteMailboxReady (EthercatCom *com)
 Waits until write mailbox is empty or timeout. More...
 
int writeMailbox_ (EthercatCom *com, unsigned address, void const *data, unsigned length)
 Internal function. More...
 
bool writeMailboxInternal (EthercatCom *com, void const *data, unsigned length)
 Writes data to mailbox. More...
 

Protected Attributes

MbxDiagnostics mailbox_diagnostics_
 
pthread_mutex_t mailbox_lock_
 
MbxDiagnostics mailbox_publish_diagnostics_
 
EtherCAT_SlaveHandler * sh_
 

Detailed Description

Definition at line 55 of file wg_mailbox.h.

Constructor & Destructor Documentation

ethercat_hardware::WGMailbox::WGMailbox ( )

Definition at line 227 of file wg_mailbox.cpp.

Member Function Documentation

bool ethercat_hardware::WGMailbox::_readMailboxRepeatRequest ( EthercatCom com)
protected

Definition at line 592 of file wg_mailbox.cpp.

bool ethercat_hardware::WGMailbox::clearReadMailbox ( EthercatCom com)
protected

Clears read mailbox by reading first and last byte.

Mailbox lock should be held when this function is called.

Parameters
comused to perform communication with device
Returns
returns true for success, false for failure

Definition at line 277 of file wg_mailbox.cpp.

void ethercat_hardware::WGMailbox::diagnoseMailboxError ( EthercatCom com)
protected

Runs diagnostic on read and write mailboxes.

Collects and data from mailbox control registers.

Todo:
not implemented yet
Parameters
comused to perform communication with device
Returns
returns true for success, false for failure

Definition at line 264 of file wg_mailbox.cpp.

bool ethercat_hardware::WGMailbox::initialize ( EtherCAT_SlaveHandler *  sh)

Definition at line 236 of file wg_mailbox.cpp.

bool ethercat_hardware::WGMailbox::lockMailbox ( )
protected

Definition at line 906 of file wg_mailbox.cpp.

void ethercat_hardware::WGMailbox::publishMailboxDiagnostics ( diagnostic_updater::DiagnosticStatusWrapper d)

Definition at line 993 of file wg_mailbox.cpp.

int ethercat_hardware::WGMailbox::readMailbox ( EthercatCom com,
unsigned  address,
void *  data,
unsigned  length 
)

Read data from WG0X local bus using mailbox communication.

Internally a localbus read is done in two parts. First, a mailbox write of a command header that include local bus address and length. Second, a mailbox read of the result.

Parameters
comused to perform communication with device
addressWG0X (FPGA) local bus address to read from
datapointer to buffer where read data can be stored, must be at least length in size
lengthamount of data to read, limited at 511 bytes.
Returns
returns zero for success, non-zero for failure

Definition at line 812 of file wg_mailbox.cpp.

int ethercat_hardware::WGMailbox::readMailbox_ ( EthercatCom com,
unsigned  address,
void *  data,
unsigned  length 
)
protected

Internal function.

Aguments are the same as readMailbox() except that this assumes the mailbox lock is held.

Definition at line 831 of file wg_mailbox.cpp.

bool ethercat_hardware::WGMailbox::readMailboxInternal ( EthercatCom com,
void *  data,
unsigned  length 
)
protected

Reads data from read mailbox.

Will try to conserve bandwidth by reading length bytes of data and last byte of mailbox. Mailbox lock should be held when this function is called.

Parameters
comused to perform communication with device
datapointer to buffer where read data is stored.
lengthamount of data to read from mailbox
Returns
returns true for success, false for failure

Definition at line 681 of file wg_mailbox.cpp.

bool ethercat_hardware::WGMailbox::readMailboxRepeatRequest ( EthercatCom com)
protected

Definition at line 582 of file wg_mailbox.cpp.

void ethercat_hardware::WGMailbox::unlockMailbox ( )
protected

Definition at line 917 of file wg_mailbox.cpp.

bool ethercat_hardware::WGMailbox::verifyDeviceStateForMailboxOperation ( )
protected

Definition at line 242 of file wg_mailbox.cpp.

bool ethercat_hardware::WGMailbox::waitForReadMailboxReady ( EthercatCom com)
protected

Waits until read mailbox is full or timeout.

Wait times out after 100msec. Mailbox lock should be held when this function is called.

Parameters
comused to perform communication with device
Returns
returns true for success, false for failure or timeout

Definition at line 359 of file wg_mailbox.cpp.

bool ethercat_hardware::WGMailbox::waitForWriteMailboxReady ( EthercatCom com)
protected

Waits until write mailbox is empty or timeout.

Wait times out after 100msec. Mailbox lock should be held when this function is called.

Parameters
comused to perform communication with device
Returns
returns true for success, false for failure or timeout

Definition at line 411 of file wg_mailbox.cpp.

int ethercat_hardware::WGMailbox::writeMailbox ( EthercatCom com,
unsigned  address,
void const *  data,
unsigned  length 
)

Write data to WG0X local bus using mailbox communication.

First, this puts a command header that include local bus address and length in write mailbox. Second it waits until device actually empties write mailbox.

Parameters
comused to perform communication with device
addressWG0X (FPGA) local bus address to write data to
datapointer to buffer where write data is stored, must be at least length in size
lengthamount of data to write, limited at 507 bytes
Returns
returns zero for success, non-zero for failure

Definition at line 939 of file wg_mailbox.cpp.

int ethercat_hardware::WGMailbox::writeMailbox_ ( EthercatCom com,
unsigned  address,
void const *  data,
unsigned  length 
)
protected

Internal function.

Aguments are the same as writeMailbox() except that this assumes the mailbox lock is held.

Definition at line 959 of file wg_mailbox.cpp.

bool ethercat_hardware::WGMailbox::writeMailboxInternal ( EthercatCom com,
void const *  data,
unsigned  length 
)
protected

Writes data to mailbox.

Will try to conserve bandwidth by only length bytes of data and last byte of mailbox. Mailbox lock should be held when this function is called.

Parameters
comused to perform communication with device
datapointer to buffer where read data is stored.
lengthamount of data to read from mailbox
Returns
returns true for success, false for failure

Definition at line 466 of file wg_mailbox.cpp.

Member Data Documentation

MbxDiagnostics ethercat_hardware::WGMailbox::mailbox_diagnostics_
protected

Definition at line 78 of file wg_mailbox.h.

pthread_mutex_t ethercat_hardware::WGMailbox::mailbox_lock_
protected

Definition at line 77 of file wg_mailbox.h.

MbxDiagnostics ethercat_hardware::WGMailbox::mailbox_publish_diagnostics_
protected

Definition at line 79 of file wg_mailbox.h.

const unsigned ethercat_hardware::WGMailbox::MBX_COMMAND_PHY_ADDR = 0x1400
static

Definition at line 65 of file wg_mailbox.h.

const unsigned ethercat_hardware::WGMailbox::MBX_COMMAND_SIZE = 512
static

Definition at line 66 of file wg_mailbox.h.

const unsigned ethercat_hardware::WGMailbox::MBX_COMMAND_SYNCMAN_NUM = 2
static

Definition at line 70 of file wg_mailbox.h.

const unsigned ethercat_hardware::WGMailbox::MBX_STATUS_PHY_ADDR = 0x2400
static

Definition at line 67 of file wg_mailbox.h.

const unsigned ethercat_hardware::WGMailbox::MBX_STATUS_SIZE = 512
static

Definition at line 68 of file wg_mailbox.h.

const unsigned ethercat_hardware::WGMailbox::MBX_STATUS_SYNCMAN_NUM = 3
static

Definition at line 71 of file wg_mailbox.h.

EtherCAT_SlaveHandler* ethercat_hardware::WGMailbox::sh_
protected

Definition at line 94 of file wg_mailbox.h.


The documentation for this class was generated from the following files:


ethercat_hardware
Author(s): Rob Wheeler , Derek King
autogenerated on Thu Mar 4 2021 03:10:21