Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/openlightingproject/ola i…
Browse files Browse the repository at this point in the history
…nto ipv6-type
  • Loading branch information
peternewman committed Oct 23, 2023
2 parents 88cabc9 + 8556eea commit 3315b64
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 84 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ jobs:
run: apt-get update -y
# See comments beginning at
# https://github.com/actions/runner/issues/763#issuecomment-1435474884
# Without Git, actions/checkout@v3 will resort to REST and will not
# Without Git, actions/checkout@v4 will resort to REST and will not
# create a .git folder or .git.config. The Problem Matcher looks for
# .git/config to find where the root of the repo is, so it must be
# present.
- name: Install Git
run: apt-get -y install git
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install build tools
shell: bash
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ jobs:
run: apt-get update -y
# See comments beginning at
# https://github.com/actions/runner/issues/763#issuecomment-1435474884
# Without Git, actions/checkout@v3 will resort to REST and will not
# Without Git, actions/checkout@v4 will resort to REST and will not
# create a .git folder or .git.config. The Problem Matcher looks for
# .git/config to find where the root of the repo is, so it must be
# present.
- name: Install Git
run: apt-get -y install git
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install build tools
run: apt-get -y install devscripts adduser fakeroot sudo
- name: Install build dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/isort.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ jobs:
isort:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: isort/isort-action@v1
6 changes: 3 additions & 3 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ jobs:
run: apt-get update -y
# See comments beginning at
# https://github.com/actions/runner/issues/763#issuecomment-1435474884
# Without Git, actions/checkout@v3 will resort to REST and will not
# Without Git, actions/checkout@v4 will resort to REST and will not
# create a .git folder or .git.config. The Problem Matcher looks for
# .git/config to find where the root of the repo is, so it must be
# present.
- name: Install Git
run: apt-get -y install git
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install build tools
shell: bash
run: |
Expand Down Expand Up @@ -260,7 +260,7 @@ jobs:
name: weblint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Node.js v18
uses: actions/setup-node@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion common/rpc/RpcChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void RpcChannel::DescriptorReady() {
m_buffer_size = AllocateMsgBuffer(m_expected_size);

if (m_buffer_size < m_expected_size) {
OLA_WARN << "buffer size to small " << m_buffer_size << " < " <<
OLA_WARN << "buffer size too small: " << m_buffer_size << " < " <<
m_expected_size;
return;
}
Expand Down
23 changes: 19 additions & 4 deletions examples/ola-client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ typedef struct {
string cmd; // argv[0]
string uni_name; // universe name
string dmx; // DMX string
bool blackout;
ola::port_priority_mode priority_mode; // port priority mode
uint8_t priority_value; // port priority value
bool list_plugin_ids;
Expand Down Expand Up @@ -304,6 +305,7 @@ void InitOptions(options *opts) {
opts->port_direction = ola::client::OUTPUT_PORT;
opts->device_id = INVALID_VALUE;
opts->merge_mode = OlaUniverse::MERGE_HTP;
opts->blackout = false;
opts->priority_mode = ola::PRIORITY_MODE_INHERIT;
opts->priority_value = 0;
}
Expand Down Expand Up @@ -358,6 +360,7 @@ void ParseOptions(int argc, char *argv[], options *opts) {

static struct option long_options[] = {
{"dmx", required_argument, 0, 'd'},
{"blackout", no_argument, 0, 'b'},
{"help", no_argument, 0, 'h'},
{"ltp", no_argument, 0, 'l'},
{"name", required_argument, 0, 'n'},
Expand All @@ -373,7 +376,7 @@ void ParseOptions(int argc, char *argv[], options *opts) {
int option_index = 0;

while (1) {
c = getopt_long(argc, argv, "ld:n:u:p:s:hv", long_options, &option_index);
c = getopt_long(argc, argv, "ld:bn:u:p:s:hv", long_options, &option_index);

if (c == -1)
break;
Expand All @@ -384,6 +387,9 @@ void ParseOptions(int argc, char *argv[], options *opts) {
case 'd':
opts->dmx = optarg;
break;
case 'b':
opts->blackout = true;
break;
case 'h':
opts->help = true;
break;
Expand Down Expand Up @@ -656,7 +662,8 @@ void DisplayUniverseMergeHelp(const options &opts) {
* Help message for set dmx
*/
void DisplaySetDmxHelp(const options &opts) {
cout << "Usage: " << opts.cmd << " --universe <universe> --dmx <values>\n"
cout << "Usage: " << opts.cmd << " --universe <universe> [ --dmx <values> ] "
"[ --blackout ]\n"
"\n"
"Sets the DMX values for a universe.\n"
"\n"
Expand All @@ -665,6 +672,7 @@ void DisplaySetDmxHelp(const options &opts) {
" -d, --dmx <values> Comma separated DMX values, e.g. "
"0,255,128 sets first channel to 0, second channel to 255"
" and third channel to 128.\n"
" -b, --blackout Send a universe to blackout instead.\n"
<< endl;
}

Expand Down Expand Up @@ -857,9 +865,16 @@ int SendDmx(OlaClientWrapper *wrapper, const options &opts) {
SelectServer *ss = wrapper->GetSelectServer();
OlaClient *client = wrapper->GetClient();
ola::DmxBuffer buffer;
bool status = buffer.SetFromString(opts.dmx);
bool status = false;
if (opts.blackout) {
status = buffer.Blackout();
} else {
status = buffer.SetFromString(opts.dmx);
}

if (opts.uni < 0 || !status || buffer.Size() == 0) {
// A dmx string and blackout are mutually exclusive
if (opts.uni < 0 || !status || (opts.blackout && !opts.dmx.empty()) ||
buffer.Size() == 0) {
DisplaySetDmxHelp(opts);
exit(1);
}
Expand Down
70 changes: 41 additions & 29 deletions libs/acn/DMPE131Inflator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ bool DMPE131Inflator::HandlePDUData(uint32_t vector,
return true;
}

if (universe_iter == m_handlers.end())
if (universe_iter == m_handlers.end()) {
return true;
}

DMPHeader dmp_header = headers.GetDMPHeader();

Expand Down Expand Up @@ -104,16 +105,17 @@ bool DMPE131Inflator::HandlePDUData(uint32_t vector,

if (address->Increment() != 1) {
OLA_INFO << "E1.31 DMP packet with increment " << address->Increment()
<< ", disarding";
<< ", disarding";
return true;
}

unsigned int length_remaining = pdu_len - available_length;
int start_code = -1;
if (e131_header.UsingRev2())
if (e131_header.UsingRev2()) {
start_code = static_cast<int>(address->Start());
else if (length_remaining && address->Number())
} else if (length_remaining && address->Number()) {
start_code = *(data + available_length);
}

// The only time we want to continue processing a non-0 start code is if it
// contains a Terminate message.
Expand All @@ -132,14 +134,16 @@ bool DMPE131Inflator::HandlePDUData(uint32_t vector,
// Reaching here means that we actually have new data and we should merge.
if (target_buffer && start_code == 0) {
unsigned int channels = std::min(length_remaining, address->Number());
if (e131_header.UsingRev2())
if (e131_header.UsingRev2()) {
target_buffer->Set(data + available_length, channels);
else
target_buffer->Set(data + available_length + 1, channels - 1);
} else {
target_buffer->Set(data + available_length + 1, channels - 1);
}
}

if (universe_iter->second.priority)
if (universe_iter->second.priority) {
*universe_iter->second.priority = universe_iter->second.active_priority;
}

// merge the sources
switch (universe_iter->second.sources.size()) {
Expand All @@ -155,9 +159,11 @@ bool DMPE131Inflator::HandlePDUData(uint32_t vector,
// HTP Merge
universe_iter->second.buffer->Reset();
std::vector<dmx_source>::const_iterator source_iter =
universe_iter->second.sources.begin();
for (; source_iter != universe_iter->second.sources.end(); ++source_iter)
universe_iter->second.sources.begin();
for (; source_iter != universe_iter->second.sources.end();
++source_iter) {
universe_iter->second.buffer->HTPMerge(source_iter->buffer);
}
universe_iter->second.closure->Run();
}
return true;
Expand All @@ -175,8 +181,9 @@ bool DMPE131Inflator::SetHandler(uint16_t universe,
ola::DmxBuffer *buffer,
uint8_t *priority,
ola::Callback0<void> *closure) {
if (!closure || !buffer)
if (!closure || !buffer) {
return false;
}

UniverseHandlers::iterator iter = m_handlers.find(universe);

Expand Down Expand Up @@ -265,38 +272,41 @@ bool DMPE131Inflator::TrackSourceIfRequired(
iter++;
}

if (sources.empty())
if (sources.empty()) {
universe_data->active_priority = 0;
}

for (iter = sources.begin(); iter != sources.end(); ++iter) {
if (iter->cid == headers.GetRootHeader().GetCid())
if (iter->cid == headers.GetRootHeader().GetCid()) {
break;
}
}

if (iter == sources.end()) {
// This is an untracked source
if (e131_header.StreamTerminated() ||
priority < universe_data->active_priority)
priority < universe_data->active_priority) {
return false;
}

if (priority > universe_data->active_priority) {
OLA_INFO << "Raising priority for universe " <<
e131_header.Universe() << " from " <<
static_cast<int>(universe_data->active_priority) << " to " <<
static_cast<int>(priority);
OLA_INFO << "Raising priority for universe " << e131_header.Universe()
<< " from " << static_cast<int>(universe_data->active_priority)
<< " to " << static_cast<int>(priority);
sources.clear();
universe_data->active_priority = priority;
}

if (sources.size() == MAX_MERGE_SOURCES) {
// TODO(simon): flag this in the export map
OLA_WARN << "Max merge sources reached for universe " <<
e131_header.Universe() << ", " <<
headers.GetRootHeader().GetCid().ToString() << " won't be tracked";
OLA_WARN << "Max merge sources reached for universe "
<< e131_header.Universe() << ", "
<< headers.GetRootHeader().GetCid().ToString()
<< " won't be tracked";
return false;
} else {
OLA_INFO << "Added new E1.31 source: " <<
headers.GetRootHeader().GetCid().ToString();
OLA_INFO << "Added new E1.31 source: "
<< headers.GetRootHeader().GetCid().ToString();
dmx_source new_source;
new_source.cid = headers.GetRootHeader().GetCid();
new_source.sequence = e131_header.Sequence();
Expand All @@ -311,19 +321,21 @@ bool DMPE131Inflator::TrackSourceIfRequired(
int8_t seq_diff = static_cast<int8_t>(e131_header.Sequence() -
iter->sequence);
if (seq_diff <= 0 && seq_diff > SEQUENCE_DIFF_THRESHOLD) {
OLA_INFO << "Old packet received, ignoring, this # " <<
static_cast<int>(e131_header.Sequence()) << ", last " <<
static_cast<int>(iter->sequence);
OLA_INFO << "Old packet received, ignoring, this # "
<< static_cast<int>(e131_header.Sequence()) << ", last "
<< static_cast<int>(iter->sequence);
return false;
}
iter->sequence = e131_header.Sequence();

if (e131_header.StreamTerminated()) {
OLA_INFO << "CID " << headers.GetRootHeader().GetCid().ToString() <<
" sent a termination for universe " << e131_header.Universe();
OLA_INFO << "CID " << headers.GetRootHeader().GetCid().ToString()
<< " sent a termination for universe "
<< e131_header.Universe();
sources.erase(iter);
if (sources.empty())
if (sources.empty()) {
universe_data->active_priority = 0;
}
// We need to trigger a merge here else the buffer will be stale, we keep
// the buffer as NULL though so we don't use the data.
return true;
Expand Down
Loading

0 comments on commit 3315b64

Please sign in to comment.