CogniBoost/sw/libCogniBoost/cbLibDev.c
int cbTrans(cbHnd_T     hnd,
            cbMsgId_T   eReqMsgId,
            void       *pReqStruct,
            cbMsgId_T   eRspMsgId,
            void       *pRspStruct)
{
  byte_t    bufPkt[CB_PKT_MAX_SIZE];  // request/response packet buffer
  int       n;                        // number of bytes/return code

  CHK_DEV(hnd);

  // pack request
  n = cbPackMsg(eReqMsgId, pReqStruct, CB_BUF_MSG(bufPkt), hnd->m_bTrace);

  CHK_NM_ECODE(hnd, n, "Failed to pack message %s(%d).",
              CB_MSG_NAME_ID(eReqMsgId));

  n = cbTransLow(hnd, eReqMsgId, bufPkt, (size_t)n,
                      eRspMsgId, CB_BUF_MSG(bufPkt));

  CHK_ECODE(hnd, n, "Transaction failed.");

  // unpack response
  n = cbUnpackMsg(eRspMsgId, CB_BUF_MSG(bufPkt), pRspStruct, hnd->m_bTrace);

  CHK_NM_ECODE(hnd, n, "Failed to unpack message %s(%d).",
              CB_MSG_NAME_ID(eRspMsgId));

  return CB_OK;
}
/*!
 * \brief Execute a request-response transaction with the CogniBoost server.
 *
 * \param hnd             CogniBoost device handle.
 * \param eReqMsgId       Request message id.
 * \param [in]pReqStruct  Pointer to request message-specific structure with
 *                        initialized data. NULL if no message body.
 * \param eRspMsgId       Response message id.
 * \param [out]pRspStruct Pointer to response message-specific structure. The
 *                        structure will be filled in with the field values
 *                        from the response message. NULL if no message body.
 *
 * \copydoc doc_return_std
 */
\brief Execute a request-response transaction with the CogniBoost server.
\param hnd             CogniBoost device handle.
\param eReqMsgId       Request message id.
\param [in]pReqStruct  Pointer to request message-specific structure with
initialized data. NULL if no message body.
\param eRspMsgId       Response message id.
\param [out]pRspStruct Pointer to response message-specific structure. The
structure will be filled in with the field values
from the response message. NULL if no message body.


\ brief Execute a request - response transaction with the CogniBoost server . \ param hnd CogniBoost device handle . \ param eReqMsgId Request message id . \ param [ in ] pReqStruct Pointer to request message - specific structure with initialized data . NULL if no message body . \ param eRspMsgId Response message id . \ param [ out ] pRspStruct Pointer to response message - specific structure . The structure will be filled in with the field values from the response message . NULL if no message body .
int cbTrans(cbHnd_T     hnd,
            cbMsgId_T   eReqMsgId,
            void       *pReqStruct,
            cbMsgId_T   eRspMsgId,
            void       *pRspStruct)
{
  byte_t    bufPkt[CB_PKT_MAX_SIZE];  
  int       n;                        
  CHK_DEV(hnd);
  n = cbPackMsg(eReqMsgId, pReqStruct, CB_BUF_MSG(bufPkt), hnd->m_bTrace);
  CHK_NM_ECODE(hnd, n, "Failed to pack message %s(%d).",
              CB_MSG_NAME_ID(eReqMsgId));
  n = cbTransLow(hnd, eReqMsgId, bufPkt, (size_t)n,
                      eRspMsgId, CB_BUF_MSG(bufPkt));
  CHK_ECODE(hnd, n, "Transaction failed.");
  n = cbUnpackMsg(eRspMsgId, CB_BUF_MSG(bufPkt), pRspStruct, hnd->m_bTrace);
  CHK_NM_ECODE(hnd, n, "Failed to unpack message %s(%d).",
              CB_MSG_NAME_ID(eRspMsgId));
  return CB_OK;
}
int cbTrans ( cbHnd_T hnd , cbMsgId_T eReqMsgId , void * pReqStruct , cbMsgId_T eRspMsgId , void * pRspStruct ) { byte_t bufPkt [ CB_PKT_MAX_SIZE ] ; int n ; CHK_DEV ( hnd ) ; n = cbPackMsg ( eReqMsgId , pReqStruct , CB_BUF_MSG ( bufPkt ) , hnd -> m_bTrace ) ; CHK_NM_ECODE ( hnd , n , " " , CB_MSG_NAME_ID ( eReqMsgId ) ) ; n = cbTransLow ( hnd , eReqMsgId , bufPkt , ( size_t ) n , eRspMsgId , CB_BUF_MSG ( bufPkt ) ) ; CHK_ECODE ( hnd , n , " " ) ; n = cbUnpackMsg ( eRspMsgId , CB_BUF_MSG ( bufPkt ) , pRspStruct , hnd -> m_bTrace ) ; CHK_NM_ECODE ( hnd , n , " " , CB_MSG_NAME_ID ( eRspMsgId ) ) ; return CB_OK ; }
\brief Execute a request-response transaction with the CogniBoost server.
\ brief Execute a request - response transaction with the CogniBoost server .
// request/response packet buffer // number of bytes/return code // pack request // unpack response