Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
423685d
OVDMX device support finished. Tested for about 1 minute, so don't tr…
JanOveSaltvedt Sep 14, 2015
9bbf5d4
Fixed a bug where random bytes matching \n (0x0A) was appended a carr…
Oct 6, 2015
820efe9
Merge remote-tracking branch 'upstream/master'
JanOveSaltvedt Feb 25, 2017
90ee02a
Fixed an error in the merging of DynamicPluginLoader.cpp
JanOveSaltvedt Feb 25, 2017
5b95972
Using 0 as the CRC, since it's not implemented in the USB dongle. Tha…
aasmundeldhuset Sep 29, 2017
8f58840
Merge remote-tracking branch 'upstream/master'
stemnic Sep 10, 2019
adfb1a2
Added temp plugin id for development
stemnic Sep 10, 2019
257a657
Merge branch 'master' into master
stemnic Oct 9, 2021
3463363
fixed endif comment
stemnic Oct 9, 2021
c42da3a
Fixed up copyright and added the plugins original author
stemnic Oct 9, 2021
2ecdaac
Fixed linting errors
stemnic Oct 9, 2021
a063bbb
More linting fixing
stemnic Oct 9, 2021
f8afbe9
Another try at fixing the linting
stemnic Oct 9, 2021
7ed3912
Update plugins/ovdmx/OVDmxThread.cpp
stemnic Nov 28, 2021
d527f9f
Update plugins/ovdmx/OVDmxThread.cpp
stemnic Nov 28, 2021
eec5012
Update plugins/ovdmx/OVDmxDevice.h
stemnic Nov 28, 2021
4c64bb1
Update plugins/ovdmx/OVDmxPlugin.cpp
stemnic Nov 28, 2021
0dbd73d
Update plugins/ovdmx/OVDmxDevice.cpp
stemnic Nov 28, 2021
7c7464c
Changed to SplitUInt16
stemnic Nov 28, 2021
be89b1c
Fixed linting error
stemnic Nov 28, 2021
7781f54
whitespace lint
stemnic Nov 28, 2021
fb773d3
Changed to packed macro
stemnic Nov 28, 2021
dfb558f
Fixed typo in struct pack definition
stemnic Nov 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/protocol/Ola.proto
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ enum PluginIds {
OLA_PLUGIN_GPIO = 22;
OLA_PLUGIN_SPIDMX = 23;
OLA_PLUGIN_NANOLEAF = 24;
OLA_PLUGIN_OVDMX = 10050;

/*
* To obtain a new plugin ID, open a ticket at
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,7 @@ PLUGIN_SUPPORT(stageprofi, USE_STAGEPROFI)
PLUGIN_SUPPORT(uartdmx, USE_UART, [$have_uart])
PLUGIN_SUPPORT(usbdmx, USE_LIBUSB, [$have_libusb])
PLUGIN_SUPPORT(usbpro, USE_USBPRO)
PLUGIN_SUPPORT(ovdmx, USE_OVDMX)

# Finally build a list of the required plugin libs.
PLUGIN_LIBS=''
Expand Down
11 changes: 10 additions & 1 deletion olad/DynamicPluginLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@
#include "plugins/dmx4linux/Dmx4LinuxPlugin.h"
#endif // USE_DMX4LINUX

#ifdef USE_OVDMX
#include "plugins/ovdmx/OVDmxPlugin.h"
#endif

namespace ola {

using std::vector;
Expand Down Expand Up @@ -253,7 +257,12 @@ void DynamicPluginLoader::PopulatePlugins() {
#ifdef USE_UART
m_plugins.push_back(
new ola::plugin::uartdmx::UartDmxPlugin(m_plugin_adaptor));
#endif // USE_UART
#endif

#ifdef USE_OVDMX
m_plugins.push_back(
new ola::plugin::ovdmx::OVDmxPlugin(m_plugin_adaptor));
#endif
}

void DynamicPluginLoader::UnloadPlugins() {
Expand Down
1 change: 1 addition & 0 deletions plugins/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ include plugins/spi/Makefile.mk
include plugins/spidmx/Makefile.mk
include plugins/stageprofi/Makefile.mk
include plugins/usbdmx/Makefile.mk
include plugins/ovdmx/Makefile.mk

if !USING_WIN32
include plugins/usbpro/Makefile.mk
Expand Down
16 changes: 16 additions & 0 deletions plugins/ovdmx/Makefile.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# LIBRARIES
##################################################
if USE_OVDMX
lib_LTLIBRARIES += plugins/ovdmx/libolaovdmx.la
plugins_ovdmx_libolaovdmx_la_SOURCES = \
plugins/ovdmx/OVDmxDevice.cpp \
plugins/ovdmx/OVDmxDevice.h \
plugins/ovdmx/OVDmxPlugin.cpp \
plugins/ovdmx/OVDmxPlugin.h \
plugins/ovdmx/OVDmxPort.h \
plugins/ovdmx/OVDmxThread.cpp \
plugins/ovdmx/OVDmxThread.h
plugins_ovdmx_libolaovdmx_la_LIBADD = \
common/libolacommon.la \
olad/plugin_api/libolaserverplugininterface.la
endif
46 changes: 46 additions & 0 deletions plugins/ovdmx/OVDmxDevice.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>

#include "plugins/ovdmx/OVDmxDevice.h"
#include "plugins/ovdmx/OVDmxPort.h"

namespace ola {
namespace plugin {
namespace ovdmx {

using ola::Device;
using std::string;


/*
* Create a new device
* @param owner
* @param name
* @param path to device
*/
OVDmxDevice::OVDmxDevice(AbstractPlugin *owner,
const string &name,
const string &path,
unsigned int device_id)
: Device(owner, name),
m_path(path) {
std::ostringstream str;
str << device_id;
m_device_id = str.str();
}



/*
* Start this device
*/
bool OVDmxDevice::StartHook() {
AddPort(new OVDmxOutputPort(this, 0, m_path));
return true;
}
} // namespace ovdmx
} // namespace plugin
} // namespace ola
31 changes: 31 additions & 0 deletions plugins/ovdmx/OVDmxDevice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef PLUGINS_OVDMX_OVDMXDEVICE_H_
#define PLUGINS_OVDMX_OVDMXDEVICE_H_

#include <string>
#include "olad/Device.h"

namespace ola {
namespace plugin {
namespace ovdmx {

class OVDmxDevice: public ola::Device {
public:
OVDmxDevice(ola::AbstractPlugin *owner,
const std::string &name,
const std::string &path,
unsigned int device_id);

// we only support one widget for now
std::string DeviceId() const { return m_device_id; }

protected:
bool StartHook();

private:
std::string m_path;
std::string m_device_id;
};
} // namespace ovdmx
} // namespace plugin
} // namespace ola
#endif // PLUGINS_OVDMX_OVDMXDEVICE_H_
115 changes: 115 additions & 0 deletions plugins/ovdmx/OVDmxPlugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>

#include "ola/Logging.h"
#include "ola/io/IOUtils.h"
#include "olad/PluginAdaptor.h"
#include "olad/Preferences.h"
#include "plugins/ovdmx/OVDmxDevice.h"
#include "plugins/ovdmx/OVDmxPlugin.h"

namespace ola {
namespace plugin {
namespace ovdmx {

using ola::PluginAdaptor;
using std::string;
using std::vector;

const char OVDmxPlugin::OVDMX_DEVICE_PATH[] = "/dev/ttyACM0";
const char OVDmxPlugin::OVDMX_DEVICE_NAME[] = "OVDmx USB Device";
const char OVDmxPlugin::PLUGIN_NAME[] = "Omega Verksted DMX";
const char OVDmxPlugin::PLUGIN_PREFIX[] = "ovdmx";
const char OVDmxPlugin::DEVICE_KEY[] = "device";


/*
* Start the plugin
* TODO: scan /dev for devices?
*/
bool OVDmxPlugin::StartHook() {
vector<string> devices = m_preferences->GetMultipleValue(DEVICE_KEY);
vector<string>::const_iterator iter = devices.begin();

// start counting device ids from 0
unsigned int device_id = 0;

for (; iter != devices.end(); ++iter) {
// first check if it's there
int fd;
if (ola::io::Open(*iter, O_WRONLY, &fd)) {
close(fd);
OVDmxDevice *device = new OVDmxDevice(
this,
OVDMX_DEVICE_NAME,
*iter,
device_id++);
if (device->Start()) {
m_devices.push_back(device);
m_plugin_adaptor->RegisterDevice(device);
} else {
OLA_WARN << "Failed to start OVDmxDevice for " << *iter;
delete device;
}
} else {
OLA_WARN << "Could not open " << *iter << " " << strerror(errno);
}
}
return true;
}


/*
* Stop the plugin
* @return true on success, false on failure
*/
bool OVDmxPlugin::StopHook() {
bool ret = true;
DeviceList::iterator iter = m_devices.begin();
for (; iter != m_devices.end(); ++iter) {
m_plugin_adaptor->UnregisterDevice(*iter);
ret &= (*iter)->Stop();
delete *iter;
}
m_devices.clear();
return ret;
}


/*
* Return the description for this plugin
*/
string OVDmxPlugin::Description() const {
return "OVDMX is awesome";
}


/*
* Set default preferences.
*/
bool OVDmxPlugin::SetDefaultPreferences() {
if (!m_preferences) {
return false;
}

if (m_preferences->SetDefaultValue(DEVICE_KEY, StringValidator(),
OVDMX_DEVICE_PATH)) {
m_preferences->Save();
}

// check if this save correctly
// we don't want to use it if null
if (m_preferences->GetValue(DEVICE_KEY).empty()) {
return false;
}

return true;
}
} // namespace ovdmx
} // namespace plugin
} // namespace ola
43 changes: 43 additions & 0 deletions plugins/ovdmx/OVDmxPlugin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#ifndef PLUGINS_OVDMX_OVDMXPLUGIN_H_
#define PLUGINS_OVDMX_OVDMXPLUGIN_H_

#include <string>
#include <vector>
#include "olad/Plugin.h"
#include "ola/plugin_id.h"

namespace ola {
namespace plugin {
namespace ovdmx {

class OVDmxDevice;

class OVDmxPlugin: public Plugin {
public:
explicit OVDmxPlugin(PluginAdaptor *plugin_adaptor):
Plugin(plugin_adaptor) {
}

std::string Name() const { return PLUGIN_NAME; }
std::string Description() const;
ola_plugin_id Id() const { return OLA_PLUGIN_OVDMX; }
std::string PluginPrefix() const { return PLUGIN_PREFIX; }

private:
bool StartHook();
bool StopHook();
bool SetDefaultPreferences();

typedef std::vector<OVDmxDevice*> DeviceList;
DeviceList m_devices;
static const char PLUGIN_NAME[];
static const char PLUGIN_PREFIX[];
static const char OVDMX_DEVICE_PATH[];
static const char OVDMX_DEVICE_NAME[];
static const char DEVICE_KEY[];
};
} // namespace ovdmx
} // namespace plugin
} // namespace ola

#endif // PLUGINS_OVDMX_OVDMXPLUGIN_H_
62 changes: 62 additions & 0 deletions plugins/ovdmx/OVDmxPort.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* OVDmxPort.h
* The Open DMX plugin for ola
* Copyright (C) 2005 Simon Newton
*/

#ifndef PLUGINS_OVDMX_OVDMXPORT_H_
#define PLUGINS_OVDMX_OVDMXPORT_H_

#include <string>
#include "ola/DmxBuffer.h"
#include "olad/Port.h"
#include "plugins/ovdmx/OVDmxDevice.h"
#include "plugins/ovdmx/OVDmxThread.h"

namespace ola {
namespace plugin {
namespace ovdmx {

class OVDmxOutputPort: public BasicOutputPort {
public:
OVDmxOutputPort(OVDmxDevice *parent,
unsigned int id,
const std::string &path)
: BasicOutputPort(parent, id),
m_thread(path),
m_path(path) {
m_thread.Start();
}

~OVDmxOutputPort() {
}

std::string Description() const { return "OVDMX at " + m_path; }

bool WriteDMX(OLA_UNUSED const DmxBuffer &buffer, OLA_UNUSED uint8_t priority) {
return m_thread.WriteDmx(buffer);
}

private:
OVDmxThread m_thread;
std::string m_path;

};
} // namespace ovdmx
} // namespace plugin
} // namespace ola
#endif // PLUGINS_OVDMX_OVDMXPORT_H_
Loading