1 | /******************************************************************************* |
---|
2 | Copyright(c) 2011 Gerry Rozema. All rights reserved. |
---|
3 | |
---|
4 | This library is free software; you can redistribute it and/or |
---|
5 | modify it under the terms of the GNU Library General Public |
---|
6 | License version 2 as published by the Free Software Foundation. |
---|
7 | |
---|
8 | This library is distributed in the hope that it will be useful, |
---|
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
11 | Library General Public License for more details. |
---|
12 | |
---|
13 | You should have received a copy of the GNU Library General Public License |
---|
14 | along with this library; see the file COPYING.LIB. If not, write to |
---|
15 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
---|
16 | Boston, MA 02110-1301, USA. |
---|
17 | *******************************************************************************/ |
---|
18 | |
---|
19 | #ifndef USBDEVICE_H |
---|
20 | #define USBDEVICE_H |
---|
21 | |
---|
22 | #pragma once |
---|
23 | |
---|
24 | #include <stdio.h> |
---|
25 | #include <stdlib.h> |
---|
26 | #include <unistd.h> |
---|
27 | #include <errno.h> |
---|
28 | |
---|
29 | #include <usb.h> |
---|
30 | |
---|
31 | #include "indibase.h" |
---|
32 | |
---|
33 | /** |
---|
34 | * \class INDI::USBDevice |
---|
35 | \brief Class to provide general functionality of a generic USB device. |
---|
36 | |
---|
37 | Developers need to subclass INDI::USBDevice to implement any driver within INDI that requires direct read/write/control over USB. |
---|
38 | |
---|
39 | \author Gerry Rozema |
---|
40 | \see Starlight Xpress INDI CCD driver for an example implementation of INDI::USBDevice |
---|
41 | */ |
---|
42 | class INDI::USBDevice |
---|
43 | { |
---|
44 | protected: |
---|
45 | struct usb_device *dev; |
---|
46 | struct usb_dev_handle *usb_handle; |
---|
47 | |
---|
48 | int ProductId; |
---|
49 | int VendorId; |
---|
50 | |
---|
51 | int OutputType; |
---|
52 | int OutputEndpoint; |
---|
53 | int InputType; |
---|
54 | int InputEndpoint; |
---|
55 | |
---|
56 | struct usb_device * FindDevice(int,int,int); |
---|
57 | |
---|
58 | public: |
---|
59 | int WriteInterrupt(char *,int,int); |
---|
60 | int ReadInterrupt(char *,int,int); |
---|
61 | |
---|
62 | int ControlMessage(); |
---|
63 | |
---|
64 | int WriteBulk(char *buf,int nbytes,int timeout); |
---|
65 | int ReadBulk(char *buf,int nbytes,int timeout); |
---|
66 | int FindEndpoints(); |
---|
67 | int Open(); |
---|
68 | USBDevice(void); |
---|
69 | USBDevice(struct usb_device *); |
---|
70 | virtual ~USBDevice(void); |
---|
71 | }; |
---|
72 | |
---|
73 | #endif // USBDEVICE_H |
---|