Jump to main content

##

# 3.4.4.7 USB_HOST_CDC_Write Function

## C

    USB_HOST_CDC_RESULT USB_HOST_CDC_Write(
        USB_HOST_CDC_HANDLE handle,
        USB_HOST_CDC_TRANSFER_HANDLE * transferHandle,
        void * data,
        size_t size
    );

## Summary

This function will write data to the attached CDC device. The function will write size amount of bytes. If the request was accepted, transferHandle will contain a valid transfer handle, else it will contain USB_HOST_CDC_TRANSFER_HANDLE_INVALID. The completion of the request will be indicated by the USB_HOST_CDC_EVENT_WRITE_COMPLETE event. The transfer handle will be returned in the event.

## Precondition

The client handle should be valid.

## Parameters

Parameters | Description
handle | handle to the CDC device instance to which the request should be sent.
transferHandle | Pointer to USB_HOST_CDC_TRANSFER_HANDLE type of a variable. This will contain a valid transfer handle if the request was successful.
data | pointer to the buffer containing the data to be written. The contents of the buffer should not be changed till the USB_HOST_CDC_EVENT_WRITE_COMPLETE event has occurred.
size | Number of bytes to write.

## Returns

USB_HOST_CDC_RESULT_SUCCESS - The operation was successful.

USB_HOST_CDC_RESULT_DEVICE_UNKNOWN - The device that this request was targeted to does not exist in the system.

USB_HOST_CDC_RESULT_BUSY - The request could not be scheduled at this time. The client should try again.

USB_HOST_CDC_RESULT_INVALID_PARAMETER - An input parameter was NULL.

USB_HOST_CDC_RESULT_FAILURE - An unknown failure occurred.

USB_HOST_CDC_RESULT_HANDLE_INVALID - The client handle is not valid.

## Remarks

None.