-
Notifications
You must be signed in to change notification settings - Fork 221
Adding ovdmx support for ola #1581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
stemnic
wants to merge
23
commits into
OpenLightingProject:master
Choose a base branch
from
stemnic:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 9bbf5d4
Fixed a bug where random bytes matching \n (0x0A) was appended a carr…
820efe9
Merge remote-tracking branch 'upstream/master'
JanOveSaltvedt 90ee02a
Fixed an error in the merging of DynamicPluginLoader.cpp
JanOveSaltvedt 5b95972
Using 0 as the CRC, since it's not implemented in the USB dongle. Tha…
aasmundeldhuset 8f58840
Merge remote-tracking branch 'upstream/master'
stemnic adfb1a2
Added temp plugin id for development
stemnic 257a657
Merge branch 'master' into master
stemnic 3463363
fixed endif comment
stemnic c42da3a
Fixed up copyright and added the plugins original author
stemnic 2ecdaac
Fixed linting errors
stemnic a063bbb
More linting fixing
stemnic f8afbe9
Another try at fixing the linting
stemnic 7ed3912
Update plugins/ovdmx/OVDmxThread.cpp
stemnic d527f9f
Update plugins/ovdmx/OVDmxThread.cpp
stemnic eec5012
Update plugins/ovdmx/OVDmxDevice.h
stemnic 4c64bb1
Update plugins/ovdmx/OVDmxPlugin.cpp
stemnic 0dbd73d
Update plugins/ovdmx/OVDmxDevice.cpp
stemnic 7c7464c
Changed to SplitUInt16
stemnic be89b1c
Fixed linting error
stemnic 7781f54
whitespace lint
stemnic fb773d3
Changed to packed macro
stemnic dfb558f
Fixed typo in struct pack definition
stemnic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
stemnic marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| : 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
stemnic marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // 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_ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
stemnic marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
stemnic marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * Copyright (C) 2005 Simon Newton | ||
stemnic marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| */ | ||
|
|
||
| #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_ | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.