Open Lighting Architecture  0.9.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EuroliteProOutputPort.h
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15  *
16  * EuroliteProOutputPort.h
17  * The output port for a EurolitePro device.
18  * Copyright (C) 2011 Simon Newton & Harry F
19  * Eurolite Pro USB DMX ArtNo. 51860120
20  */
21 
22 #ifndef PLUGINS_USBDMX_EUROLITEPROOUTPUTPORT_H_
23 #define PLUGINS_USBDMX_EUROLITEPROOUTPUTPORT_H_
24 
25 #include <libusb.h>
26 #include <string>
27 #include "ola/DmxBuffer.h"
28 #include "ola/thread/Thread.h"
29 #include "olad/Port.h"
30 
31 namespace ola {
32 namespace plugin {
33 namespace usbdmx {
34 
35 
37  public:
39  unsigned int id,
40  libusb_device *usb_device);
42  std::string SerialNumber() const { return m_serial; }
43 
44  bool Start();
45  void *Run();
46 
47  bool WriteDMX(const DmxBuffer &buffer, uint8_t priority);
48  std::string Description() const { return ""; }
49 
50  private:
51  static const unsigned int URB_TIMEOUT_MS = 500;
52  static const unsigned int UDMX_SET_CHANNEL_RANGE = 0x0002;
53  static const unsigned char ENDPOINT = 0x02;
54  static const char EXPECTED_MANUFACTURER[];
55  static const char EXPECTED_PRODUCT[];
56  static const uint8_t DMX_LABEL = 6;
57 
58  bool m_term;
59  int m_interface_number;
60  std::string m_serial;
61 
62  libusb_device *m_usb_device;
63  libusb_device_handle *m_usb_handle;
64  DmxBuffer m_buffer;
65  ola::thread::Mutex m_data_mutex;
66  ola::thread::Mutex m_term_mutex;
67 
68  bool SendDMX(const DmxBuffer &buffer_old);
69 
70  bool GetDescriptorString(libusb_device_handle *usb_handle,
71  uint8_t desc_index,
72  std::string *data);
73  bool LocateInterface();
74 
75  // 513 + header + code + size(2) + footer
76  enum { FRAME_SIZE = 518 };
77 };
78 } // namespace usbdmx
79 } // namespace plugin
80 } // namespace ola
81 #endif // PLUGINS_USBDMX_EUROLITEPROOUTPUTPORT_H_