aboutsummaryrefslogtreecommitdiff
path: root/include/libtio
diff options
context:
space:
mode:
authorThomas Touhey <thomas@touhey.fr>2019-04-30 13:50:29 +0200
committerThomas Touhey <thomas@touhey.fr>2019-04-30 13:50:29 +0200
commit4bced2ce87c9cb6cdb37bf0d39d47b35afba0741 (patch)
treea8798d99a8d9ba4b20fee5398a5b0b14be496c20 /include/libtio
parentc5ecf356812ce0cb588a38b34591e144587cee7c (diff)
Added libusb support (untested).
Diffstat (limited to 'include/libtio')
-rw-r--r--include/libtio/io/usb.h32
-rw-r--r--include/libtio/native.h8
-rw-r--r--include/libtio/stream.h4
3 files changed, 37 insertions, 7 deletions
diff --git a/include/libtio/io/usb.h b/include/libtio/io/usb.h
index b761bd1..aed26a9 100644
--- a/include/libtio/io/usb.h
+++ b/include/libtio/io/usb.h
@@ -8,9 +8,28 @@ TIO_BEGIN_NAMESPACE
* Using such a stream, you can send USB requests and receive the answer
* (act as the master).
*
- * USB packets are described in the callbacks section. */
+ * USB packets are described in the callbacks section.
+ *
+ * Descriptors (for finding and giving information about connected USB
+ * devices) have the following structure: */
+
+TIO_STRUCT(tio_usb_device, tio_usb_device_t)
+
+struct tio_usb_device {
+ /* Localisation on the USB buses. */
+
+ int tio_usb_device_bus;
+ int tio_usb_device_address;
-/* TODO: USB descriptors. */
+ /* Data. */
+
+ int tio_usb_device_class; /* bDeviceClass */
+ int tio_usb_device_subclass; /* bDeviceSubClass */
+ int tio_usb_device_protocol; /* bDeviceProtocol */
+
+ unsigned int tio_usb_device_vendor_id; /* idVendor */
+ unsigned int tio_usb_device_product_id; /* idProduct */
+};
/* ---
* Utilities.
@@ -18,7 +37,14 @@ TIO_BEGIN_NAMESPACE
TIO_BEGIN_DECLS
-/* TODO: list USB devices. */
+/* List the available USB devices.
+ * The iterator yields strings (`char const *`) representing the path. */
+
+TIO_EXTERN(int) tio_list_usb_devices
+ OF((tio_iter_t **tio__iterp));
+
+# define tio_next_usb_device(ITER, PTRP) \
+ (tio_next((ITER), (void **)(tio_usb_device_t **)(PTRP)))
TIO_END_DECLS
TIO_END_NAMESPACE
diff --git a/include/libtio/native.h b/include/libtio/native.h
index 1f556fb..4a005ad 100644
--- a/include/libtio/native.h
+++ b/include/libtio/native.h
@@ -109,9 +109,13 @@ TIO_EXTERN(int) tio_list_windows_serial_ports
# include <libusb.h>
TIO_EXTERN(int) tio_open_libusb
- OF((tio_stream_t **streamp, int bus, int addr));
+ OF((tio_stream_t **tio__streamp, int tio__bus, int tio__addr));
TIO_EXTERN(int) tio_open_libusb_device
- OF((tio_stream_t **streamp, libusb_device_handle *handle));
+ OF((tio_stream_t **tio__streamp, libusb_device *tio__device,
+ int tio__deref));
+
+TIO_EXTERN(int) tio_list_libusb_devices
+ OF((tio_iter_t **tio__iterp));
# endif
diff --git a/include/libtio/stream.h b/include/libtio/stream.h
index 0ab20d3..e4dac10 100644
--- a/include/libtio/stream.h
+++ b/include/libtio/stream.h
@@ -80,7 +80,7 @@ typedef TIO_HOOK_TYPE(int) tio_usb_send_bulk_t
OF((void *, unsigned char const *, size_t,
unsigned int /* total timeout in ms */));
typedef TIO_HOOK_TYPE(int) tio_usb_recv_bulk_t
- OF((void *, unsigned char *, size_t,
+ OF((void *, unsigned char *, size_t *,
unsigned int /* total timeout in ms */));
/* Generic stream definitions. */
@@ -274,7 +274,7 @@ TIO_EXTERN(int) tio_usb_send_bulk
size_t tio__size, unsigned int tio__timeout));
TIO_EXTERN(int) tio_usb_recv_bulk
OF((tio_stream_t *tio__stream, unsigned char *tio__buf,
- size_t tio__size, unsigned int tio__timeout));
+ size_t *tio__sizep, unsigned int tio__timeout));
/* Make an SCSI request. */