xslibusb.h
Go to the documentation of this file.
1 
2 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification,
6 // are permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice,
9 // this list of conditions, and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions, and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
14 //
15 // 3. Neither the names of the copyright holders nor the names of their contributors
16 // may be used to endorse or promote products derived from this software without
17 // specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
26 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
28 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
29 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
30 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
31 //
32 
33 
34 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
35 // All rights reserved.
36 //
37 // Redistribution and use in source and binary forms, with or without modification,
38 // are permitted provided that the following conditions are met:
39 //
40 // 1. Redistributions of source code must retain the above copyright notice,
41 // this list of conditions, and the following disclaimer.
42 //
43 // 2. Redistributions in binary form must reproduce the above copyright notice,
44 // this list of conditions, and the following disclaimer in the documentation
45 // and/or other materials provided with the distribution.
46 //
47 // 3. Neither the names of the copyright holders nor the names of their contributors
48 // may be used to endorse or promote products derived from this software without
49 // specific prior written permission.
50 //
51 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
52 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
53 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
54 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
56 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
58 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
59 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
60 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
61 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
62 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
63 //
64 
65 #ifndef XSLIBUSB
66 #define XSLIBUSB
67 
68 #ifdef HAVE_LIBUSB
69 
70 #include <libusb-1.0/libusb.h>
71 
72 typedef int libUSB_init(libusb_context** ctx);
73 typedef void libUSB_exit(libusb_context* ctx);
74 typedef int libUSB_open(libusb_device* dev, libusb_device_handle** handle);
75 typedef void libUSB_close(libusb_device_handle* dev_handle);
76 typedef int libUSB_kernel_driver_active(libusb_device_handle* dev, int interface_number);
77 typedef int libUSB_attach_kernel_driver(libusb_device_handle* dev, int interface_number);
78 typedef int libUSB_detach_kernel_driver(libusb_device_handle* dev, int interface_number);
79 typedef libusb_device* libUSB_ref_device(libusb_device* dev);
80 typedef void libUSB_unref_device(libusb_device* dev);
81 typedef int libUSB_claim_interface(libusb_device_handle* dev, int interface_number);
82 typedef int libUSB_release_interface(libusb_device_handle* dev, int interface_number);
83 typedef int libUSB_get_active_config_descriptor(libusb_device* dev, struct libusb_config_descriptor** config);
84 typedef void libUSB_free_config_descriptor(struct libusb_config_descriptor* config);
85 typedef uint8_t libUSB_get_bus_number(libusb_device* dev);
86 typedef libusb_device* libUSB_get_device(libusb_device_handle* dev_handle);
87 typedef uint8_t libUSB_get_device_address(libusb_device* dev);
88 typedef int libUSB_get_device_descriptor(libusb_device* dev, struct libusb_device_descriptor* desc);
89 typedef ssize_t libUSB_get_device_list(libusb_context* ctx, libusb_device*** list);
90 typedef void libUSB_free_device_list(libusb_device** list, int unref_devices);
91 typedef int libUSB_get_string_descriptor_ascii(libusb_device_handle* dev, uint8_t desc_index, unsigned char* data, int length);
92 typedef int libUSB_bulk_transfer(libusb_device_handle* dev_handle, unsigned char endpoint, unsigned char* data, int length, int* actual_length, unsigned int timeout);
93 typedef void libUSB_set_debug(libusb_context* ctx, int level);
94 
95 struct XsLibraryLoader;
96 
97 class XsLibUsb
98 {
99 public:
100  XsLibUsb(void);
101  ~XsLibUsb(void);
102 
103  libUSB_init init;
104  libUSB_exit exit;
105  libUSB_open open;
106  libUSB_close close;
107  libUSB_kernel_driver_active kernel_driver_active;
108  libUSB_attach_kernel_driver attach_kernel_driver;
109  libUSB_detach_kernel_driver detach_kernel_driver;
110  libUSB_ref_device ref_device;
111  libUSB_unref_device unref_device;
112  libUSB_claim_interface claim_interface;
113  libUSB_release_interface release_interface;
114  libUSB_get_active_config_descriptor get_active_config_descriptor;
115  libUSB_free_config_descriptor free_config_descriptor;
116  libUSB_get_bus_number get_bus_number;
117  libUSB_get_device get_device;
118  libUSB_get_device_address get_device_address;
119  libUSB_get_device_descriptor get_device_descriptor;
120  libUSB_get_device_list get_device_list;
121  libUSB_free_device_list free_device_list;
122  libUSB_get_string_descriptor_ascii get_string_descriptor_ascii;
123  libUSB_bulk_transfer bulk_transfer;
124  libUSB_set_debug set_debug;
125 private:
126 
127  struct LIBUSB_API
128  {
129  libUSB_init* init;
130  libUSB_exit* exit;
131  libUSB_open* open;
132  libUSB_close* close;
133  libUSB_kernel_driver_active* kernel_driver_active;
134  libUSB_attach_kernel_driver* attach_kernel_driver;
135  libUSB_detach_kernel_driver* detach_kernel_driver;
136  libUSB_ref_device* ref_device;
137  libUSB_unref_device* unref_device;
138  libUSB_claim_interface* claim_interface;
139  libUSB_release_interface* release_interface;
140  libUSB_get_active_config_descriptor* get_active_config_descriptor;
141  libUSB_free_config_descriptor* free_config_descriptor;
142  libUSB_get_bus_number* get_bus_number;
143  libUSB_get_device* get_device;
144  libUSB_get_device_address* get_device_address;
145  libUSB_get_device_descriptor* get_device_descriptor;
146  libUSB_get_device_list* get_device_list;
147  libUSB_free_device_list* free_device_list;
148  libUSB_get_string_descriptor_ascii* get_string_descriptor_ascii;
149  libUSB_bulk_transfer* bulk_transfer;
150  libUSB_set_debug* set_debug;
151  } m_libUsb;
152 
153  XsLibraryLoader* m_libraryLoader;
154 
155  void tryLoadLibrary();
156  void initLibrary();
157 };
158 
159 #endif // HAVE_LIBUSB
160 #endif
XsLibraryLoader
The Xsens dynamic library loader base class.
Definition: xslibraryloader.h:93
init
void init(const M_string &remappings)


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:20