Open Lighting Architecture  0.9.3
 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 
36  public:
38  unsigned int id,
39  libusb_device *usb_device);
41  std::string SerialNumber() const { return m_serial; }
42 
43  bool Start();
44  void *Run();
45 
46  bool WriteDMX(const DmxBuffer &buffer, uint8_t priority);
47  std::string Description() const { return ""; }
48 
49  private:
50  static const unsigned int URB_TIMEOUT_MS = 500;
51  static const unsigned int UDMX_SET_CHANNEL_RANGE = 0x0002;
52  static const unsigned char ENDPOINT = 0x02;
53  static const char EXPECTED_MANUFACTURER[];
54  static const char EXPECTED_PRODUCT[];
55  static const uint8_t DMX_LABEL = 6;
56 
57  bool m_term;
58  int m_interface_number;
59  std::string m_serial;
60 
61  libusb_device *m_usb_device;
62  libusb_device_handle *m_usb_handle;
63  DmxBuffer m_buffer;
64  ola::thread::Mutex m_data_mutex;
65  ola::thread::Mutex m_term_mutex;
66 
67  bool SendDMX(const DmxBuffer &buffer_old);
68 
69  bool LocateInterface();
70 
71  // 513 + header + code + size(2) + footer
72  enum { FRAME_SIZE = 518 };
73 };
74 } // namespace usbdmx
75 } // namespace plugin
76 } // namespace ola
77 #endif // PLUGINS_USBDMX_EUROLITEPROOUTPUTPORT_H_