Instrument Neutral Distributed Interface INDI  1.9.2
indiusbdevice.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2011 Gerry Rozema. All rights reserved.
3 
4  Upgrade to libusb 1.0 by CloudMakers, s. r. o.
5  Copyright(c) 2013 CloudMakers, s. r. o. All rights reserved.
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License version 2 as published by the Free Software Foundation.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 *******************************************************************************/
21 
22 #pragma once
23 
24 #include "indibase.h"
25 
26 #include <libusb.h>
27 
34 namespace INDI
35 {
36 
37 class USBDevice
38 {
39  protected:
40  libusb_device *dev;
41  libusb_device_handle *usb_handle;
42 
43  int ProductId;
44  int VendorId;
45 
48  int InputType;
50 
51  libusb_device *FindDevice(int, int, int);
52 
53  public:
54  int WriteInterrupt(unsigned char *, int, int);
55  int ReadInterrupt(unsigned char *, int, int);
56  int WriteBulk(unsigned char *buf, int nbytes, int timeout);
57  int ReadBulk(unsigned char *buf, int nbytes, int timeout);
58  int ControlMessage(unsigned char request_type, unsigned char request, unsigned int value, unsigned int index,
59  unsigned char *data, unsigned char len);
60  int FindEndpoints();
61  int Open();
62  void Close();
63  USBDevice();
64  USBDevice(libusb_device *dev);
65  virtual ~USBDevice();
66 };
67 }
INDI::USBDevice::ProductId
int ProductId
Definition: indiusbdevice.h:43
INDI::USBDevice
Definition: indiusbdevice.h:37
INDI::USBDevice::OutputEndpoint
int OutputEndpoint
Definition: indiusbdevice.h:47
indibase.h
INDI::USBDevice::ReadBulk
int ReadBulk(unsigned char *buf, int nbytes, int timeout)
Definition: indiusbdevice.cpp:193
INDI::USBDevice::VendorId
int VendorId
Definition: indiusbdevice.h:44
INDI::USBDevice::WriteInterrupt
int WriteInterrupt(unsigned char *, int, int)
Definition: indiusbdevice.cpp:182
INDI::USBDevice::USBDevice
USBDevice()
Definition: indiusbdevice.cpp:40
INDI::USBDevice::FindEndpoints
int FindEndpoints()
Definition: indiusbdevice.cpp:138
INDI::USBDevice::~USBDevice
virtual ~USBDevice()
Definition: indiusbdevice.cpp:57
INDI::USBDevice::WriteBulk
int WriteBulk(unsigned char *buf, int nbytes, int timeout)
Definition: indiusbdevice.cpp:204
INDI::USBDevice::ControlMessage
int ControlMessage(unsigned char request_type, unsigned char request, unsigned int value, unsigned int index, unsigned char *data, unsigned char len)
Definition: indiusbdevice.cpp:215
INDI::USBDevice::Close
void Close()
Definition: indiusbdevice.cpp:133
INDI::USBDevice::dev
libusb_device * dev
Definition: indiusbdevice.h:40
INDI::USBDevice::Open
int Open()
Definition: indiusbdevice.cpp:103
INDI::USBDevice::FindDevice
libusb_device * FindDevice(int, int, int)
Definition: indiusbdevice.cpp:62
INDI::USBDevice::usb_handle
libusb_device_handle * usb_handle
Definition: indiusbdevice.h:41
INDI::USBDevice::ReadInterrupt
int ReadInterrupt(unsigned char *, int, int)
Definition: indiusbdevice.cpp:171
INDI
Namespace to encapsulate INDI client, drivers, and mediator classes.
Definition: AlignmentSubsystemForClients.cpp:11
INDI::USBDevice::InputType
int InputType
Definition: indiusbdevice.h:48
INDI::USBDevice::InputEndpoint
int InputEndpoint
Definition: indiusbdevice.h:49
INDI::USBDevice::OutputType
int OutputType
Definition: indiusbdevice.h:46