# Vendor specific protocol over EtherCAT® (VoE) VoE is for vendor specific protocols. With VoE the vendor has access to a raw EtherCAT® mailbox without a specific header or specific protocol mechanism. ## emVoeWrite ### static [EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) ecatVoeWrite([EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) dwSlaveId, [EC_T_BYTE](toc_api.html.md#_CPPv49EC_T_BYTE) \*pbyData, [EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) dwDataLen, [EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) dwTimeout) ### [EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) emVoeWrite([EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) dwSlaveId, [EC_T_BYTE](toc_api.html.md#_CPPv49EC_T_BYTE) \*pbyData, [EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) dwDataLen, [EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) dwTimeout) Execute a VoE mailbox write to an EtherCAT slave device. This function blocks until the VoE write has been successfully completed or an error has occurred. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **dwSlaveId** – [in] Slave ID * **pbyData** – [in] Buffer containing transferred data * **dwDataLen** – [in] Buffer length [bytes]. The maximum data length including 6 bytes for the mailbox header is given at [EC_T_CFG_SLAVE_INFO.dwMbxOutSize](api_slave_control.html.md#d5/dca/struct_e_c___t___c_f_g___s_l_a_v_e___i_n_f_o_1a56d9ff78d80ee8ca133c9b83e9471a8c). * **dwTimeout** – [in] Timeout [ms]. The function will block at most for this time. * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ### **emVoeWrite() Example** ```cpp dwRes = emVoeWrite(dwInstanceId, dwSlaveId, abyVoeDataOutBuf, sizeof(abyVoeDataOutBuf), 5000); if(dwRes != EC_E_NOERROR) { EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "emVoeWrite(...): %s (0x%lx))\n", ecatGetText(dwRes), dwRes)); } ``` #### SEE ALSO - [`emGetCfgSlaveInfo()`](api_slave_control.html.md#_CPPv417emGetCfgSlaveInfo10EC_T_DWORD9EC_T_BOOL9EC_T_WORDP19EC_T_CFG_SLAVE_INFO) - [`emGetSlaveId()`](api_slave_control.html.md#_CPPv412emGetSlaveId10EC_T_DWORD9EC_T_WORD) ## emVoeWriteReq ### static [EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) ecatVoeWriteReq([EC_T_MBXTFER](mbx_tfer.html.md#_CPPv412EC_T_MBXTFER) \*pMbxTfer, [EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) dwSlaveId, [EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) dwTimeout) ### [EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) emVoeWriteReq([EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_MBXTFER](mbx_tfer.html.md#_CPPv412EC_T_MBXTFER) \*pMbxTfer, [EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) dwSlaveId, [EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) dwTimeout) Initiates a VoE mailbox write to an EtherCAT slave device. The amount of data bytes to write has to be stored in [EC_T_MBXTFER.dwDataLen](mbx_tfer.html.md#dd/db6/struct_e_c___t___m_b_x_t_f_e_r_1acdf20a0520615fca75c9f3a1a6ac18ea). The maximum data length including 6 bytes for the mailbox header is given at [EC_T_CFG_SLAVE_INFO.dwMbxOutSize](api_slave_control.html.md#d5/dca/struct_e_c___t___c_f_g___s_l_a_v_e___i_n_f_o_1a56d9ff78d80ee8ca133c9b83e9471a8c). A unique transfer ID must be written into [EC_T_MBXTFER.dwTferId](mbx_tfer.html.md#dd/db6/struct_e_c___t___m_b_x_t_f_e_r_1a36cd53365b5741523a1f5b8777866024). * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **pMbxTfer** – [in] Mailbox transfer object * **dwSlaveId** – [in] Slave ID * **dwTimeout** – [in] Timeout [ms], EC_NOWAIT returns the function immediately * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ### **emVoeWriteReq() Example** ```cpp dwRes = emVoeWriteReq(dwInstanceId, pMbxTfer, dwSlaveId, 5000); if (dwRes != EC_E_NOERROR) { dwRetVal = dwRes; EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "emVoeWriteReq: %s (0x%lx))\n", ecatGetText(dwRes), dwRes)); goto Exit; } ``` #### SEE ALSO [`emGetSlaveId()`](api_slave_control.html.md#_CPPv412emGetSlaveId10EC_T_DWORD9EC_T_WORD) ## emVoeRead ### static [EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) ecatVoeRead([EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) dwSlaveId, [EC_T_BYTE](toc_api.html.md#_CPPv49EC_T_BYTE) \*pbyData, [EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) dwDataLen, [EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) \*pdwOutDataLen, [EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) dwTimeout) ### [EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) emVoeRead([EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) dwSlaveId, [EC_T_BYTE](toc_api.html.md#_CPPv49EC_T_BYTE) \*pbyData, [EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) dwDataLen, [EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) \*pdwOutDataLen, [EC_T_DWORD](toc_api.html.md#_CPPv410EC_T_DWORD) dwTimeout) Retrieves VoE mailbox, that was sent by an EtherCAT slave device. If a VoE mailbox was already received, further received VoE mailboxes will be discarded as long as this function was not called. The received data includes the Mailbox header of type [ETHERCAT_MBOX_HEADER](#d1/d57/struct_e_t_h_e_r_c_a_t___m_b_o_x___h_e_a_d_e_r) followed by the VoE payload. This function blocks until the VoE data has been successfully received or an error has occurred. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **dwSlaveId** – [in] Slave ID * **pbyData** – [out] Buffer receiving transferred data * **dwDataLen** – [in] Buffer length [byte] * **pdwOutDataLen** – [out] Length of received data [byte] * **dwTimeout** – [in] Timeout [ms]. The function will block at most for this time. EC_NOWAIT returns the function immediately. * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if the VoE slave has provided some VoE data * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if EtherCAT stack isn’t initialized * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range * [EC_E_TIMEOUT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2d09527654c655e159d26d36143674cb) if dwTimeout elapsed during the API call * [EC_E_VOE_NO_MBX_RECEIVED](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga01a2428aa0fe1530fe5cf7ab13bc547c) if no VoE data was received * [EC_E_MASTER_RED_STATE_INACTIVE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gae2870f20d370920995e27b2a78171a5e) if Master Redundancy is configured and master is inactive ### struct ETHERCAT_MBOX_HEADER ### Public Members ### [EC_T_WORD](toc_api.html.md#_CPPv49EC_T_WORD) wLength Following bytes (payload length) ### [EC_T_WORD](toc_api.html.md#_CPPv49EC_T_WORD) wAddress Station address of destination (READ) or source (WRITE). 0 == Master (ETHERCAT_MBOX_MASTER_ADDRESS) ### [EC_T_BYTE](toc_api.html.md#_CPPv49EC_T_BYTE) byChnPri Channel, Priority ### [EC_T_BYTE](toc_api.html.md#_CPPv49EC_T_BYTE) byTypCntRsvd wMbxType, Counter, Rsvd ### **emVoeRead() Example** ```cpp dwRes = emVoeRead(dwInstanceId, dwSlaveId, abyVoeDataInBuf, sizeof(abyVoeDataInBuf), &dwDataOutLen, 5000); if(dwRes != EC_E_NOERROR) { EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "emVoeRead(...): %s (0x%lx))\n", ecatGetText(dwRes), dwRes)); } ``` #### SEE ALSO [`emGetSlaveId()`](api_slave_control.html.md#_CPPv412emGetSlaveId10EC_T_DWORD9EC_T_WORD) ## emNotify - eMbxTferType_VOE_READ The corresponding SubDevice ID can be found in pMbxTfer->dwTferId. The MBX data stored in pMbxTfer->pbyMbxTferData may have to be buffered by the client. After emNotify returns the pointer and thus the data is invalid. Access to the memory area pointed to by pMbxTfer-> pbyMbxTferData after returning from emNotify is illegal and the results are undefined. **emNotify - eMbxTferType_VOE_READ** : **Parameter** : * `pbyInBuf`: [in] pMbxTfer - Pointer to a structure of type EC_T_MBXTFER, containing the used mailbox transfer object. To retrieve this VoE mailbox data emVoeRead has to be called. * `dwInBufSize`: [in] Size of the transfer object * `pbyOutBuf`: [out] Should be set to EC_NULL * `dwOutBufSize`: [in] Should be set to 0 * `pdwNumOutData`: [out] Should be set to EC_NULL ## emNotify - eMbxTferType_VOE_WRITE VoE mailbox was successfully written to the VoE SubDevice. The corresponding transfer ID can be found in pMbxTfer->dwTferId. The transfer result is stored in pMbxTfer->dwErrorCode. **emNotify - eMbxTferType_VOE_WRITE** : **Parameter** : * `pbyInBuf`: [in] pMbxTfer - Pointer to a structure of type EC_T_MBXTFER, containing the corresponding mailbox transfer object * `dwInBufSize`: [in] Size of the transfer object * `pbyOutBuf`: [out] Should be set to EC_NULL * `dwOutBufSize`: [in] Should be set to 0 * `pdwNumOutData`: [out] Should be set to EC_NULL