#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. | |
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_ |
Definition at line 55 of file wg_mailbox.h.
Definition at line 227 of file wg_mailbox.cpp.
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.
com | used to perform communication with device |
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.
com | used to perform communication with device |
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.
com | used to perform communication with device |
address | WG0X (FPGA) local bus address to read from |
data | pointer to buffer where read data can be stored, must be at least length in size |
length | amount of data to read, limited at 511 bytes. |
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.
com | used to perform communication with device |
data | pointer to buffer where read data is stored. |
length | amount of data to read from mailbox |
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.
com | used to perform communication with device |
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.
com | used to perform communication with device |
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.
com | used to perform communication with device |
address | WG0X (FPGA) local bus address to write data to |
data | pointer to buffer where write data is stored, must be at least length in size |
length | amount of data to write, limited at 507 bytes |
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.
com | used to perform communication with device |
data | pointer to buffer where read data is stored. |
length | amount of data to read from mailbox |
Definition at line 466 of file wg_mailbox.cpp.
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.
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.