Lines Matching refs:handle
51 /// Handle to USB interface
54 /// Handle to USB read pipe (endpoint)
57 /// Handle to USB write pipe (endpoint)
69 int recognized_device(usb_handle* handle, ifc_match_func callback);
74 /// Writes data to the opened usb handle
75 int usb_write(usb_handle* handle, const void* data, int len);
77 /// Reads data using the opened usb handle
78 int usb_read(usb_handle *handle, void* data, int len);
80 /// Cleans up opened usb handle
81 void usb_cleanup_handle(usb_handle* handle);
83 /// Cleans up (but don't close) opened usb handle
84 void usb_kick(usb_handle* handle);
86 /// Closes opened usb handle
87 int usb_close(usb_handle* handle);
91 // Allocate our handle
153 int usb_write(usb_handle* handle, const void* data, int len) {
160 if (NULL != handle) {
164 ret = AdbWriteEndpointSync(handle->adb_write_pipe,
174 usb_kick(handle);
186 DBG("usb_write NULL handle\n");
195 int usb_read(usb_handle *handle, void* data, int len) {
201 if (NULL != handle) {
205 ret = AdbReadEndpointSync(handle->adb_read_pipe,
217 usb_kick(handle);
223 DBG("usb_read NULL handle\n");
232 void usb_cleanup_handle(usb_handle* handle) {
233 if (NULL != handle) {
234 if (NULL != handle->interface_name)
235 free(handle->interface_name);
236 if (NULL != handle->adb_write_pipe)
237 AdbCloseHandle(handle->adb_write_pipe);
238 if (NULL != handle->adb_read_pipe)
239 AdbCloseHandle(handle->adb_read_pipe);
240 if (NULL != handle->adb_interface)
241 AdbCloseHandle(handle->adb_interface);
243 handle->interface_name = NULL;
244 handle->adb_write_pipe = NULL;
245 handle->adb_read_pipe = NULL;
246 handle->adb_interface = NULL;
250 void usb_kick(usb_handle* handle) {
251 if (NULL != handle) {
252 usb_cleanup_handle(handle);
259 int usb_close(usb_handle* handle) {
262 if (NULL != handle) {
263 // Cleanup handle
264 usb_cleanup_handle(handle);
265 free(handle);
271 int recognized_device(usb_handle* handle, ifc_match_func callback) {
276 if (NULL == handle)
280 if (!AdbGetUsbDeviceDescriptor(handle->adb_interface,
286 if (!AdbGetUsbInterfaceDescriptor(handle->adb_interface,
308 if (!AdbGetSerialNumber(handle->adb_interface, info.serial_number,
321 usb_handle* handle = NULL;
347 handle = do_usb_open(next_interface->device_name);
348 if (NULL != handle) {
350 if (recognized_device(handle, callback)) {
354 usb_cleanup_handle(handle);
355 free(handle);
356 handle = NULL;
364 return handle;