Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes
ethercat_hardware::WGMailbox Class Reference

#include <wg_mailbox.h>

List of all members.

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.
 WGMailbox ()
int writeMailbox (EthercatCom *com, unsigned address, void const *data, unsigned length)
 Write data to WG0X local bus using mailbox communication.

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.
void diagnoseMailboxError (EthercatCom *com)
 Runs diagnostic on read and write mailboxes.
bool lockMailbox ()
int readMailbox_ (EthercatCom *com, unsigned address, void *data, unsigned length)
 Internal function.
bool readMailboxInternal (EthercatCom *com, void *data, unsigned length)
 Reads data from read mailbox.
bool readMailboxRepeatRequest (EthercatCom *com)
void unlockMailbox ()
bool verifyDeviceStateForMailboxOperation ()
bool waitForReadMailboxReady (EthercatCom *com)
 Waits until read mailbox is full or timeout.
bool waitForWriteMailboxReady (EthercatCom *com)
 Waits until write mailbox is empty or timeout.
int writeMailbox_ (EthercatCom *com, unsigned address, void const *data, unsigned length)
 Internal function.
bool writeMailboxInternal (EthercatCom *com, void const *data, unsigned length)
 Writes data to mailbox.

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

Definition at line 227 of file wg_mailbox.cpp.


Member Function Documentation

Definition at line 592 of file wg_mailbox.cpp.

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.

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.

Definition at line 906 of file wg_mailbox.cpp.

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.

Definition at line 582 of file wg_mailbox.cpp.

Definition at line 917 of file wg_mailbox.cpp.

Definition at line 242 of file wg_mailbox.cpp.

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.

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

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.

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.

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.

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 Jun 6 2019 19:46:33