Open Lighting Architecture: plugins/usbdmx/AsyncUsbSender.h Source File

| 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
42 class AsyncUsbSender: public AsyncUsbTransceiverBase {
43 public:
49 AsyncUsbSender(ola::usb::LibUsbAdaptor* const adaptor,
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_
DmxBuffer.h
A class used to hold a single universe of DMX data.
Macro.h
Helper macros.
ola::DmxBuffer
Used to hold a single universe of DMX data.
Definition DmxBuffer.h:49
ola::plugin::usbdmx::AsyncUsbSender
A base class that send DMX data asynchronously to a libusb_device.
Definition AsyncUsbSender.h:42
ola::plugin::usbdmx::AsyncUsbSender::~AsyncUsbSender
virtual ~AsyncUsbSender()
Destructor.
Definition AsyncUsbSender.cpp:38
ola::plugin::usbdmx::AsyncUsbSender::TransferComplete
void TransferComplete(struct libusb_transfer *transfer)
Called from the libusb callback when the asynchronous transfer completes.
Definition AsyncUsbSender.cpp:59
ola::plugin::usbdmx::AsyncUsbSender::PostTransferHook
virtual void PostTransferHook()
Called when the transfer completes.
Definition AsyncUsbSender.h:89
ola::plugin::usbdmx::AsyncUsbSender::SendDMX
bool SendDMX(const DmxBuffer &buffer)
Send one frame of DMX data.
Definition AsyncUsbSender.cpp:42
ola::plugin::usbdmx::AsyncUsbSender::PerformTransfer
virtual bool PerformTransfer(const DmxBuffer &buffer)=0
Perform the DMX transfer.
ola::plugin::usbdmx::AsyncUsbSender::AsyncUsbSender
AsyncUsbSender(ola::usb::LibUsbAdaptor *const adaptor, libusb_device *usb_device)
Create a new AsyncUsbSender.
Definition AsyncUsbSender.cpp:32
ola::plugin::usbdmx::AsyncUsbSender::TransferPending
bool TransferPending() const
Check if there is a pending transfer.
Definition AsyncUsbSender.h:95
ola::plugin::usbdmx::AsyncUsbTransceiverBase::AsyncUsbTransceiverBase
AsyncUsbTransceiverBase(ola::usb::LibUsbAdaptor *const adaptor, libusb_device *usb_device)
Create a new AsyncUsbTransceiverBase.
Definition AsyncUsbTransceiverBase.cpp:47
ola::usb::LibUsbAdaptor
Wraps calls to libusb so we can test the code.
Definition LibUsbAdaptor.h:36
ola::plugin::usbdmx
The plugin for hardware using libusb.
ola::plugin
Code for supported devices and protocols.
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44