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 87 of file wg_mailbox.h.

Constructor & Destructor Documentation

◆ WGMailbox()

ethercat_hardware::WGMailbox::WGMailbox ( )

Definition at line 259 of file wg_mailbox.cpp.

Member Function Documentation

◆ _readMailboxRepeatRequest()

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

Definition at line 624 of file wg_mailbox.cpp.

◆ clearReadMailbox()

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 309 of file wg_mailbox.cpp.

◆ diagnoseMailboxError()

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 296 of file wg_mailbox.cpp.

◆ initialize()

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

Definition at line 268 of file wg_mailbox.cpp.

◆ lockMailbox()

bool ethercat_hardware::WGMailbox::lockMailbox ( )
protected

Definition at line 938 of file wg_mailbox.cpp.

◆ publishMailboxDiagnostics()

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

Definition at line 1025 of file wg_mailbox.cpp.

◆ readMailbox()

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 844 of file wg_mailbox.cpp.

◆ readMailbox_()

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 863 of file wg_mailbox.cpp.

◆ readMailboxInternal()

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 713 of file wg_mailbox.cpp.

◆ readMailboxRepeatRequest()

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

Definition at line 614 of file wg_mailbox.cpp.

◆ unlockMailbox()

void ethercat_hardware::WGMailbox::unlockMailbox ( )
protected

Definition at line 949 of file wg_mailbox.cpp.

◆ verifyDeviceStateForMailboxOperation()

bool ethercat_hardware::WGMailbox::verifyDeviceStateForMailboxOperation ( )
protected

Definition at line 274 of file wg_mailbox.cpp.

◆ waitForReadMailboxReady()

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 391 of file wg_mailbox.cpp.

◆ waitForWriteMailboxReady()

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 443 of file wg_mailbox.cpp.

◆ writeMailbox()

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 971 of file wg_mailbox.cpp.

◆ writeMailbox_()

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 991 of file wg_mailbox.cpp.

◆ writeMailboxInternal()

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 498 of file wg_mailbox.cpp.

Member Data Documentation

◆ mailbox_diagnostics_

MbxDiagnostics ethercat_hardware::WGMailbox::mailbox_diagnostics_
protected

Definition at line 110 of file wg_mailbox.h.

◆ mailbox_lock_

pthread_mutex_t ethercat_hardware::WGMailbox::mailbox_lock_
protected

Definition at line 109 of file wg_mailbox.h.

◆ mailbox_publish_diagnostics_

MbxDiagnostics ethercat_hardware::WGMailbox::mailbox_publish_diagnostics_
protected

Definition at line 111 of file wg_mailbox.h.

◆ MBX_COMMAND_PHY_ADDR

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

Definition at line 97 of file wg_mailbox.h.

◆ MBX_COMMAND_SIZE

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

Definition at line 98 of file wg_mailbox.h.

◆ MBX_COMMAND_SYNCMAN_NUM

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

Definition at line 102 of file wg_mailbox.h.

◆ MBX_STATUS_PHY_ADDR

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

Definition at line 99 of file wg_mailbox.h.

◆ MBX_STATUS_SIZE

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

Definition at line 100 of file wg_mailbox.h.

◆ MBX_STATUS_SYNCMAN_NUM

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

Definition at line 103 of file wg_mailbox.h.

◆ sh_

EtherCAT_SlaveHandler* ethercat_hardware::WGMailbox::sh_
protected

Definition at line 126 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 Sun Apr 2 2023 02:44:04