co_usb
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Enumerations | Functions
co_usb Namespace Reference

Namespaces

namespace  detail
 

Classes

struct  basic_transfer
 Base transfer type which provides Capy's ReadStream/WriteStream operations depending on the direction of the endpoint provided. More...
 
struct  bulk_stream_transfer
 Transfer type for bulk stream transfers. More...
 
struct  bulk_transfer
 Transfer type for bulk transfers. More...
 
struct  context
 libusb_context wrapper More...
 
struct  context< use_service::no >
 
struct  context< use_service::yes >
 
struct  control_transfer
 Transfer type for control transfers. More...
 
struct  device_acceptor
 Accepts devices via hotplug. More...
 
struct  device_ref
 Wrapper for nullable libusb_device that increments ref count on ctor and decrements on dtor. More...
 
struct  device_triplet
 Aggregate struct to pass to functions requiring device information. More...
 
struct  endpoint
 USB endpoint templated on its direction. More...
 
struct  error_category_t
 
struct  hotplug_awaitable
 Low-level awaitable primitive for strapping hotplug callbacks to a coroutine ecosystem. More...
 
struct  interface
 RAII wrapper than claims interface on ctor and releases on dtor. More...
 
struct  interrupt_transfer
 Transfer type for interrupt transfers. More...
 
struct  isochronous_transfer
 Transfer type for isochronous transfers. More...
 
struct  kernel_driver_guard
 Refcounted RAII guard for managing detachment of a kernel driver for an interface of a device. More...
 
struct  transfer_awaitable
 Awaitable for submitting transfers. More...
 
struct  transfer_status_category_t
 

Typedefs

using dev_handle_deleter_t = std::decay_t< decltype(libusb_close)>
 
using unique_dev_handle = std::unique_ptr< libusb_device_handle, dev_handle_deleter_t >
 
using transfer_deleter_t = std::decay_t< decltype(libusb_free_transfer)>
 
using unique_transfer = std::unique_ptr< libusb_transfer, transfer_deleter_t >
 

Enumerations

enum class  use_service { no = 0 , yes }
 
enum class  usb_error : int {
  success = LIBUSB_SUCCESS , io_error = LIBUSB_ERROR_IO , invalid_param = LIBUSB_ERROR_INVALID_PARAM , access_error = LIBUSB_ERROR_ACCESS ,
  no_device = LIBUSB_ERROR_NO_DEVICE , not_found = LIBUSB_ERROR_NOT_FOUND , resource_busy = LIBUSB_ERROR_BUSY , timed_out = LIBUSB_ERROR_TIMEOUT ,
  overflow = LIBUSB_ERROR_OVERFLOW , broken_pipe = LIBUSB_ERROR_PIPE , interrupted = LIBUSB_ERROR_INTERRUPTED , out_of_memory = LIBUSB_ERROR_NO_MEM ,
  not_supported = LIBUSB_ERROR_NOT_SUPPORTED , unknown = LIBUSB_ERROR_OTHER
}
 
enum class  hotplug_event { arrived = LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED , left = LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT }
 enum class wrapper for hotplug events More...
 
enum class  hotplug_flag { none = LIBUSB_HOTPLUG_NO_FLAGS , enumerate = LIBUSB_HOTPLUG_ENUMERATE }
 wrapper for hotplug flags More...
 
enum class  endpoint_type : uint8_t {
  control = 0 , bulk , interrupt , isochronous ,
  bulk_stream
}
 
enum class  ep_direction { out = 0x00 , in = 0x80 , both = 0xFF }
 
enum class  transfer_status {
  completed = LIBUSB_TRANSFER_COMPLETED , error = LIBUSB_TRANSFER_ERROR , timed_out = LIBUSB_TRANSFER_TIMED_OUT , cancelled = LIBUSB_TRANSFER_CANCELLED ,
  stall = LIBUSB_TRANSFER_STALL , no_device = LIBUSB_TRANSFER_NO_DEVICE , overflow = LIBUSB_TRANSFER_OVERFLOW
}
 Status codes for transfers. More...
 

Functions

void default_handler (libusb_context *ctx, std::stop_token st)
 default handler function for the service
 
const std::error_category & usb_error_category ()
 
std::error_code make_usb_error_code (usb_error e) noexcept
 
std::error_code make_usb_error_code (libusb_error e) noexcept
 
boost::capy::io_result< unique_dev_handleopen (libusb_context *ctx, device_triplet triplet) noexcept
 
boost::capy::io_result< unique_dev_handleopen (libusb_device *dev) noexcept
 
boost::capy::io_result< unique_dev_handleopen (device_ref dev) noexcept
 
endpoint< ep_direction::inep_in (uint8_t ep, const interface &iface) noexcept
 Wrapper around endpoint<co_usb::ep_direction::in>::make_safe.
 
endpoint< ep_direction::outep_out (uint8_t ep, const interface &iface) noexcept
 Wrapper around endpoint<co_usb::ep_direction::out>::make_safe.
 
endpoint< ep_direction::bothep_any (uint8_t ep, const interface &iface) noexcept
 Creates an endpoint with an unknown direction.
 
const std::error_category & transfer_status_category ()
 
std::error_code make_transfer_status (transfer_status e) noexcept
 
std::error_code make_transfer_status (libusb_transfer_status e) noexcept
 

Typedef Documentation

◆ dev_handle_deleter_t

◆ transfer_deleter_t

◆ unique_dev_handle

◆ unique_transfer

Enumeration Type Documentation

◆ endpoint_type

Enumerator
control 
bulk 
interrupt 
isochronous 
bulk_stream 

◆ ep_direction

Enumerator
out 
in 
both 

◆ hotplug_event

enum class wrapper for hotplug events

Used in hotplug_awaitable

Enumerator
arrived 
left 

◆ hotplug_flag

wrapper for hotplug flags

There is only two of them

Enumerator
none 
enumerate 

◆ transfer_status

Status codes for transfers.

Note
Can be casted from libusb_transfer_status
Enumerator
completed 
error 

Transfer failed

timed_out 

Transfer timed out

cancelled 

Transfer was cancelled

stall 

For bulk/interrupt endpoints: halt condition detected (endpoint stalled). For control endpoints: control request not supported.

no_device 

Device was disconnected

overflow 

Device sent more data than requested

◆ usb_error

Enumerator
success 
io_error 

Input/output error

invalid_param 

Invalid parameter

access_error 

Access denied (insufficient permissions)

no_device 

No such device (it may have been disconnected)

not_found 

Entity not found

resource_busy 

Resource busy

timed_out 

Operation timed out

overflow 

Overflow

broken_pipe 

Pipe error

interrupted 

System call interrupted (perhaps due to signal)

out_of_memory 

Insufficient memory

not_supported 

Operation not supported or unimplemented on this platform

unknown 

Other error

◆ use_service

Enumerator
no 
yes 

Function Documentation

◆ default_handler()

void co_usb::default_handler ( libusb_context ctx,
std::stop_token  st 
)

default handler function for the service

◆ ep_any()

co_usb::endpoint< co_usb::ep_direction::both > co_usb::ep_any ( uint8_t  ep,
const interface iface 
)
noexcept

Creates an endpoint with an unknown direction.

◆ ep_in()

co_usb::endpoint< co_usb::ep_direction::in > co_usb::ep_in ( uint8_t  ep,
const interface iface 
)
noexcept

◆ ep_out()

co_usb::endpoint< co_usb::ep_direction::out > co_usb::ep_out ( uint8_t  ep,
const interface iface 
)
noexcept

◆ make_transfer_status() [1/2]

std::error_code co_usb::make_transfer_status ( libusb_transfer_status  e)
inlinenoexcept

◆ make_transfer_status() [2/2]

std::error_code co_usb::make_transfer_status ( transfer_status  e)
inlinenoexcept

◆ make_usb_error_code() [1/2]

std::error_code co_usb::make_usb_error_code ( libusb_error  e)
inlinenoexcept

◆ make_usb_error_code() [2/2]

std::error_code co_usb::make_usb_error_code ( usb_error  e)
inlinenoexcept

◆ open() [1/3]

boost::capy::io_result< co_usb::unique_dev_handle > co_usb::open ( co_usb::device_ref  dev)
noexcept

◆ open() [2/3]

boost::capy::io_result< co_usb::unique_dev_handle > co_usb::open ( libusb_context ctx,
device_triplet  triplet 
)
noexcept

◆ open() [3/3]

boost::capy::io_result< co_usb::unique_dev_handle > co_usb::open ( libusb_device dev)
noexcept

◆ transfer_status_category()

const std::error_category & co_usb::transfer_status_category ( )
inline

◆ usb_error_category()

const std::error_category & co_usb::usb_error_category ( )
inline