Skip to content
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

Added '-padding' option to uartdmx plugin. #1656

Open
wants to merge 8 commits into
base: 0.10
Choose a base branch
from

Conversation

rbalykov
Copy link

@rbalykov rbalykov commented Aug 2, 2020

Sets minimal slots count in UART frame. Default is 0, will behave as before.

Sets minimal slots count in UART frame. Default is 0, will behave as before.
Copy link
Member

@FloEdelmann FloEdelmann left a comment

Choose a reason for hiding this comment

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

Please also add the setting to the plugin README

@rbalykov
Copy link
Author

rbalykov commented Aug 4, 2020

  1. FAIL: common/network/HealthCheckedConnectionTester - do I need to fix it some way?
  2. Missing from tarball plugins/uartdmx/README.md - i've checked it out from "master", edited and commited to "0.10". Need smth else?

@peternewman
Copy link
Member

1. FAIL: common/network/HealthCheckedConnectionTester - do I need to fix it some way?

No, some of the tests area bit flaky on Mac, you can ignore this.

2. Missing from tarball plugins/uartdmx/README.md - i've checked it out from "master", edited and commited to "0.10". Need smth else?

On 0.10 the plugin description is in the code:

/**
* Return a description for this plugin.
*/
string UartDmxPlugin::Description() const {
return
"Native UART DMX Plugin\n"
"----------------------\n"

However I'd suggest if this code was to go in, that it should go in master, as it's a feature not a bug fix.

Can I ask the broader question, why? The web interface sends a full frame, any API can do so too, what's the reasoning for adding this to this plugin rather than dealing with it at source? I think the Enttec Pro's behave the same way and probably the Open's too. This would also be a perfect candidate for Patcher v2 #280.

@rbalykov
Copy link
Author

rbalykov commented Aug 4, 2020

  1. Missing from tarball plugins/uartdmx/README.md - i've checked it out from "master", edited and commited to "0.10". Need smth else?
    On 0.10 the plugin description is in the code:

So, keep README or edit in-code descriptption?
Plugin is still "Native UART", nothing has changed.

However I'd suggest if this code was to go in, that it should go in master, as it's a feature not a bug fix.
Can I ask the broader question, why?

This code fixes #1523 , I got some "hardware madness" with zero-lenght frames.
Sure, it could be fixed with ola_set_dmx, but this still gives some "broken" frames on boot.
Had another PR #1573 with same issue before, but was unfamiliar with github, so mixed two PRs in one commit. This one gives just "-padding" relates code.

@peternewman
Copy link
Member

Sorry this slipped through the net a bit.

  1. Missing from tarball plugins/uartdmx/README.md - i've checked it out from "master", edited and commited to "0.10". Need smth else?
    On 0.10 the plugin description is in the code:

So, keep README or edit in-code descriptption?
Plugin is still "Native UART", nothing has changed.

Edit the in-code description if targetting 0.10 or the README if targetting master.

However I'd suggest if this code was to go in, that it should go in master, as it's a feature not a bug fix.
Can I ask the broader question, why?

This code fixes #1523 , I got some "hardware madness" with zero-lenght frames.

Ah okay, makes sense.

Sure, it could be fixed with ola_set_dmx, but this still gives some "broken" frames on boot.

Yeah I think we're agreeing, fixing in the plugin is the most sense.

Had another PR #1573 with same issue before, but was unfamiliar with github, so mixed two PRs in one commit. This one gives just "-padding" relates code.

Great thanks.

Copy link
Member

@peternewman peternewman left a comment

Choose a reason for hiding this comment

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

Sorry this got missed before @rbalykov , thanks for your contribution, a few comments if you don't mind.

@@ -0,0 +1,34 @@
Native UART DMX Plugin
Copy link
Member

Choose a reason for hiding this comment

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

As discussed, please remove this file and edit PluginDescription if targeting 0.10.

@@ -60,11 +61,14 @@ class UartDmxDevice : public Device {
const std::string m_path;
unsigned int m_breakt;
unsigned int m_malft;
unsigned int m_paddingt;
Copy link
Member

Choose a reason for hiding this comment

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

I think the t's were timing, e..g break time, mark after last frame time, so this should probably just be m_padding.

Comment on lines 126 to +130
data.Get(buffer + 1, &length);
if (length < m_padding) {
memset((buffer + 1 + length), 0x00, (m_padding - length) );
length = m_padding;
}
Copy link
Member

Choose a reason for hiding this comment

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

Given as you've said this is probably required in a few other plugins, I wonder if it makes sense to add some extra options to DmxBuffer? e.g. GetWithPadding(uint8_t *data, unsigned int *length, unsigned int min_length). Or alternatively a Pad/Grow function which modifies the buffer in place (to save duplicating lots of functions), although the latter would need to be called on the lower level buffer in UartThread as this one is const so maybe GetWithPadding is simpler.

@@ -48,9 +48,9 @@ class UartWidget {
/**
* Construct a new UartWidget instance for one widget.
* @param path The device file path of the serial port
* @param padding Minimum DMX frame slots count, padded with NULLs
Copy link
Member

Choose a reason for hiding this comment

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

Possibly semantics, but I'd say they are zeros here, as they will be actual channel data.

@@ -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.

The std:: isn't needed here as we're using std::string

@@ -46,6 +46,7 @@
#include "ola/io/IOUtils.h"
#include "ola/Logging.h"
#include "plugins/uartdmx/UartWidget.h"
#include "plugins/uartdmx/UartDmxDevice.h"
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need this include do we?

The Mark After Last Frame time in microseconds for this device (optional).

`<device>-padding = 0` Minimal slots count in DMX frame (optional).
Default is 0, which allows empty frame. Using minimal timing, frame period reaches 140 microseconds, while standard requires minimum 1204us. Using BREAK=88us and MAB=8us, frame has to include 25 slots, that gives frame period 1240us.
Copy link
Member

Choose a reason for hiding this comment

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

If you're feeling particularly keen, it would be really nice on initialisation to print an OLA_INFO with the minimum padding value (based on break/MAB/MALF), or even an OLA_WARN if the configured padding is insufficient!

@peternewman peternewman added this to the 0.10.9 milestone Dec 6, 2022
@peternewman peternewman linked an issue Dec 6, 2022 that may be closed by this pull request
@peternewman peternewman modified the milestones: 0.10.9, 0.10.10 Feb 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

wrong output mode (UART-DMX, but affects virtually elsewhere)
3 participants