pub struct UsbSynchronousProxy { /* private fields */ }Implementations§
Source§impl UsbSynchronousProxy
impl UsbSynchronousProxy
pub fn new(channel: Channel) -> Self
pub fn into_channel(self) -> Channel
Sourcepub fn wait_for_event(
&self,
deadline: MonotonicInstant,
) -> Result<UsbEvent, Error>
pub fn wait_for_event( &self, deadline: MonotonicInstant, ) -> Result<UsbEvent, Error>
Waits until an event arrives and returns it. It is safe for other threads to make concurrent requests while waiting for an event.
Sourcepub fn connect_to_endpoint(
&self,
ep_addr: u8,
ep: ServerEnd<EndpointMarker>,
___deadline: MonotonicInstant,
) -> Result<UsbConnectToEndpointResult, Error>
pub fn connect_to_endpoint( &self, ep_addr: u8, ep: ServerEnd<EndpointMarker>, ___deadline: MonotonicInstant, ) -> Result<UsbConnectToEndpointResult, Error>
Connects a channel to the specified USB endpoint (ep_addr).
Endpoint 0 (the default control pipe) cannot be connected via this method; use
[ControlTransfer] instead.
Closing the [Usb] channel does not automatically close open [Endpoint] channels, which
remain bound to the underlying host controller until explicitly closed by the client or
disconnected when the physical USB device is unplugged.
- error:
ZX_ERR_INVALID_ARGSifep_addrrefers to endpoint 0 or an endpoint number > 15.ZX_ERR_NOT_FOUNDif the device or endpoint address does not exist.ZX_ERR_ALREADY_BOUNDif the endpoint is already bound to an active channel.ZX_ERR_IO_NOT_PRESENTif the device has been disconnected.
Sourcepub fn get_device_speed(
&self,
___deadline: MonotonicInstant,
) -> Result<UsbSpeed, Error>
pub fn get_device_speed( &self, ___deadline: MonotonicInstant, ) -> Result<UsbSpeed, Error>
Returns the negotiated bus speed of the USB device.
Sourcepub fn get_device_id(&self, ___deadline: MonotonicInstant) -> Result<u32, Error>
pub fn get_device_id(&self, ___deadline: MonotonicInstant) -> Result<u32, Error>
Returns the internal device ID assigned by the USB host controller / bus driver.
Sourcepub fn get_device_descriptor(
&self,
___deadline: MonotonicInstant,
) -> Result<UsbDeviceDescriptor, Error>
pub fn get_device_descriptor( &self, ___deadline: MonotonicInstant, ) -> Result<UsbDeviceDescriptor, Error>
Returns the USB device descriptor.
Sourcepub fn get_configuration_descriptor(
&self,
config: u8,
___deadline: MonotonicInstant,
) -> Result<UsbGetConfigurationDescriptorResult, Error>
pub fn get_configuration_descriptor( &self, config: u8, ___deadline: MonotonicInstant, ) -> Result<UsbGetConfigurationDescriptorResult, Error>
Returns the full raw configuration descriptor hierarchy (in standard USB wire format) for
the configuration with bConfigurationValue == config.
- error:
ZX_ERR_INVALID_ARGSifconfigdoes not match any configuration descriptor on the device.
Sourcepub fn get_configuration(
&self,
___deadline: MonotonicInstant,
) -> Result<u8, Error>
pub fn get_configuration( &self, ___deadline: MonotonicInstant, ) -> Result<u8, Error>
Returns the bConfigurationValue of the currently active USB configuration.
Sourcepub fn set_configuration(
&self,
configuration: u8,
___deadline: MonotonicInstant,
) -> Result<UsbSetConfigurationResult, Error>
pub fn set_configuration( &self, configuration: u8, ___deadline: MonotonicInstant, ) -> Result<UsbSetConfigurationResult, Error>
Selects the active USB configuration (SET_CONFIGURATION) and updates the host controller
state.
Replies after the SET_CONFIGURATION control transfer and controller state update complete.
- error:
ZX_ERR_INVALID_ARGSifconfigurationdoes not match any configuration on the device.ZX_ERR_TIMED_OUTif the control transfer times out.ZX_ERR_IO_REFUSEDif the device stalls the request.ZX_ERR_IO_NOT_PRESENTif the device has been disconnected.ZX_ERR_NOT_SUPPORTEDif invoked on an interface-scoped connection that prohibits device-wide configuration changes.
Sourcepub fn set_interface(
&self,
interface_number: u8,
alt_setting: u8,
___deadline: MonotonicInstant,
) -> Result<UsbSetInterfaceResult, Error>
pub fn set_interface( &self, interface_number: u8, alt_setting: u8, ___deadline: MonotonicInstant, ) -> Result<UsbSetInterfaceResult, Error>
Selects an alternate setting for the specified USB interface (SET_INTERFACE) and updates
the host controller state.
Replies after the SET_INTERFACE control transfer and controller state update complete.
- error:
ZX_ERR_INVALID_ARGSifinterface_numberoralt_settingis invalid.ZX_ERR_TIMED_OUTif the control transfer times out.ZX_ERR_IO_REFUSEDif the device stalls the request.ZX_ERR_IO_NOT_PRESENTif the device has been disconnected.
Sourcepub fn control_transfer(
&self,
setup: &UsbSetup,
timeout_ns: i64,
write_data: &[u8],
___deadline: MonotonicInstant,
) -> Result<UsbControlTransferResult, Error>
pub fn control_transfer( &self, setup: &UsbSetup, timeout_ns: i64, write_data: &[u8], ___deadline: MonotonicInstant, ) -> Result<UsbControlTransferResult, Error>
Performs a synchronous USB control transfer (IN or OUT) over endpoint 0.
Replies after the control transaction completes on the bus (and any associated host
controller state updates for standard SET_CONFIGURATION or SET_INTERFACE requests
finish).
While this method can be used to read descriptors, prefer [GetDeviceDescriptor] and
[GetConfigurationDescriptor] when reading descriptors.
If timeout_ns is 0 or negative, a default 5-second timeout is used (per USB 2.0
Section 9.2.6.4).
- error:
ZX_ERR_INVALID_ARGSif the setup packet length orwrite_datasize is invalid.ZX_ERR_TIMED_OUTif the control transfer does not complete within the timeout.ZX_ERR_IO_REFUSEDif the device returns a STALL handshake.ZX_ERR_IO_NOT_PRESENTif the device has been disconnected.ZX_ERR_NOT_SUPPORTEDif the server does not support raw control transfers.
Sourcepub fn enable_endpoint(
&self,
ep_desc: &UsbEndpointDescriptor,
ss_com_desc: &UsbSsEpCompDescriptor,
enable: bool,
___deadline: MonotonicInstant,
) -> Result<UsbEnableEndpointResult, Error>
pub fn enable_endpoint( &self, ep_desc: &UsbEndpointDescriptor, ss_com_desc: &UsbSsEpCompDescriptor, enable: bool, ___deadline: MonotonicInstant, ) -> Result<UsbEnableEndpointResult, Error>
Enables or disables a USB endpoint on the host controller, configuring it as specified by the provided descriptors.
Replies after the host controller has updated its endpoint context and transfer ring state.
- error:
ZX_ERR_INVALID_ARGSif the endpoint descriptor is invalid.ZX_ERR_NO_RESOURCESif the host controller lacks bandwidth or resources.ZX_ERR_IO_NOT_PRESENTif the device has been disconnected.ZX_ERR_NOT_SUPPORTEDif the server does not support direct endpoint configuration.
Sourcepub fn reset_endpoint(
&self,
ep_address: u8,
___deadline: MonotonicInstant,
) -> Result<UsbResetEndpointResult, Error>
pub fn reset_endpoint( &self, ep_address: u8, ___deadline: MonotonicInstant, ) -> Result<UsbResetEndpointResult, Error>
Resets an endpoint on the host controller that is in a halted or error state, returning the host controller’s endpoint ring and data toggle to a normal running state.
Note: To clear a halt condition on a non-control endpoint, clients should also issue a
standard CLEAR_FEATURE(ENDPOINT_HALT) control request to the device to reset the device’s
data toggle to DATA0.
- error:
ZX_ERR_INVALID_ARGSif the endpoint is not halted or the address is invalid.ZX_ERR_IO_NOT_PRESENTif the device has been disconnected.