Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,5 @@ javascript/new-src/node_modules
.cproject
.settings
.vscode/
etc
.pydevproject
14 changes: 13 additions & 1 deletion plugins/uartdmx/UartDmxDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ using std::string;

const char UartDmxDevice::K_MALF[] = "-malf";
const char UartDmxDevice::K_BREAK[] = "-break";
const char UartDmxDevice::K_PADDING[] = "-padding";
const unsigned int UartDmxDevice::DEFAULT_BREAK = 100;
const unsigned int UartDmxDevice::DEFAULT_MALF = 100;
const unsigned int UartDmxDevice::DEFAULT_PADDING = 24;


UartDmxDevice::UartDmxDevice(AbstractPlugin *owner,
Expand All @@ -57,7 +59,11 @@ UartDmxDevice::UartDmxDevice(AbstractPlugin *owner,
if (!StringToInt(m_preferences->GetValue(DeviceMalfKey()), &m_malft)) {
m_malft = DEFAULT_MALF;
}
m_widget.reset(new UartWidget(path));
// Minimum amount of DMX channels to transmit
if (!StringToInt(m_preferences->GetValue(DevicePaddingKey()), &m_padding)) {
m_padding = DEFAULT_PADDING;
}
m_widget.reset(new UartWidget(path, m_padding));
}

UartDmxDevice::~UartDmxDevice() {
Expand All @@ -77,6 +83,9 @@ string UartDmxDevice::DeviceMalfKey() const {
string UartDmxDevice::DeviceBreakKey() const {
return m_path + K_BREAK;
}
string UartDmxDevice::DevicePaddingKey() const {
return m_path + K_PADDING;
}

/**
* Set the default preferences for this one Device
Expand All @@ -94,6 +103,9 @@ void UartDmxDevice::SetDefaults() {
save |= m_preferences->SetDefaultValue(DeviceMalfKey(),
UIntValidator(8, 1000000),
DEFAULT_MALF);
save |= m_preferences->SetDefaultValue(DevicePaddingKey(),
UIntValidator(24, 512),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this data slots, or including start code? I think in theory it can be less than 24 depending on frame rate etc.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is data slots. Got this number somewhere on net.
Wikipedia: However, it does require that packets be transmitted so that the leading edges of any two sequential BREAKs must be separated by at least 1204 μs, and receivers must be able to handle packets with break-to-break times as short as 1196 μs.[10] The minimum break-to-break transmit time can be achieved by sending packets that contain at least 24 slots

DEFAULT_PADDING);
if (save) {
m_preferences->Save();
}
Expand Down
4 changes: 4 additions & 0 deletions plugins/uartdmx/UartDmxDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class UartDmxDevice : public Device {
// Per device options
std::string DeviceBreakKey() const;
std::string DeviceMalfKey() const;
std::string DevicePaddingKey() const;
void SetDefaults();

std::auto_ptr<UartWidget> m_widget;
Expand All @@ -60,11 +61,14 @@ class UartDmxDevice : public Device {
const std::string m_path;
unsigned int m_breakt;
unsigned int m_malft;
unsigned int m_padding;

static const unsigned int DEFAULT_MALF;
static const char K_MALF[];
static const unsigned int DEFAULT_BREAK;
static const char K_BREAK[];
static const unsigned int DEFAULT_PADDING;
static const char K_PADDING[];

DISALLOW_COPY_AND_ASSIGN(UartDmxDevice);
};
Expand Down
8 changes: 7 additions & 1 deletion plugins/uartdmx/UartWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "ola/io/IOUtils.h"
#include "ola/Logging.h"
#include "plugins/uartdmx/UartWidget.h"
#include "plugins/uartdmx/UartDmxDevice.h"

namespace ola {
namespace plugin {
Expand All @@ -54,8 +55,9 @@ namespace uartdmx {
using std::string;
using std::vector;

UartWidget::UartWidget(const string& path)
UartWidget::UartWidget(const std::string &path, unsigned int padding)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need the std:: as we're already using string.

: m_path(path),
m_padding (padding),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align with the line above and below (and drop the space before ()

m_fd(NOT_OPEN) {
}

Expand Down Expand Up @@ -122,6 +124,10 @@ bool UartWidget::Write(const ola::DmxBuffer& data) {
buffer[0] = DMX512_START_CODE;

data.Get(buffer + 1, &length);
if (length < m_padding) {
memset ((buffer + 1 + length), 0x00, (m_padding - length) );
length = m_padding;
}

if (write(m_fd, buffer, length + 1) <= 0) {
// TODO(richardash1981): handle errors better as per the test code,
Expand Down
6 changes: 4 additions & 2 deletions plugins/uartdmx/UartWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ class UartWidget {
/**
* Construct a new UartWidget instance for one widget.
* @param path The device file path of the serial port
* @param padding Minimal DMX frame size, padded with zeros
*/
explicit UartWidget(const std::string &path);
explicit UartWidget(const std::string &path, unsigned int padding);

/** Destructor */
virtual ~UartWidget();
Expand Down Expand Up @@ -80,7 +81,8 @@ class UartWidget {
bool SetupOutput();

private:
const std::string m_path;
const std::string m_path;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you leave the indenting where it was, two in from the start of the line.

unsigned int m_padding;

/**
* variable to hold the Unix file descriptor used to open and manipulate
Expand Down
6 changes: 5 additions & 1 deletion plugins/usbpro/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ plugins_usbpro_libolausbprowidget_la_SOURCES = \
plugins/usbpro/UsbProWidgetDetector.h \
plugins/usbpro/WidgetDetectorInterface.h \
plugins/usbpro/WidgetDetectorThread.cpp \
plugins/usbpro/WidgetDetectorThread.h
plugins/usbpro/WidgetDetectorThread.h \
plugins/usbpro/UsbProExtWidget.cpp \
plugins/usbpro/UsbProExtWidget.h
plugins_usbpro_libolausbprowidget_la_LIBADD = common/libolacommon.la

if USE_USBPRO
Expand All @@ -57,6 +59,8 @@ plugins_usbpro_libolausbpro_la_SOURCES = \
plugins/usbpro/RobeDevice.h \
plugins/usbpro/UltraDMXProDevice.cpp \
plugins/usbpro/UltraDMXProDevice.h \
plugins/usbpro/UsbProExtDevice.cpp \
plugins/usbpro/UsbProExtDevice.h \
plugins/usbpro/UsbProDevice.cpp \
plugins/usbpro/UsbProDevice.h \
plugins/usbpro/UsbSerialDevice.h \
Expand Down
Loading