Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / ground / gcs / src / plugins / ophid / inc / ophid_hidapi.h
blob0b026423d54ff3da7789614c90ae9df453a64ebc
1 /**
2 ******************************************************************************
4 * @file ophid_hidapi.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2013.
6 * @addtogroup GCSPlugins GCS Plugins
7 * @{
8 * @addtogroup opHIDPlugin HID Plugin
9 * @{
10 * @brief Impliments a HID USB connection to the flight hardware as a QIODevice
11 *****************************************************************************/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #ifndef OPHID_HIDAPI_H
29 #define OPHID_HIDAPI_H
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <stdint.h>
33 #include <QString>
34 #include <QMutex>
35 #include "../hidapi/hidapi.h"
36 #include "ophid_const.h"
37 #include "ophid_global.h"
40 class OPHID_EXPORT opHID_hidapi : public QObject {
41 Q_OBJECT
43 public:
45 opHID_hidapi();
47 ~opHID_hidapi();
49 int open(int max, int vid, int pid, int usage_page, int usage);
51 int receive(int, void *buf, int len, int timeout);
53 void close(int num);
55 int send(int num, void *buf, int len, int timeout);
57 QString getserial(int num);
59 private:
61 int enumerate(struct hid_device_info * *current_device_pptr, int *devices_found);
63 hid_device *handle;
65 /** A mutex to protect hid write */
66 QMutex hid_write_Mtx;
68 /** A mutex to protect hid read */
69 QMutex hid_read_Mtx;
71 signals:
72 void deviceUnplugged(int);
75 #endif // ifndef OPHID_HIDAPI_H