pub struct GsUsbClass<'a, B: UsbBus> { /* private fields */ }Expand description
USB GS_USB class implementing the candleLight / Linux gs_usb protocol.
Provides a bidirectional CAN channel via USB bulk endpoints plus vendor-specific control requests for configuration.
Implementations§
Source§impl<'a, B: UsbBus> GsUsbClass<'a, B>
impl<'a, B: UsbBus> GsUsbClass<'a, B>
Sourcepub fn new(alloc: &'a UsbBusAllocator<B>) -> Self
pub fn new(alloc: &'a UsbBusAllocator<B>) -> Self
Create a new GS_USB class with default device configuration.
Call set_device_config and
set_bt_const before connecting to set
device-specific parameters.
Sourcepub fn set_device_config(&mut self, cfg: GsDeviceConfig)
pub fn set_device_config(&mut self, cfg: GsDeviceConfig)
Set the device configuration reported to the host.
Sourcepub fn set_bt_const(&mut self, c: GsDeviceBtConst)
pub fn set_bt_const(&mut self, c: GsDeviceBtConst)
Set the bit-timing constraints reported to the host.
Sourcepub fn is_configured(&self) -> bool
pub fn is_configured(&self) -> bool
true when the device is configured by the host.
Sourcepub fn mode_flags(&self) -> u32
pub fn mode_flags(&self) -> u32
Current mode flags.
Sourcepub fn bit_timing(&self) -> &GsDeviceBitTiming
pub fn bit_timing(&self) -> &GsDeviceBitTiming
Current bit timing parameters.
Sourcepub fn try_recv(&self) -> UsbResult<Option<GsHostFrame>>
pub fn try_recv(&self) -> UsbResult<Option<GsHostFrame>>
Attempt to read a CAN frame from the host (bulk OUT).
Returns Ok(Some(frame)) when a frame is available,
Ok(None) when no data is waiting, or an error.
Sourcepub fn try_send(&self, frame: &GsHostFrame) -> UsbResult<()>
pub fn try_send(&self, frame: &GsHostFrame) -> UsbResult<()>
Send a CAN frame to the host (bulk IN).
Returns Ok(()) on success, or an error (e.g. WouldBlock if the
previous packet hasn’t been sent yet).
Trait Implementations§
Source§impl<B: UsbBus> UsbClass<B> for GsUsbClass<'_, B>
impl<B: UsbBus> UsbClass<B> for GsUsbClass<'_, B>
Source§fn configuration_descriptors(
&self,
w: &mut DescriptorWriter<'_>,
) -> UsbResult<()>
fn configuration_descriptors( &self, w: &mut DescriptorWriter<'_>, ) -> UsbResult<()>
Source§fn control_in(&mut self, xfer: ControlIn<'_, B>)
fn control_in(&mut self, xfer: ControlIn<'_, B>)
Source§fn control_out(&mut self, xfer: ControlOut<'_, B>)
fn control_out(&mut self, xfer: ControlOut<'_, B>)
Source§fn deconfigure(&mut self)
fn deconfigure(&mut self)
Source§fn string(&self, index: StringIndex, lang_id: u16) -> Option<&str>
fn string(&self, index: StringIndex, lang_id: u16) -> Option<&str>
StringIndex, or None.Source§fn endpoint_out(&mut self, addr: EndpointAddress)
fn endpoint_out(&mut self, addr: EndpointAddress)
addr received an OUT packet.Source§fn endpoint_in_complete(&mut self, addr: EndpointAddress)
fn endpoint_in_complete(&mut self, addr: EndpointAddress)
addr completed an IN transfer.Source§fn endpoint_setup(&mut self, addr: EndpointAddress)
fn endpoint_setup(&mut self, addr: EndpointAddress)
addr received a SETUP packet (non-EP0 control).Source§fn poll(&mut self)
fn poll(&mut self)
UsbDevice::poll.Source§fn alt_setting(&mut self, interface: InterfaceNumber) -> Option<u8>
fn alt_setting(&mut self, interface: InterfaceNumber) -> Option<u8>
interface, or None.Source§fn set_alt_setting(&mut self, interface: InterfaceNumber, alt: u8) -> bool
fn set_alt_setting(&mut self, interface: InterfaceNumber, alt: u8) -> bool
interface. Return true if handled.