/* Function: rtIOStreamSend =====================================================
 * Abstract:
 *  Sends the specified number of bytes on the comm line. Returns the number of
 *  bytes sent (if successful) or a negative value if an error occurred. As long
 *  as an error does not occur, this function is guaranteed to set the requested
 *  number of bytes; the function blocks if the TCP/IP send buffer doesn't have
 *  room for all of the data to be sent
 */
int rtIOStreamSend(
    int streamID,
    const void * const src,
    size_t size,
    size_t *sizeSent)
{
    int retVal;
    SerialCommsData *sd = getSerialData(streamID);
    if (sd == NULL) {
        retVal = RTIOSTREAM_ERROR;
        return retVal;
    }
    retVal = serialDataSet( sd, src, size, sizeSent);
    if (sd->verbosity) {
        printf("rtIOStreamSend (connection id %d): size = %lu, sizeSent = %lu",
               streamID,
               (unsigned long) size,
               (unsigned long) *sizeSent);
        if (sd->verbosity >= VERBOSITY_LEVEL_2) {
            size_t currElement;
            printf(": ");
            for (currElement = 0; currElement < *sizeSent; currElement++) {
                printf("%u ", ((const unsigned char *) src)[currElement]);
            }
        }
        printf("\n");
    }
    return retVal;
}
/* Function: rtIOStreamSend =====================================================
 * Abstract:
 *  Sends the specified number of bytes on the comm line. Returns the number of
 *  bytes sent (if successful) or a negative value if an error occurred. As long
 *  as an error does not occur, this function is guaranteed to set the requested
 *  number of bytes; the function blocks if the TCP/IP send buffer doesn't have
 *  room for all of the data to be sent
 */
int rtIOStreamSend(
    int streamID,
    const void *src,
    size_t size,
    size_t *sizeSent)
{
    int retVal;
    SerialCommsData *sd;

    sd = &SerialData[streamID];

    retVal = serialDataSet( sd, src, size, sizeSent);

    return retVal;
}