usb_linux_utils.h
Go to the documentation of this file.
1 /*
2  * BSD 3-Clause License
3  *
4  * Copyright (c) 2019, Analog Devices, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice, this
11  * list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived from
19  * this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 #ifndef USB_LINUX_UTILS_H
33 #define USB_LINUX_UTILS_H
34 
36 #include <cstdint>
37 #include <string>
38 
39 #define CLEAR(x) memset(&(x), 0, sizeof(x))
40 
41 #define MAX_PACKET_SIZE (58)
42 #define MAX_BUF_SIZE (MAX_PACKET_SIZE + 2)
43 
45  public:
46  static int xioctl(int fh, unsigned long request, void *arg);
47 
61  static int uvcExUnitReadOnePacket(int fd, uint8_t selector,
62  uint8_t *BytesToWrite,
63  uint8_t nbBytesToWrite, uint8_t *data,
64  uint8_t nbPacketBytes,
65  uint8_t nbBytesToRead);
66 
77  static int uvcExUnitReadBuffer(int fd, uint8_t selector, int16_t id,
78  uint32_t address, uint8_t *data,
79  uint32_t bufferLength);
80 
91  static int uvcExUnitWriteBuffer(int fd, uint8_t selector, int16_t id,
92  uint32_t address, const uint8_t *data,
93  uint32_t bufferLength);
101  static aditof::Status uvcExUnitGetString(int fd, int uvcControlId,
102  std::string &outStr);
103 
112  static int UvcExUnitSetProperty(int fd, uint8_t selector,
113  const uint8_t *data, size_t nbBytes);
114 
123  static int UvcExUnitGetProperty(int fd, uint8_t selector, uint8_t *data,
124  size_t nbBytes);
125 
132  static aditof::Status uvcExUnitSendRequest(int fd,
133  const std::string &requestStr);
134 
142  static aditof::Status uvcExUnitGetResponse(int fd,
144 };
145 
146 #endif // USB_LINUX_UTILS_H
string
GLsizei const GLchar *const * string
Definition: glcorearb.h:3083
address
const char * address
Definition: builds/zos/test_fork.cpp:6
responseStr
ROSCPP_DECL XmlRpc::XmlRpcValue responseStr(int code, const std::string &msg, const std::string &response)
UsbLinuxUtils::uvcExUnitReadBuffer
static int uvcExUnitReadBuffer(int fd, uint8_t selector, int16_t id, uint32_t address, uint8_t *data, uint32_t bufferLength)
uvcExUnitReadBuffer - Reads a chunk of data (a buffer) through the UVC Extension Unit
Definition: usb_linux_utils.cpp:146
UsbLinuxUtils::uvcExUnitGetString
static aditof::Status uvcExUnitGetString(int fd, int uvcControlId, std::string &outStr)
uvcExUnitGetString
Definition: usb_linux_utils.cpp:241
UsbLinuxUtils::uvcExUnitWriteBuffer
static int uvcExUnitWriteBuffer(int fd, uint8_t selector, int16_t id, uint32_t address, const uint8_t *data, uint32_t bufferLength)
uvcExUnitWriteBuffer
Definition: usb_linux_utils.cpp:188
aditof::Status
Status
Status of any operation that the TOF sdk performs.
Definition: status_definitions.h:48
UsbLinuxUtils::UvcExUnitGetProperty
static int UvcExUnitGetProperty(int fd, uint8_t selector, uint8_t *data, size_t nbBytes)
Read bytes from one of the controls of the UVC extension unit.
Definition: usb_linux_utils.cpp:287
UsbLinuxUtils
Definition: usb_linux_utils.h:44
UsbLinuxUtils::uvcExUnitGetResponse
static aditof::Status uvcExUnitGetResponse(int fd, std::string &responseStr)
Get the response (which is encoded in a protobuf message) for the last request that was made....
Definition: usb_linux_utils.cpp:343
UsbLinuxUtils::UvcExUnitSetProperty
static int UvcExUnitSetProperty(int fd, uint8_t selector, const uint8_t *data, size_t nbBytes)
Send bytes to one of the controls of the UVC extension unit.
Definition: usb_linux_utils.cpp:272
data
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: glcorearb.h:2879
status_definitions.h
UsbLinuxUtils::xioctl
static int xioctl(int fh, unsigned long request, void *arg)
Definition: usb_linux_utils.cpp:54
UsbLinuxUtils::uvcExUnitSendRequest
static aditof::Status uvcExUnitSendRequest(int fd, const std::string &requestStr)
Send a request (which is encoded in a protobuf message) via the UVC extension unit.
Definition: usb_linux_utils.cpp:302
UsbLinuxUtils::uvcExUnitReadOnePacket
static int uvcExUnitReadOnePacket(int fd, uint8_t selector, uint8_t *BytesToWrite, uint8_t nbBytesToWrite, uint8_t *data, uint8_t nbPacketBytes, uint8_t nbBytesToRead)
uvcExUnitReadOnePacket - Reads one packet of data through the UVC Extension Unit
Definition: usb_linux_utils.cpp:80


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:07:01