Open Lighting Architecture  0.9.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UartWidget.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  * This class is based on QLCFTDI class from
17  *
18  * Q Light Controller
19  * qlcftdi.h
20  *
21  * Copyright (C) Heikki Junnila
22  *
23  * Only standard CPP conversion was changed and function name changed
24  * to follow OLA coding standards.
25  *
26  * by Rui Barreiros
27  * Copyright (C) 2014 Richard Ash
28  */
29 
30 #ifndef PLUGINS_UARTDMX_UARTWIDGET_H_
31 #define PLUGINS_UARTDMX_UARTWIDGET_H_
32 
33 #include <string>
34 #include <vector>
35 #include "ola/base/Macro.h"
36 #include "ola/DmxBuffer.h"
37 
38 namespace ola {
39 namespace plugin {
40 namespace uartdmx {
41 
45 class UartWidget {
46  public:
51  explicit UartWidget(const std::string &path);
52 
54  virtual ~UartWidget();
55 
57  std::string Name() const { return m_path; }
58  std::string Description() const { return m_path; }
59 
61  bool Open();
62 
64  bool Close();
65 
67  bool IsOpen() const;
68 
70  bool SetBreak(bool on);
71 
73  bool Write(const ola::DmxBuffer &data);
74 
76  bool Read(unsigned char* buff, int size);
77 
79  bool SetupOutput();
80 
81  private:
82  const std::string m_path;
83 
88  int m_fd;
89 
93  static const int NOT_OPEN = -2;
94 
98  static const int FAILED_OPEN = -1;
99 
100  DISALLOW_COPY_AND_ASSIGN(UartWidget);
101 };
102 } // namespace uartdmx
103 } // namespace plugin
104 } // namespace ola
105 #endif // PLUGINS_UARTDMX_UARTWIDGET_H_