CogniBoost/sw/libCogniBoost/cbLibDev.c
static int cbDeviceWrite(cbHnd_T hnd, byte_t buf[], size_t count, uint_t usec)
{
  ssize_t         n;

  LOGDIAG5CALL(_TINT(hnd->m_fd), _TPTR(buf), _TUINT(count), _TUINT(usec));

  n = SerDevWrite(hnd->m_fd, buf, count, usec);

  if( n < 0 )
  {
    CB_LOG_SYSERROR(hnd, CB_LIB_ECODE_WRITE, "SerDevWrite().");
    return -CB_LIB_ECODE_READ;
  }

  else if( (size_t)n != count )
  {
    CB_LOG_ERROR(hnd, CB_LIB_ECODE_TIMEDOUT, "SerDevWrite().");
  }

  LOGDIAG4("%s(): Device %d: %zd bytes written.", LOGFUNCNAME, hnd->m_fd, n);

  return (int)n;
}
/*!
 * \brief Write bytes to CogniBoost device.
 *
 *  Write up to <em>count</em> bytes from <em>buf</em> to the connection.
 *  This call is non-blocking if the timeout value <em>usec</em> is greater than
 *  zero. Otherwise the read can block indefinitely.
 *
 *  Note that the number of bytes written can be less than the <em>count</em>.
 *
 * \param hnd       CogniBoost device handle.
 * \param buf       Destination buffer.
 * \param count     Number of bytes to read.
 * \param usec      Timeout in microseconds.\n
 *                  If <em>usec</em> \h_gt 0, an upper timeout limit is placed
 *                  on the read.
 *                  If <em>usec</em> == 0, then the read will block indefinitely
 *                  until <em>count</em> bytes are read or an I/O error has
 *                  ocurred.
 *
 * \return
 * On success, returns \h_ge 0 number of bytes written.\n
 * On error, returns \h_lt 0 error code.
 */
\brief Write bytes to CogniBoost device.
Write up to count bytes from buf to the connection.
This call is non-blocking if the timeout value usec is greater than
zero. Otherwise the read can block indefinitely.

Note that the number of bytes written can be less than the count.

\param hnd       CogniBoost device handle.
\param buf       Destination buffer.
\param count     Number of bytes to read.
\param usec      Timeout in microseconds.\n
If usec \h_gt 0, an upper timeout limit is placed
on the read.
If usec == 0, then the read will block indefinitely
until count bytes are read or an I/O error has
ocurred.

\return
On success, returns \h_ge 0 number of bytes written.\n
On error, returns \h_lt 0 error code.
\ brief Write bytes to CogniBoost device . Write up to count bytes from buf to the connection . This call is non - blocking if the timeout value usec is greater than zero . Otherwise the read can block indefinitely . Note that the number of bytes written can be less than the count . \ param hnd CogniBoost device handle . \ param buf Destination buffer . \ param count Number of bytes to read . \ param usec Timeout in microseconds . \ n If usec \ h_gt 0 an upper timeout limit is placed on the read . If usec == 0 then the read will block indefinitely until count bytes are read or an I / O error has ocurred . \ return On success returns \ h_ge 0 number of bytes written . \ n On error returns \ h_lt 0 error code .
static int cbDeviceWrite(cbHnd_T hnd, byte_t buf[], size_t count, uint_t usec)
{
  ssize_t         n;
  LOGDIAG5CALL(_TINT(hnd->m_fd), _TPTR(buf), _TUINT(count), _TUINT(usec));
  n = SerDevWrite(hnd->m_fd, buf, count, usec);
  if( n < 0 )
  {
    CB_LOG_SYSERROR(hnd, CB_LIB_ECODE_WRITE, "SerDevWrite().");
    return -CB_LIB_ECODE_READ;
  }
  else if( (size_t)n != count )
  {
    CB_LOG_ERROR(hnd, CB_LIB_ECODE_TIMEDOUT, "SerDevWrite().");
  }
  LOGDIAG4("%s(): Device %d: %zd bytes written.", LOGFUNCNAME, hnd->m_fd, n);
  return (int)n;
}
static int cbDeviceWrite ( cbHnd_T hnd , byte_t buf [ ] , size_t count , uint_t usec ) { ssize_t n ; LOGDIAG5CALL ( _TINT ( hnd -> m_fd ) , _TPTR ( buf ) , _TUINT ( count ) , _TUINT ( usec ) ) ; n = SerDevWrite ( hnd -> m_fd , buf , count , usec ) ; if ( n < 0 ) { CB_LOG_SYSERROR ( hnd , CB_LIB_ECODE_WRITE , " " ) ; return - CB_LIB_ECODE_READ ; } else if ( ( size_t ) n != count ) { CB_LOG_ERROR ( hnd , CB_LIB_ECODE_TIMEDOUT , " " ) ; } LOGDIAG4 ( " " , LOGFUNCNAME , hnd -> m_fd , n ) ; return ( int ) n ; }
\brief Write bytes to CogniBoost device.
\ brief Write bytes to CogniBoost device .