Open Lighting Architecture 0.10.9
Loading...
Searching...
No Matches
AsyncUsbSender.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 * AsyncUsbSender.h
17 * An Asynchronous DMX USB sender.
18 * Copyright (C) 2014 Simon Newton
19 */
20
21#ifndef PLUGINS_USBDMX_ASYNCUSBSENDER_H_
22#define PLUGINS_USBDMX_ASYNCUSBSENDER_H_
23
24#include <libusb.h>
25
26#include "AsyncUsbTransceiverBase.h"
27#include "libs/usb/LibUsbAdaptor.h"
28#include "ola/DmxBuffer.h"
29#include "ola/base/Macro.h"
30#include "ola/thread/Mutex.h"
31
32namespace ola {
33namespace plugin {
34namespace usbdmx {
35
43 public:
50 libusb_device *usb_device);
51
55 virtual ~AsyncUsbSender();
56
62 bool SendDMX(const DmxBuffer &buffer);
63
69 void TransferComplete(struct libusb_transfer *transfer);
70
71 protected:
81 virtual bool PerformTransfer(const DmxBuffer &buffer) = 0;
82
89 virtual void PostTransferHook() {}
90
95 bool TransferPending() const { return m_pending_tx; }
96
97 private:
98 DmxBuffer m_tx_buffer; // GUARDED_BY(m_mutex);
99 bool m_pending_tx; // GUARDED_BY(m_mutex);
100
101 AsyncUsbSender(const AsyncUsbSender &) = delete;
102 const AsyncUsbSender &operator=(const AsyncUsbSender &) = delete;
103};
104} // namespace usbdmx
105} // namespace plugin
106} // namespace ola
107#endif // PLUGINS_USBDMX_ASYNCUSBSENDER_H_
A class used to hold a single universe of DMX data.
Helper macros.
Used to hold a single universe of DMX data.
Definition DmxBuffer.h:49
A base class that send DMX data asynchronously to a libusb_device.
Definition AsyncUsbSender.h:42
virtual ~AsyncUsbSender()
Destructor.
Definition AsyncUsbSender.cpp:38
void TransferComplete(struct libusb_transfer *transfer)
Called from the libusb callback when the asynchronous transfer completes.
Definition AsyncUsbSender.cpp:59
virtual void PostTransferHook()
Called when the transfer completes.
Definition AsyncUsbSender.h:89
bool SendDMX(const DmxBuffer &buffer)
Send one frame of DMX data.
Definition AsyncUsbSender.cpp:42
virtual bool PerformTransfer(const DmxBuffer &buffer)=0
Perform the DMX transfer.
AsyncUsbSender(ola::usb::LibUsbAdaptor *const adaptor, libusb_device *usb_device)
Create a new AsyncUsbSender.
Definition AsyncUsbSender.cpp:32
bool TransferPending() const
Check if there is a pending transfer.
Definition AsyncUsbSender.h:95
A base class that implements common functionality to send or receive DMX asynchronously to a libusb_d...
Definition AsyncUsbTransceiverBase.h:39
Wraps calls to libusb so we can test the code.
Definition LibUsbAdaptor.h:36
The namespace containing all OLA symbols.
Definition Credentials.cpp:44