From d4414feefd95adf9c91d7eaf1e94380296c35f7a Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Fri, 7 Jul 2023 15:57:35 +0100 Subject: [PATCH 01/56] Fix protoc version checking, since v20.x (cherry picked from commit 2e55aa88756718d8ab4a4c8fde97d620542c2c98) --- config/ola.m4 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/config/ola.m4 b/config/ola.m4 index f838ab70ad..51b6c825c6 100644 --- a/config/ola.m4 +++ b/config/ola.m4 @@ -44,7 +44,14 @@ if test -z "$PROTOC" ; then AC_MSG_ERROR([cannot find 'protoc' program]); elif test -n "$1" ; then AC_MSG_CHECKING([protoc version]) - [protoc_version=`$PROTOC --version 2>&1 | grep 'libprotoc' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`] + # Since v20.x we only get effectively the minor and patch versions out of protoc. + # Treat them as major and minor and everything should keep working indefinitely. + # See https://protobuf.dev/support/version-support/ + # So we've got either of these: + # libprotoc 2.4.1 + # libprotoc 23.3 + # The first sed ensures all versions have major, minor, patch, by adding a .0 on the end of ones missing it + [protoc_version=`$PROTOC --version 2>&1 | grep 'libprotoc' | sed 's/\([^\.0-9][0-9][0-9]*\.[0-9][0-9]*\)$/\1\.0/g' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`] [required=$1] [required_major=`echo $required | sed 's/[^0-9].*//'`] [required_minor=`echo $required | sed 's/[0-9][0-9]*\.\([0-9][0-9]*\)\.[0-9][0-9]*/\1/'`] From 546d9ee8d970c4e5b33d9d28b4acf6eb34f27a5d Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Fri, 7 Jul 2023 16:14:21 +0100 Subject: [PATCH 02/56] Protoc check - correctly match multi-digit major versions (cherry picked from commit 69a2946622cdfce54cb6ed7f2210df2be0ec5576) --- config/ola.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/ola.m4 b/config/ola.m4 index 51b6c825c6..eacee5d94f 100644 --- a/config/ola.m4 +++ b/config/ola.m4 @@ -51,7 +51,7 @@ elif test -n "$1" ; then # libprotoc 2.4.1 # libprotoc 23.3 # The first sed ensures all versions have major, minor, patch, by adding a .0 on the end of ones missing it - [protoc_version=`$PROTOC --version 2>&1 | grep 'libprotoc' | sed 's/\([^\.0-9][0-9][0-9]*\.[0-9][0-9]*\)$/\1\.0/g' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`] + [protoc_version=`$PROTOC --version 2>&1 | grep 'libprotoc' | sed 's/\([^\.0-9][0-9][0-9]*\.[0-9][0-9]*\)$/\1\.0/g' | sed 's/[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`] [required=$1] [required_major=`echo $required | sed 's/[^0-9].*//'`] [required_minor=`echo $required | sed 's/[0-9][0-9]*\.\([0-9][0-9]*\)\.[0-9][0-9]*/\1/'`] From 7e8325fac718db218b8d1f9fec89702ce4b80119 Mon Sep 17 00:00:00 2001 From: Perry Naseck Date: Tue, 11 Jul 2023 17:06:24 -0400 Subject: [PATCH 03/56] fix codespell typos --- common/io/IOStackTest.cpp | 2 +- common/io/PollerInterface.h | 2 +- include/ola/rdm/RDMControllerInterface.h | 4 ++-- include/ola/web/JsonTypes.h | 2 +- python/ola/OlaClient.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/io/IOStackTest.cpp b/common/io/IOStackTest.cpp index c2ce9935b0..8563f9892a 100644 --- a/common/io/IOStackTest.cpp +++ b/common/io/IOStackTest.cpp @@ -207,7 +207,7 @@ void IOStackTest::testAppendToQueue() { } /** - * Confirm we re-use blocks + * Confirm we reuse blocks */ void IOStackTest::testBlockReuse() { MemoryBlockPool pool(4); diff --git a/common/io/PollerInterface.h b/common/io/PollerInterface.h index 003106f3b3..cde0f2c39b 100644 --- a/common/io/PollerInterface.h +++ b/common/io/PollerInterface.h @@ -51,7 +51,7 @@ namespace io { * reentrant. Calling any of the read / write / close actions may in turn add / * remove descriptors, including the descriptor the method was itself called * on. There are tests in SelectServerTest.cpp to exercise some of these cases - * but implementors need to be careful. + * but implementers need to be careful. * * @warning * For example, if Poll() iterates over a set of Descriptors and calls diff --git a/include/ola/rdm/RDMControllerInterface.h b/include/ola/rdm/RDMControllerInterface.h index 8ddff1e049..564c20ea88 100644 --- a/include/ola/rdm/RDMControllerInterface.h +++ b/include/ola/rdm/RDMControllerInterface.h @@ -79,12 +79,12 @@ class RDMControllerInterface { * @param request the RDMRequest, ownership is transferred. * @param on_complete The callback to run when the request completes. * - * Implementors much ensure that the callback is always run at some point. + * Implementers much ensure that the callback is always run at some point. * In other words, there must be no way that a request can be dropped in such * a way that the callback is never run. Doing so will either block all * subsequent requests, or leak memory depending on the implementation. * - * Also the implementor of this class may want to re-write the transaction #, + * Also the implementer of this class may want to re-write the transaction #, * and possibly the UID (changing src UIDs isn't addressed by the RDM * spec). * diff --git a/include/ola/web/JsonTypes.h b/include/ola/web/JsonTypes.h index 2477fbecdd..b05fd0e1f9 100644 --- a/include/ola/web/JsonTypes.h +++ b/include/ola/web/JsonTypes.h @@ -23,7 +23,7 @@ * @addtogroup json * @{ * @file JsonTypes.h - * @brief Enums used to identfy JSON types. + * @brief Enums used to identify JSON types. * @} */ diff --git a/python/ola/OlaClient.py b/python/ola/OlaClient.py index 47e8dfa41c..f10eb4f0db 100644 --- a/python/ola/OlaClient.py +++ b/python/ola/OlaClient.py @@ -1345,7 +1345,7 @@ def GetCandidatePorts(self, callback, universe=None): request.universe = universe try: - # GetCandidatePorts works very much like GetDeviceInfo, so we can re-use + # GetCandidatePorts works very much like GetDeviceInfo, so we can reuse # its complete method. self._stub.GetCandidatePorts( controller, request, From 7e79607c19aea8acba4d4984d780ab327e7f30d9 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Tue, 18 Jul 2023 04:15:16 +0100 Subject: [PATCH 04/56] Fix distcheck configure args --- .github/workflows/build.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 554baa985f..d41e260dec 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -92,11 +92,19 @@ jobs: - name: Set configure arguments run: | echo "GH_OLA_CONFIGURE_ARGS=${{ matrix.configure-args }}" >> $GITHUB_ENV + - name: Set distcheck configure arguments + if: matrix.task == 'distcheck' + run: | + echo "DISTCHECK_CONFIGURE_FLAGS=${{ matrix.configure-args }}" >> $GITHUB_ENV - name: Set additional Linux configure arguments if: runner.os == 'Linux' # Silence all deprecated declarations on Linux due to auto_ptr making the build log too long run: | echo "GH_OLA_CONFIGURE_ARGS=$GH_OLA_CONFIGURE_ARGS CPPFLAGS=-Wno-deprecated-declarations" >> $GITHUB_ENV + - name: Set additional Linux distcheck configure arguments + if: matrix.task == 'distcheck' + run: | + echo "DISTCHECK_CONFIGURE_FLAGS=${{ matrix.configure-args }} CPPFLAGS=-Wno-deprecated-declarations" >> $GITHUB_ENV - name: Print configure command run: echo "./configure $GH_OLA_CONFIGURE_ARGS" - name: Configure From 38bd9de6638abb504326c6e4f2062b46beffa5db Mon Sep 17 00:00:00 2001 From: Perry Naseck Date: Wed, 26 Jul 2023 16:31:03 -0400 Subject: [PATCH 05/56] fix ci java build using correct autotools env var (closes #1883) --- .github/workflows/build.yaml | 11 ++++------- .travis-ci.sh | 1 + 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d41e260dec..9b68ec257d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -90,25 +90,22 @@ jobs: - name: Autoreconf run: sudo --preserve-env -u builduser env "PATH=$PATH" autoreconf -i - name: Set configure arguments - run: | - echo "GH_OLA_CONFIGURE_ARGS=${{ matrix.configure-args }}" >> $GITHUB_ENV - - name: Set distcheck configure arguments - if: matrix.task == 'distcheck' + # Env var name DISTCHECK_CONFIGURE_FLAGS must be used, see #1881 and #1883 run: | echo "DISTCHECK_CONFIGURE_FLAGS=${{ matrix.configure-args }}" >> $GITHUB_ENV - name: Set additional Linux configure arguments if: runner.os == 'Linux' # Silence all deprecated declarations on Linux due to auto_ptr making the build log too long run: | - echo "GH_OLA_CONFIGURE_ARGS=$GH_OLA_CONFIGURE_ARGS CPPFLAGS=-Wno-deprecated-declarations" >> $GITHUB_ENV + echo "DISTCHECK_CONFIGURE_FLAGS=$DISTCHECK_CONFIGURE_FLAGS CPPFLAGS=-Wno-deprecated-declarations" >> $GITHUB_ENV - name: Set additional Linux distcheck configure arguments if: matrix.task == 'distcheck' run: | echo "DISTCHECK_CONFIGURE_FLAGS=${{ matrix.configure-args }} CPPFLAGS=-Wno-deprecated-declarations" >> $GITHUB_ENV - name: Print configure command - run: echo "./configure $GH_OLA_CONFIGURE_ARGS" + run: echo "./configure $DISTCHECK_CONFIGURE_FLAGS" - name: Configure - run: sudo --preserve-env -u builduser env "PATH=$PATH" ./configure $GH_OLA_CONFIGURE_ARGS + run: sudo --preserve-env -u builduser env "PATH=$PATH" ./configure $DISTCHECK_CONFIGURE_FLAGS - name: ${{ matrix.task }} run: sudo --preserve-env -u builduser env "PATH=$PATH" make ${{ matrix.task }} -j${{ steps.num-cpu-cores.outputs.NUM_CPU_CORES }} VERBOSE=1 - name: Display structure of the built files diff --git a/.travis-ci.sh b/.travis-ci.sh index fc9bd59e79..f76f7b72e5 100755 --- a/.travis-ci.sh +++ b/.travis-ci.sh @@ -232,6 +232,7 @@ elif [[ $TASK = 'flake8' ]]; then make flake8 else # Otherwise compile and check as normal + # Env var name DISTCHECK_CONFIGURE_FLAGS must be used, see #1881 and #1883 if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then # Silence all deprecated declarations on Linux due to auto_ptr making the build log too long export DISTCHECK_CONFIGURE_FLAGS='--enable-rdm-tests --enable-ja-rule --enable-e133 CPPFLAGS=-Wno-deprecated-declarations' From b153941f80f814c5d38173f76d2d61735a4cfcfa Mon Sep 17 00:00:00 2001 From: Perry Naseck Date: Thu, 27 Jul 2023 10:09:35 -0400 Subject: [PATCH 06/56] fix codespell typos --- README.developer | 2 +- plugins/artnet/ArtNetNodeTest.cpp | 106 +++++++++++++++--------------- tools/rdm/rdm_test_server.py | 2 +- 3 files changed, 55 insertions(+), 55 deletions(-) diff --git a/README.developer b/README.developer index e989e800df..309ad07a92 100644 --- a/README.developer +++ b/README.developer @@ -55,7 +55,7 @@ The release lifecycle is: - New feature work occurs on the master branch. - Once the new features are considered stable or enough time has passed, a new minor release branch will be created, e.g. 0.10. -- The minor release branch will be stablized with bugfixes, these bug fixes +- The minor release branch will be stabilized with bugfixes, these bug fixes will also be merged back into master. - Once declared stable, a new patch branch 0 will be created e.g. 0.10.0 - Release specific changes like the version number, debian files etc. will be diff --git a/plugins/artnet/ArtNetNodeTest.cpp b/plugins/artnet/ArtNetNodeTest.cpp index 16960da26c..53b62350f1 100644 --- a/plugins/artnet/ArtNetNodeTest.cpp +++ b/plugins/artnet/ArtNetNodeTest.cpp @@ -211,7 +211,7 @@ class ArtNetNodeTest: public CppUnit::TestFixture { // This sends a tod data so 7s70:00000000 is insert into the tod void PopulateTod() { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); const uint8_t art_tod[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x81, @@ -646,7 +646,7 @@ void ArtNetNodeTest::testBroadcastSendDMX() { m_socket->SetDiscardMode(false); { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); const uint8_t DMX_MESSAGE[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x50, @@ -666,7 +666,7 @@ void ArtNetNodeTest::testBroadcastSendDMX() { // send an odd sized dmx frame, we should pad this to a multiple of two { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); const uint8_t DMX_MESSAGE2[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x50, @@ -684,14 +684,14 @@ void ArtNetNodeTest::testBroadcastSendDMX() { } { // attempt to send on a invalid port - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); DmxBuffer dmx; dmx.SetFromString("0,1,2,3,4"); OLA_ASSERT_FALSE(node.SendDMX(4, dmx)); } { // attempt to send an empty fram - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); DmxBuffer empty_buffer; OLA_ASSERT(node.SendDMX(m_port_id, empty_buffer)); } @@ -717,7 +717,7 @@ void ArtNetNodeTest::testBroadcastSendDMXZeroUniverse() { m_socket->SetDiscardMode(false); { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); const uint8_t DMX_MESSAGE[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x50, @@ -781,7 +781,7 @@ void ArtNetNodeTest::testBroadcastSendDMXZeroUniverse() { } { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); const uint8_t DMX_MESSAGE[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x50, @@ -818,7 +818,7 @@ void ArtNetNodeTest::testLimitedBroadcastDMX() { m_socket->SetDiscardMode(false); { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); const uint8_t DMX_MESSAGE[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x50, @@ -861,7 +861,7 @@ void ArtNetNodeTest::testNonBroadcastSendDMX() { vector node_addresses; { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); const uint8_t poll_reply_message[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x21, @@ -926,7 +926,7 @@ void ArtNetNodeTest::testNonBroadcastSendDMX() { // add another peer { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); const uint8_t poll_reply_message2[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x21, @@ -980,7 +980,7 @@ void ArtNetNodeTest::testNonBroadcastSendDMX() { // send another DMX frame, this should get unicast twice { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); const uint8_t DMX_MESSAGE2[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x50, @@ -999,7 +999,7 @@ void ArtNetNodeTest::testNonBroadcastSendDMX() { // adjust the broadcast threshold { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); node.SetBroadcastThreshold(2); // send another DMX frame, this should get broadcast @@ -1050,7 +1050,7 @@ void ArtNetNodeTest::testReceiveDMX() { // 'receive' a DMX message { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); OLA_ASSERT_FALSE(m_got_dmx); ReceiveFromPeer(DMX_MESSAGE, sizeof(DMX_MESSAGE), peer_ip); OLA_ASSERT(m_got_dmx); @@ -1059,7 +1059,7 @@ void ArtNetNodeTest::testReceiveDMX() { // send a second frame { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); uint8_t DMX_MESSAGE2[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x50, @@ -1079,7 +1079,7 @@ void ArtNetNodeTest::testReceiveDMX() { // advance the clock by more than the merge timeout (10s) { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); m_clock.AdvanceTime(11, 0); // send another message, but first update the seq # @@ -1128,7 +1128,7 @@ void ArtNetNodeTest::testReceiveDMXZeroUniverse() { 0, 6, // dmx length 0, 1, 2, 3, 4, 5 }; - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); OLA_ASSERT_FALSE(m_got_dmx); ReceiveFromPeer(DMX_MESSAGE, sizeof(DMX_MESSAGE), peer_ip); OLA_ASSERT(m_got_dmx); @@ -1158,7 +1158,7 @@ void ArtNetNodeTest::testReceiveDMXZeroUniverse() { 0, 4, // dmx length 10, 11, 12, 13 }; - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); OLA_ASSERT_FALSE(m_got_dmx); ReceiveFromPeer(DMX_MESSAGE, sizeof(DMX_MESSAGE), peer_ip); OLA_ASSERT(m_got_dmx); @@ -1186,7 +1186,7 @@ void ArtNetNodeTest::testHTPMerge() { // 'receive' a DMX message from the first peer { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); uint8_t source1_message1[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x50, @@ -1206,7 +1206,7 @@ void ArtNetNodeTest::testHTPMerge() { // receive a message from a second peer { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); uint8_t source2_message1[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x50, @@ -1267,7 +1267,7 @@ void ArtNetNodeTest::testHTPMerge() { // send a packet from a third source, this shouldn't result in any new dmx { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); const uint8_t source3_message1[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x50, @@ -1287,7 +1287,7 @@ void ArtNetNodeTest::testHTPMerge() { // send another packet from the first source { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); uint8_t source1_message2[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x50, @@ -1312,7 +1312,7 @@ void ArtNetNodeTest::testHTPMerge() { // send another packet from the first source { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); uint8_t source1_message3[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x50, @@ -1337,7 +1337,7 @@ void ArtNetNodeTest::testHTPMerge() { // send another packet from the first source { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); uint8_t source1_message4[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x50, @@ -1379,7 +1379,7 @@ void ArtNetNodeTest::testLTPMerge() { // switch to LTP merge mode, this will trigger an art poll reply { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); uint8_t poll_reply_message[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x21, @@ -1422,7 +1422,7 @@ void ArtNetNodeTest::testLTPMerge() { // 'receive' a DMX message from the first peer { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); uint8_t source1_message1[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x50, @@ -1442,7 +1442,7 @@ void ArtNetNodeTest::testLTPMerge() { // receive a message from a second peer { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); uint8_t source2_message1[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x50, @@ -1506,7 +1506,7 @@ void ArtNetNodeTest::testLTPMerge() { // send another packet from the first source { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); uint8_t source1_message2[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x50, @@ -1547,7 +1547,7 @@ void ArtNetNodeTest::testControllerDiscovery() { // send a tod control { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); ExpectedBroadcast(TOD_CONTROL, sizeof(TOD_CONTROL)); node.RunFullDiscovery( m_port_id, @@ -1557,7 +1557,7 @@ void ArtNetNodeTest::testControllerDiscovery() { // advance the clock and run the select server { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); m_clock.AdvanceTime(5, 0); // tod timeout is 4s ss.RunOnce(); // update the wake up time OLA_ASSERT(m_discovery_done); @@ -1568,7 +1568,7 @@ void ArtNetNodeTest::testControllerDiscovery() { // run discovery again, this time returning a ArtTod from a peer { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); m_discovery_done = false; ExpectedBroadcast(TOD_CONTROL, sizeof(TOD_CONTROL)); @@ -1602,7 +1602,7 @@ void ArtNetNodeTest::testControllerDiscovery() { // advance the clock and run the select server { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); m_clock.AdvanceTime(5, 0); // tod timeout is 4s ss.RunOnce(); // update the wake up time OLA_ASSERT(m_discovery_done); @@ -1617,7 +1617,7 @@ void ArtNetNodeTest::testControllerDiscovery() { // run discovery again, removing one UID, and moving another from peer1 // to peer2 { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); m_discovery_done = false; ExpectedBroadcast(TOD_CONTROL, sizeof(TOD_CONTROL)); @@ -1668,7 +1668,7 @@ void ArtNetNodeTest::testControllerDiscovery() { // advance the clock and run the select server { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); m_clock.AdvanceTime(5, 0); // tod timeout is 4s ss.RunOnce(); // update the wake up time OLA_ASSERT(m_discovery_done); @@ -1681,7 +1681,7 @@ void ArtNetNodeTest::testControllerDiscovery() { // try running discovery for a invalid port id { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); m_discovery_done = false; node.RunFullDiscovery( 4, @@ -1708,7 +1708,7 @@ void ArtNetNodeTest::testControllerIncrementalDiscovery() { // send a tod request { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); const uint8_t tod_request[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x80, @@ -1733,7 +1733,7 @@ void ArtNetNodeTest::testControllerIncrementalDiscovery() { // respond with a tod { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); const uint8_t art_tod1[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x81, @@ -1766,7 +1766,7 @@ void ArtNetNodeTest::testControllerIncrementalDiscovery() { // try running discovery for a invalid port id { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); m_discovery_done = false; node.RunIncrementalDiscovery( 4, @@ -1797,7 +1797,7 @@ void ArtNetNodeTest::testUnsolicitedTod() { // receive a tod { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); OLA_ASSERT_FALSE(m_discovery_done); // receive a ArtTod @@ -1848,7 +1848,7 @@ void ArtNetNodeTest::testResponderDiscovery() { // receive a tod request { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); const uint8_t tod_request[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x80, @@ -1870,7 +1870,7 @@ void ArtNetNodeTest::testResponderDiscovery() { // respond with a Tod { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); const uint8_t art_tod1[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x81, @@ -1897,7 +1897,7 @@ void ArtNetNodeTest::testResponderDiscovery() { // try a tod request a universe that doesn't match ours { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); m_tod_request = false; const uint8_t tod_request2[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, @@ -1920,7 +1920,7 @@ void ArtNetNodeTest::testResponderDiscovery() { // check TodControl { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); OLA_ASSERT_FALSE(m_tod_flush); const uint8_t tod_control[] = { @@ -1940,7 +1940,7 @@ void ArtNetNodeTest::testResponderDiscovery() { // try a tod control a universe that doesn't match ours { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); m_tod_flush = false; OLA_ASSERT_FALSE(m_tod_flush); const uint8_t tod_control2[] = { @@ -1980,7 +1980,7 @@ void ArtNetNodeTest::testRDMResponder() { ola::NewCallback(this, &ArtNetNodeTest::HandleRDM))); { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); const uint8_t rdm_request[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x83, @@ -2026,7 +2026,7 @@ void ArtNetNodeTest::testRDMResponder() { // run the RDM callback, triggering the response { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); const uint8_t rdm_response[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x83, @@ -2079,7 +2079,7 @@ void ArtNetNodeTest::testRDMRequest() { // create a new RDM request { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); SendRDMRequest( &node, ola::NewSingleCallback(this, &ArtNetNodeTest::FinalizeRDM)); @@ -2087,7 +2087,7 @@ void ArtNetNodeTest::testRDMRequest() { // send a response { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); const uint8_t rdm_response[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x83, @@ -2133,7 +2133,7 @@ void ArtNetNodeTest::testRDMRequestTimeout() { // create a new RDM request { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); SendRDMRequest( &node, ola::NewSingleCallback(this, &ArtNetNodeTest::ExpectTimeout)); @@ -2163,7 +2163,7 @@ void ArtNetNodeTest::testRDMRequestIPMismatch() { // create a new RDM request { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); SendRDMRequest( &node, ola::NewSingleCallback(this, &ArtNetNodeTest::ExpectTimeout)); @@ -2171,7 +2171,7 @@ void ArtNetNodeTest::testRDMRequestIPMismatch() { // send a response from a different IP { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); const uint8_t rdm_response[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x83, @@ -2220,7 +2220,7 @@ void ArtNetNodeTest::testRDMRequestUIDMismatch() { // create a new RDM request { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); SendRDMRequest( &node, ola::NewSingleCallback(this, &ArtNetNodeTest::ExpectTimeout)); @@ -2228,7 +2228,7 @@ void ArtNetNodeTest::testRDMRequestUIDMismatch() { // send a response from a different IP { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); const uint8_t rdm_response[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x83, @@ -2273,7 +2273,7 @@ void ArtNetNodeTest::testTimeCode() { m_socket->SetDiscardMode(false); { - SocketVerifier verifer(m_socket); + SocketVerifier verifier(m_socket); const uint8_t timecode_message[] = { 'A', 'r', 't', '-', 'N', 'e', 't', 0x00, 0x00, 0x97, diff --git a/tools/rdm/rdm_test_server.py b/tools/rdm/rdm_test_server.py index 742768d991..b8196d8424 100755 --- a/tools/rdm/rdm_test_server.py +++ b/tools/rdm/rdm_test_server.py @@ -834,7 +834,7 @@ def _CheckValidUniverse(self, request): request: the HTTPRequest object. Returns: - The santitized universe id. + The sanitized universe id. Raises: ServerException if the universe isn't valid or doesn't exist. From 514b05ab4101ab28137a6c92a5de37b10e607986 Mon Sep 17 00:00:00 2001 From: Perry Naseck <4472083+DaAwesomeP@users.noreply.github.com> Date: Thu, 27 Jul 2023 10:14:41 -0400 Subject: [PATCH 07/56] github actions build remove redundant condfigure flags Co-authored-by: Peter Newman --- .github/workflows/build.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9b68ec257d..1f1ffa9130 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -98,10 +98,6 @@ jobs: # Silence all deprecated declarations on Linux due to auto_ptr making the build log too long run: | echo "DISTCHECK_CONFIGURE_FLAGS=$DISTCHECK_CONFIGURE_FLAGS CPPFLAGS=-Wno-deprecated-declarations" >> $GITHUB_ENV - - name: Set additional Linux distcheck configure arguments - if: matrix.task == 'distcheck' - run: | - echo "DISTCHECK_CONFIGURE_FLAGS=${{ matrix.configure-args }} CPPFLAGS=-Wno-deprecated-declarations" >> $GITHUB_ENV - name: Print configure command run: echo "./configure $DISTCHECK_CONFIGURE_FLAGS" - name: Configure From 50de3e82075cfcaaaa062b9865086913b1c85067 Mon Sep 17 00:00:00 2001 From: Perry Naseck Date: Thu, 27 Jul 2023 10:16:41 -0400 Subject: [PATCH 08/56] github actions build disable java for now --- .github/workflows/build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1f1ffa9130..fb0bfe819e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -21,7 +21,7 @@ jobs: pkg: "gcc g++" - id: "distcheck-debian-stable-amd64-gcc" task: "distcheck" - configure-args: "--enable-ja-rule --enable-e133 --enable-rdm-tests --enable-java-libs" + configure-args: "--enable-ja-rule --enable-e133 --enable-rdm-tests" # TODO(Perry): Fix Debian 12 OOM issue on GitHub Actions container: "debian:stable" compiler: @@ -30,7 +30,7 @@ jobs: pkg: "gcc g++" - id: "distcheck-debian-stable-amd64-clang" task: "distcheck" - configure-args: "--enable-ja-rule --enable-e133 --enable-rdm-tests --enable-java-libs" + configure-args: "--enable-ja-rule --enable-e133 --enable-rdm-tests" # TODO(Perry): Fix Debian 12 OOM issue on GitHub Actions container: "debian:stable" compiler: From 51981882ef3a76bd9115aa8074c0680693bdd5e4 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Wed, 9 Aug 2023 11:54:45 +0100 Subject: [PATCH 09/56] Fix another minor typo --- plugins/artnet/ArtNetNodeTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/artnet/ArtNetNodeTest.cpp b/plugins/artnet/ArtNetNodeTest.cpp index 53b62350f1..4212f49961 100644 --- a/plugins/artnet/ArtNetNodeTest.cpp +++ b/plugins/artnet/ArtNetNodeTest.cpp @@ -690,7 +690,7 @@ void ArtNetNodeTest::testBroadcastSendDMX() { OLA_ASSERT_FALSE(node.SendDMX(4, dmx)); } - { // attempt to send an empty fram + { // attempt to send an empty frame SocketVerifier verifier(m_socket); DmxBuffer empty_buffer; OLA_ASSERT(node.SendDMX(m_port_id, empty_buffer)); From defe23e04a7afad1ee31763528ace6f1fac23e50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Offringa?= Date: Thu, 3 Aug 2023 08:47:34 +0200 Subject: [PATCH 10/56] Add a Eurolite serial number check This MR adds an option 'eurolite_serials' to the usb dmx plugin. This option accepts a comma separated list of serial numbers that are assumed to be Eurolite mk2 devices (as long as their product and vendor ids also match). This allows finding the Eurolite MK2 without enabling the 'enable_eurolite_mk2' option. The advantage is that is avoids the conflicts that 'enable_eurolite_mk2' produces with other plugins. These conflicts make it impossible to connect the mk2 simultaneously together with most other interfaces to have multiple universes and/or input universes. I have tested this by connecting an Enttec pro together with the Eurolite Mk2, and this works. --- plugins/usbdmx/EuroliteProFactory.cpp | 30 +++++++++++++++++++-------- plugins/usbdmx/EuroliteProFactory.h | 2 ++ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/plugins/usbdmx/EuroliteProFactory.cpp b/plugins/usbdmx/EuroliteProFactory.cpp index ce4a0b5e10..49fd55bc59 100644 --- a/plugins/usbdmx/EuroliteProFactory.cpp +++ b/plugins/usbdmx/EuroliteProFactory.cpp @@ -24,6 +24,8 @@ #include "ola/Logging.h" #include "ola/base/Flags.h" +#include + DECLARE_bool(use_async_libusb); namespace ola { @@ -46,12 +48,15 @@ const uint16_t EuroliteProFactory::VENDOR_ID_MK2 = 0x0403; const char EuroliteProFactory::ENABLE_EUROLITE_MK2_KEY[] = "enable_eurolite_mk2"; +const char EuroliteProFactory::EUROLITE_SERIALS_KEY[] = + "eurolite_serials"; EuroliteProFactory::EuroliteProFactory(ola::usb::LibUsbAdaptor *adaptor, Preferences *preferences) : BaseWidgetFactory("EuroliteProFactory"), m_adaptor(adaptor), m_enable_eurolite_mk2(IsEuroliteMk2Enabled(preferences)) { + StringSplit(preferences->GetValue(EUROLITE_SERIALS_KEY), m_expected_eurolite_serials, ","); } bool EuroliteProFactory::IsEuroliteMk2Enabled(Preferences *preferences) { @@ -88,12 +93,16 @@ bool EuroliteProFactory::DeviceAdded( // Eurolite USB-DMX512-PRO MK2? } else if (descriptor.idVendor == VENDOR_ID_MK2 && descriptor.idProduct == PRODUCT_ID_MK2) { - if (m_enable_eurolite_mk2) { - OLA_INFO << "Found a possible new Eurolite USB-DMX512-PRO MK2 device"; - LibUsbAdaptor::DeviceInformation info; - if (!m_adaptor->GetDeviceInfo(usb_device, descriptor, &info)) { - return false; - } + + LibUsbAdaptor::DeviceInformation info; + if (!m_adaptor->GetDeviceInfo(usb_device, descriptor, &info)) { + return false; + } + + const bool serial_matches = std::find(m_expected_eurolite_serials.begin(), m_expected_eurolite_serials.end(), info.serial) != m_expected_eurolite_serials.end(); + + if (m_enable_eurolite_mk2 || serial_matches) { + OLA_INFO << "Found a possible new Eurolite USB-DMX512-PRO MK2 device with serial " << info.serial; if (!m_adaptor->CheckManufacturer(EXPECTED_MANUFACTURER_MK2, info)) { return false; @@ -104,9 +113,12 @@ bool EuroliteProFactory::DeviceAdded( } is_mk2 = true; } else { - OLA_INFO << "Connected FTDI device could be a Eurolite " - << "USB-DMX512-PRO MK2 but was ignored, because " - << ENABLE_EUROLITE_MK2_KEY << " was false."; + OLA_INFO << "Connected FTDI device with serial " << info.serial + << " could be a Eurolite USB-DMX512-PRO MK2 but was " + << "ignored, because " + << ENABLE_EUROLITE_MK2_KEY << " was false and " + << "its serial number was not in the " + << "configuration."; return false; } } else { diff --git a/plugins/usbdmx/EuroliteProFactory.h b/plugins/usbdmx/EuroliteProFactory.h index 23ebdc3f86..4fb80bcfd5 100644 --- a/plugins/usbdmx/EuroliteProFactory.h +++ b/plugins/usbdmx/EuroliteProFactory.h @@ -46,10 +46,12 @@ class EuroliteProFactory : public BaseWidgetFactory { static bool IsEuroliteMk2Enabled(Preferences *preferences); static const char ENABLE_EUROLITE_MK2_KEY[]; + static const char EUROLITE_SERIALS_KEY[]; private: ola::usb::LibUsbAdaptor *m_adaptor; bool m_enable_eurolite_mk2; + std::vector m_expected_eurolite_serials; static const uint16_t PRODUCT_ID; static const uint16_t VENDOR_ID; From 0c679341f51ecb0138d71188d50a5ac37f78e2a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Offringa?= Date: Thu, 3 Aug 2023 11:20:41 +0200 Subject: [PATCH 11/56] Fix linting --- plugins/usbdmx/EuroliteProFactory.cpp | 19 +++++++++++-------- plugins/usbdmx/EuroliteProFactory.h | 3 +++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/plugins/usbdmx/EuroliteProFactory.cpp b/plugins/usbdmx/EuroliteProFactory.cpp index 49fd55bc59..302110b3a0 100644 --- a/plugins/usbdmx/EuroliteProFactory.cpp +++ b/plugins/usbdmx/EuroliteProFactory.cpp @@ -20,12 +20,12 @@ #include "plugins/usbdmx/EuroliteProFactory.h" +#include + #include "libs/usb/LibUsbAdaptor.h" #include "ola/Logging.h" #include "ola/base/Flags.h" -#include - DECLARE_bool(use_async_libusb); namespace ola { @@ -56,7 +56,8 @@ EuroliteProFactory::EuroliteProFactory(ola::usb::LibUsbAdaptor *adaptor, : BaseWidgetFactory("EuroliteProFactory"), m_adaptor(adaptor), m_enable_eurolite_mk2(IsEuroliteMk2Enabled(preferences)) { - StringSplit(preferences->GetValue(EUROLITE_SERIALS_KEY), m_expected_eurolite_serials, ","); + StringSplit(preferences->GetValue(EUROLITE_SERIALS_KEY), + m_expected_eurolite_serials, ","); } bool EuroliteProFactory::IsEuroliteMk2Enabled(Preferences *preferences) { @@ -93,16 +94,18 @@ bool EuroliteProFactory::DeviceAdded( // Eurolite USB-DMX512-PRO MK2? } else if (descriptor.idVendor == VENDOR_ID_MK2 && descriptor.idProduct == PRODUCT_ID_MK2) { - LibUsbAdaptor::DeviceInformation info; if (!m_adaptor->GetDeviceInfo(usb_device, descriptor, &info)) { return false; } - - const bool serial_matches = std::find(m_expected_eurolite_serials.begin(), m_expected_eurolite_serials.end(), info.serial) != m_expected_eurolite_serials.end(); - + + const bool serial_matches = std::find(m_expected_eurolite_serials.begin(), + m_expected_eurolite_serials.end(), info.serial) != + m_expected_eurolite_serials.end(); + if (m_enable_eurolite_mk2 || serial_matches) { - OLA_INFO << "Found a possible new Eurolite USB-DMX512-PRO MK2 device with serial " << info.serial; + OLA_INFO << "Found a possible new Eurolite USB-DMX512-PRO MK2 device " + "with serial " << info.serial; if (!m_adaptor->CheckManufacturer(EXPECTED_MANUFACTURER_MK2, info)) { return false; diff --git a/plugins/usbdmx/EuroliteProFactory.h b/plugins/usbdmx/EuroliteProFactory.h index 4fb80bcfd5..e04f4a973a 100644 --- a/plugins/usbdmx/EuroliteProFactory.h +++ b/plugins/usbdmx/EuroliteProFactory.h @@ -21,6 +21,9 @@ #ifndef PLUGINS_USBDMX_EUROLITEPROFACTORY_H_ #define PLUGINS_USBDMX_EUROLITEPROFACTORY_H_ +#include +#include + #include "libs/usb/LibUsbAdaptor.h" #include "ola/base/Macro.h" #include "olad/Preferences.h" From f149be413a1ce17aa63f03e540dfae89f4d8a0dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Offringa?= Date: Mon, 21 Aug 2023 14:46:14 +0200 Subject: [PATCH 12/56] Review comments by Peter --- plugins/usbdmx/EuroliteProFactory.cpp | 29 ++++++++++++++++++--------- plugins/usbdmx/EuroliteProFactory.h | 6 +++--- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/plugins/usbdmx/EuroliteProFactory.cpp b/plugins/usbdmx/EuroliteProFactory.cpp index 302110b3a0..62c8b57cb4 100644 --- a/plugins/usbdmx/EuroliteProFactory.cpp +++ b/plugins/usbdmx/EuroliteProFactory.cpp @@ -21,6 +21,7 @@ #include "plugins/usbdmx/EuroliteProFactory.h" #include +#include #include "libs/usb/LibUsbAdaptor.h" #include "ola/Logging.h" @@ -48,16 +49,27 @@ const uint16_t EuroliteProFactory::VENDOR_ID_MK2 = 0x0403; const char EuroliteProFactory::ENABLE_EUROLITE_MK2_KEY[] = "enable_eurolite_mk2"; -const char EuroliteProFactory::EUROLITE_SERIALS_KEY[] = - "eurolite_serials"; +const char EuroliteProFactory::EUROLITE_MK2_SERIAL_KEY[] = + "eurolite_mk2_serial"; EuroliteProFactory::EuroliteProFactory(ola::usb::LibUsbAdaptor *adaptor, Preferences *preferences) : BaseWidgetFactory("EuroliteProFactory"), m_adaptor(adaptor), m_enable_eurolite_mk2(IsEuroliteMk2Enabled(preferences)) { - StringSplit(preferences->GetValue(EUROLITE_SERIALS_KEY), - m_expected_eurolite_serials, ","); + const std::vector serials = + preferences->GetMultipleValue(EUROLITE_MK2_SERIAL_KEY); + for (const std::string& serial : serials) { + if (serial.empty()) { + OLA_WARN << EUROLITE_MK2_SERIAL_KEY + << " requires a serial key string, but is empty.\n"; + } else if (STLContains(m_expected_eurolite_mk2_serials, serial)) { + OLA_WARN << EUROLITE_MK2_SERIAL_KEY << " lists serial " + << serial << " more than once.\n"; + } else { + m_expected_eurolite_mk2_serials.insert(serial); + } + } } bool EuroliteProFactory::IsEuroliteMk2Enabled(Preferences *preferences) { @@ -99,9 +111,8 @@ bool EuroliteProFactory::DeviceAdded( return false; } - const bool serial_matches = std::find(m_expected_eurolite_serials.begin(), - m_expected_eurolite_serials.end(), info.serial) != - m_expected_eurolite_serials.end(); + const bool serial_matches = + STLContains(m_expected_eurolite_mk2_serials, info.serial); if (m_enable_eurolite_mk2 || serial_matches) { OLA_INFO << "Found a possible new Eurolite USB-DMX512-PRO MK2 device " @@ -120,8 +131,8 @@ bool EuroliteProFactory::DeviceAdded( << " could be a Eurolite USB-DMX512-PRO MK2 but was " << "ignored, because " << ENABLE_EUROLITE_MK2_KEY << " was false and " - << "its serial number was not in the " - << "configuration."; + << "its serial number was not specifically listed using " + << EUROLITE_MK2_SERIAL_KEY; return false; } } else { diff --git a/plugins/usbdmx/EuroliteProFactory.h b/plugins/usbdmx/EuroliteProFactory.h index e04f4a973a..249735dd75 100644 --- a/plugins/usbdmx/EuroliteProFactory.h +++ b/plugins/usbdmx/EuroliteProFactory.h @@ -21,8 +21,8 @@ #ifndef PLUGINS_USBDMX_EUROLITEPROFACTORY_H_ #define PLUGINS_USBDMX_EUROLITEPROFACTORY_H_ +#include #include -#include #include "libs/usb/LibUsbAdaptor.h" #include "ola/base/Macro.h" @@ -49,12 +49,12 @@ class EuroliteProFactory : public BaseWidgetFactory { static bool IsEuroliteMk2Enabled(Preferences *preferences); static const char ENABLE_EUROLITE_MK2_KEY[]; - static const char EUROLITE_SERIALS_KEY[]; + static const char EUROLITE_MK2_SERIAL_KEY[]; private: ola::usb::LibUsbAdaptor *m_adaptor; bool m_enable_eurolite_mk2; - std::vector m_expected_eurolite_serials; + std::set m_expected_eurolite_mk2_serials; static const uint16_t PRODUCT_ID; static const uint16_t VENDOR_ID; From df34ff29f7ce2294068388d931b51d60894cdb64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Offringa?= Date: Mon, 21 Aug 2023 15:15:31 +0200 Subject: [PATCH 13/56] Update documentation --- plugins/usbdmx/README.md | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/plugins/usbdmx/README.md b/plugins/usbdmx/README.md index 79d0eb8b88..f95a999eb7 100644 --- a/plugins/usbdmx/README.md +++ b/plugins/usbdmx/README.md @@ -9,7 +9,7 @@ This plugin supports various USB DMX devices including: * DMXControl Projects e.V. Nodle U1 * DMXCreator 512 Basic * Eurolite USB-DMX512 PRO -* Eurolite USB-DMX512 PRO MK2 (when `enable_eurolite_mk2 = true`) +* Eurolite USB-DMX512 PRO MK2 (see notes below) * Eurolite freeDMX Wi-Fi * Fadecandy * FX5 DMX @@ -20,25 +20,35 @@ This plugin supports various USB DMX devices including: ## Config file : `ola-usbdmx.conf` -`libusb_debug_level = {0,1,2,3,4}` -The debug level for libusb, see http://libusb.sourceforge.net/api-1.0/ +`libusb_debug_level = {0,1,2,3,4}` +The debug level for libusb, see http://libusb.sourceforge.net/api-1.0/ 0 = No logging, 4 = Verbose debug. `enable_eurolite_mk2 = {false,true}` Whether to enable detection of the Eurolite USB-DMX512 PRO MK2. -Default = false. This device is indistinguishable from other devices +Default = `false`. This device is indistinguishable from other devices with an FTDI chip, and is therefore disabled by default. When enabled, this plugin will conflict with the usbserial, StageProfi and FTDI USB DMX -plugins. +plugins. If this is undesirable, the `eurolite_mk2_serial` key can be +used instead, which manually couples a usb device as Eurolite USB-DMX512 +PRO MK2. -`nodle--mode = {0,1,2,3,4,5,6,7}` +`eurolite_mk2_serial = ` +Claim the usb device with the given serial number as a Eurolite USB-DMX512 +PRO MK2 even when `enable_eurolite_mk2 = false`. This makes it possible +to use the Eurolite USB-DMX512 PRO MK2 together with other devices that +can not be distinguished otherwise. This key has no effect when +`enable_eurolite_mk2 = true`. It may be specified multiple times to +use multiple Eurolite USB-DMX512 PRO MK2 devices. + +`nodle--mode = {0,1,2,3,4,5,6,7}` The mode for the Nodle U1 interface with serial number `` to operate -in. Default = 6 -0 - Standby -1 - DMX In -> DMX Out -2 - PC Out -> DMX Out -3 - DMX In + PC Out -> DMX Out -4 - DMX In -> PC In -5 - DMX In -> DMX Out & DMX In -> PC In -6 - PC Out -> DMX Out & DMX In -> PC In +in. Default = 6 +0 - Standby +1 - DMX In -> DMX Out +2 - PC Out -> DMX Out +3 - DMX In + PC Out -> DMX Out +4 - DMX In -> PC In +5 - DMX In -> DMX Out & DMX In -> PC In +6 - PC Out -> DMX Out & DMX In -> PC In 7 - DMX In + PC Out -> DMX Out & DMX In -> PC In From 0ea9bce1a064af8bbb77a05964bcef58d433985a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Offringa?= Date: Mon, 21 Aug 2023 15:20:13 +0200 Subject: [PATCH 14/56] Small textual changes --- plugins/usbdmx/EuroliteProFactory.cpp | 1 - plugins/usbdmx/README.md | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/usbdmx/EuroliteProFactory.cpp b/plugins/usbdmx/EuroliteProFactory.cpp index 62c8b57cb4..146ad0edc6 100644 --- a/plugins/usbdmx/EuroliteProFactory.cpp +++ b/plugins/usbdmx/EuroliteProFactory.cpp @@ -20,7 +20,6 @@ #include "plugins/usbdmx/EuroliteProFactory.h" -#include #include #include "libs/usb/LibUsbAdaptor.h" diff --git a/plugins/usbdmx/README.md b/plugins/usbdmx/README.md index f95a999eb7..956c74c258 100644 --- a/plugins/usbdmx/README.md +++ b/plugins/usbdmx/README.md @@ -30,7 +30,7 @@ Default = `false`. This device is indistinguishable from other devices with an FTDI chip, and is therefore disabled by default. When enabled, this plugin will conflict with the usbserial, StageProfi and FTDI USB DMX plugins. If this is undesirable, the `eurolite_mk2_serial` key can be -used instead, which manually couples a usb device as Eurolite USB-DMX512 +used instead, which manually associates a usb device as Eurolite USB-DMX512 PRO MK2. `eurolite_mk2_serial = ` @@ -38,8 +38,9 @@ Claim the usb device with the given serial number as a Eurolite USB-DMX512 PRO MK2 even when `enable_eurolite_mk2 = false`. This makes it possible to use the Eurolite USB-DMX512 PRO MK2 together with other devices that can not be distinguished otherwise. This key has no effect when -`enable_eurolite_mk2 = true`. It may be specified multiple times to -use multiple Eurolite USB-DMX512 PRO MK2 devices. +`enable_eurolite_mk2 = true` or no device is connected with the given +serial. The key may be specified multiple times to use multiple Eurolite +USB-DMX512 PRO MK2 devices. `nodle--mode = {0,1,2,3,4,5,6,7}` The mode for the Nodle U1 interface with serial number `` to operate From b167028d42bcc2d3bce4e6e8e9f955bcb1726693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Offringa?= Date: Tue, 22 Aug 2023 14:01:51 +0200 Subject: [PATCH 15/56] Update plugins/usbdmx/EuroliteProFactory.cpp Co-authored-by: Peter Newman --- plugins/usbdmx/EuroliteProFactory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/usbdmx/EuroliteProFactory.cpp b/plugins/usbdmx/EuroliteProFactory.cpp index 146ad0edc6..0d10539f54 100644 --- a/plugins/usbdmx/EuroliteProFactory.cpp +++ b/plugins/usbdmx/EuroliteProFactory.cpp @@ -57,7 +57,7 @@ EuroliteProFactory::EuroliteProFactory(ola::usb::LibUsbAdaptor *adaptor, m_adaptor(adaptor), m_enable_eurolite_mk2(IsEuroliteMk2Enabled(preferences)) { const std::vector serials = - preferences->GetMultipleValue(EUROLITE_MK2_SERIAL_KEY); + preferences->GetMultipleValue(EUROLITE_MK2_SERIAL_KEY); for (const std::string& serial : serials) { if (serial.empty()) { OLA_WARN << EUROLITE_MK2_SERIAL_KEY From 7609e4f4f2fc22838f7f3583547fd2b16f58bf80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Offringa?= Date: Tue, 22 Aug 2023 14:02:11 +0200 Subject: [PATCH 16/56] Update plugins/usbdmx/EuroliteProFactory.cpp Co-authored-by: Peter Newman --- plugins/usbdmx/EuroliteProFactory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/usbdmx/EuroliteProFactory.cpp b/plugins/usbdmx/EuroliteProFactory.cpp index 0d10539f54..a05616c5d6 100644 --- a/plugins/usbdmx/EuroliteProFactory.cpp +++ b/plugins/usbdmx/EuroliteProFactory.cpp @@ -61,7 +61,7 @@ EuroliteProFactory::EuroliteProFactory(ola::usb::LibUsbAdaptor *adaptor, for (const std::string& serial : serials) { if (serial.empty()) { OLA_WARN << EUROLITE_MK2_SERIAL_KEY - << " requires a serial key string, but is empty.\n"; + << " requires a serial key string, but it is empty.\n"; } else if (STLContains(m_expected_eurolite_mk2_serials, serial)) { OLA_WARN << EUROLITE_MK2_SERIAL_KEY << " lists serial " << serial << " more than once.\n"; From d37f05811164650607b8582d20607f5d699fa587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Offringa?= Date: Tue, 22 Aug 2023 14:03:16 +0200 Subject: [PATCH 17/56] Update plugins/usbdmx/README.md Co-authored-by: Peter Newman --- plugins/usbdmx/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/usbdmx/README.md b/plugins/usbdmx/README.md index 956c74c258..1cafb9102a 100644 --- a/plugins/usbdmx/README.md +++ b/plugins/usbdmx/README.md @@ -34,7 +34,7 @@ used instead, which manually associates a usb device as Eurolite USB-DMX512 PRO MK2. `eurolite_mk2_serial = ` -Claim the usb device with the given serial number as a Eurolite USB-DMX512 +Claim the USB device with the given serial number as a Eurolite USB-DMX512 PRO MK2 even when `enable_eurolite_mk2 = false`. This makes it possible to use the Eurolite USB-DMX512 PRO MK2 together with other devices that can not be distinguished otherwise. This key has no effect when From 713461bd98013c179bbc3c6c0fa7d06eb4c7f3ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Offringa?= Date: Tue, 22 Aug 2023 14:04:30 +0200 Subject: [PATCH 18/56] Update plugins/usbdmx/README.md Co-authored-by: Peter Newman --- plugins/usbdmx/README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/usbdmx/README.md b/plugins/usbdmx/README.md index 1cafb9102a..fb0c9988b8 100644 --- a/plugins/usbdmx/README.md +++ b/plugins/usbdmx/README.md @@ -37,9 +37,10 @@ PRO MK2. Claim the USB device with the given serial number as a Eurolite USB-DMX512 PRO MK2 even when `enable_eurolite_mk2 = false`. This makes it possible to use the Eurolite USB-DMX512 PRO MK2 together with other devices that -can not be distinguished otherwise. This key has no effect when -`enable_eurolite_mk2 = true` or no device is connected with the given -serial. The key may be specified multiple times to use multiple Eurolite +can not be distinguished otherwise. This setting has no effect when +can not be distinguished otherwise. This setting has no effect when +`enable_eurolite_mk2 = true` or if no device is connected with the given +serial. The setting may be specified multiple times to use multiple Eurolite USB-DMX512 PRO MK2 devices. `nodle--mode = {0,1,2,3,4,5,6,7}` From 79b7974ddb6c4794399c22cb6a710adedf7fca0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Offringa?= Date: Tue, 22 Aug 2023 14:04:43 +0200 Subject: [PATCH 19/56] Update plugins/usbdmx/EuroliteProFactory.cpp Co-authored-by: Peter Newman --- plugins/usbdmx/EuroliteProFactory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/usbdmx/EuroliteProFactory.cpp b/plugins/usbdmx/EuroliteProFactory.cpp index a05616c5d6..b4d129c26f 100644 --- a/plugins/usbdmx/EuroliteProFactory.cpp +++ b/plugins/usbdmx/EuroliteProFactory.cpp @@ -58,7 +58,7 @@ EuroliteProFactory::EuroliteProFactory(ola::usb::LibUsbAdaptor *adaptor, m_enable_eurolite_mk2(IsEuroliteMk2Enabled(preferences)) { const std::vector serials = preferences->GetMultipleValue(EUROLITE_MK2_SERIAL_KEY); - for (const std::string& serial : serials) { + for (; iter != serials.end(); ++iter) { if (serial.empty()) { OLA_WARN << EUROLITE_MK2_SERIAL_KEY << " requires a serial key string, but it is empty.\n"; From 69b8f70ad40288cbdad71166769ce2754337cc7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Offringa?= Date: Tue, 22 Aug 2023 14:11:57 +0200 Subject: [PATCH 20/56] Update plugins/usbdmx/README.md Co-authored-by: Peter Newman --- plugins/usbdmx/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/usbdmx/README.md b/plugins/usbdmx/README.md index fb0c9988b8..2cbbd1e917 100644 --- a/plugins/usbdmx/README.md +++ b/plugins/usbdmx/README.md @@ -30,7 +30,7 @@ Default = `false`. This device is indistinguishable from other devices with an FTDI chip, and is therefore disabled by default. When enabled, this plugin will conflict with the usbserial, StageProfi and FTDI USB DMX plugins. If this is undesirable, the `eurolite_mk2_serial` key can be -used instead, which manually associates a usb device as Eurolite USB-DMX512 +used instead, which manually associates a specific USB device as a Eurolite USB-DMX512 PRO MK2. `eurolite_mk2_serial = ` From 8af5d091856da588faf6eb052e382bd18ac87aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Offringa?= Date: Tue, 22 Aug 2023 14:34:19 +0200 Subject: [PATCH 21/56] Comments by Peter --- plugins/usbdmx/EuroliteProFactory.cpp | 37 +++++++++++++++++---------- plugins/usbdmx/README.md | 5 ++-- plugins/usbdmx/UsbDmxPlugin.cpp | 5 ++++ 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/plugins/usbdmx/EuroliteProFactory.cpp b/plugins/usbdmx/EuroliteProFactory.cpp index b4d129c26f..984b9ba013 100644 --- a/plugins/usbdmx/EuroliteProFactory.cpp +++ b/plugins/usbdmx/EuroliteProFactory.cpp @@ -58,15 +58,22 @@ EuroliteProFactory::EuroliteProFactory(ola::usb::LibUsbAdaptor *adaptor, m_enable_eurolite_mk2(IsEuroliteMk2Enabled(preferences)) { const std::vector serials = preferences->GetMultipleValue(EUROLITE_MK2_SERIAL_KEY); - for (; iter != serials.end(); ++iter) { - if (serial.empty()) { - OLA_WARN << EUROLITE_MK2_SERIAL_KEY - << " requires a serial key string, but it is empty.\n"; - } else if (STLContains(m_expected_eurolite_mk2_serials, serial)) { - OLA_WARN << EUROLITE_MK2_SERIAL_KEY << " lists serial " - << serial << " more than once.\n"; - } else { - m_expected_eurolite_mk2_serials.insert(serial); + // A single empty string is considered the same as specifying + // no serial numbers. This is useful as a default value. + const bool has_default_value = + serials.size() == 1 && serials[0].empty(); + if (!has_default_value) { + for (std::vector::const_iterator iter = serials.begin(); + iter != serials.end(); ++iter) { + if (iter->empty()) { + OLA_WARN << EUROLITE_MK2_SERIAL_KEY + << " requires a serial key string, but it is empty."; + } else if (STLContains(m_expected_eurolite_mk2_serials, *iter)) { + OLA_WARN << EUROLITE_MK2_SERIAL_KEY << " lists serial " + << *iter << " more than once."; + } else { + m_expected_eurolite_mk2_serials.insert(*iter); + } } } } @@ -114,9 +121,13 @@ bool EuroliteProFactory::DeviceAdded( STLContains(m_expected_eurolite_mk2_serials, info.serial); if (m_enable_eurolite_mk2 || serial_matches) { - OLA_INFO << "Found a possible new Eurolite USB-DMX512-PRO MK2 device " - "with serial " << info.serial; - + if (serial_matches) { + OLA_INFO << "Enabling new Eurolite USB-DMX512-PRO MK2 device " + "with matching serial " << info.serial; + } else { + OLA_INFO << "Found a possible new Eurolite USB-DMX512-PRO MK2 device " + "with serial " << info.serial; + } if (!m_adaptor->CheckManufacturer(EXPECTED_MANUFACTURER_MK2, info)) { return false; } @@ -130,7 +141,7 @@ bool EuroliteProFactory::DeviceAdded( << " could be a Eurolite USB-DMX512-PRO MK2 but was " << "ignored, because " << ENABLE_EUROLITE_MK2_KEY << " was false and " - << "its serial number was not specifically listed using " + << "its serial number was not specifically specified with " << EUROLITE_MK2_SERIAL_KEY; return false; } diff --git a/plugins/usbdmx/README.md b/plugins/usbdmx/README.md index 2cbbd1e917..2a96cde46a 100644 --- a/plugins/usbdmx/README.md +++ b/plugins/usbdmx/README.md @@ -30,15 +30,14 @@ Default = `false`. This device is indistinguishable from other devices with an FTDI chip, and is therefore disabled by default. When enabled, this plugin will conflict with the usbserial, StageProfi and FTDI USB DMX plugins. If this is undesirable, the `eurolite_mk2_serial` key can be -used instead, which manually associates a specific USB device as a Eurolite USB-DMX512 -PRO MK2. +used instead, which manually marks a specific USB device as a Eurolite +USB-DMX512 PRO MK2. `eurolite_mk2_serial = ` Claim the USB device with the given serial number as a Eurolite USB-DMX512 PRO MK2 even when `enable_eurolite_mk2 = false`. This makes it possible to use the Eurolite USB-DMX512 PRO MK2 together with other devices that can not be distinguished otherwise. This setting has no effect when -can not be distinguished otherwise. This setting has no effect when `enable_eurolite_mk2 = true` or if no device is connected with the given serial. The setting may be specified multiple times to use multiple Eurolite USB-DMX512 PRO MK2 devices. diff --git a/plugins/usbdmx/UsbDmxPlugin.cpp b/plugins/usbdmx/UsbDmxPlugin.cpp index d1760aea96..4aa3f7f887 100644 --- a/plugins/usbdmx/UsbDmxPlugin.cpp +++ b/plugins/usbdmx/UsbDmxPlugin.cpp @@ -107,6 +107,11 @@ bool UsbDmxPlugin::SetDefaultPreferences() { BoolValidator(), false); + save |= m_preferences->SetDefaultValue( + EuroliteProFactory::EUROLITE_MK2_SERIAL_KEY, + StringValidator(), + ""); + if (save) { m_preferences->Save(); } From 8bcce7109f5e83e69a8a73d4db399dff561ac0b7 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 3 Sep 2023 22:37:05 +0100 Subject: [PATCH 22/56] Add some testing of MAC addresses within messaging fields --- common/messaging/DescriptorTest.cpp | 8 ++++++++ common/messaging/MessagePrinterTest.cpp | 18 +++++++++++++----- common/rdm/GroupSizeCalculatorTest.cpp | 11 +++++++---- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/common/messaging/DescriptorTest.cpp b/common/messaging/DescriptorTest.cpp index eb7fcdbcc0..9c1bbcde44 100644 --- a/common/messaging/DescriptorTest.cpp +++ b/common/messaging/DescriptorTest.cpp @@ -34,6 +34,7 @@ using ola::messaging::BoolFieldDescriptor; using ola::messaging::FieldDescriptor; using ola::messaging::FieldDescriptorGroup; using ola::messaging::IPV4FieldDescriptor; +using ola::messaging::MACFieldDescriptor; using ola::messaging::StringFieldDescriptor; using ola::messaging::UIDFieldDescriptor; using ola::messaging::UInt16FieldDescriptor; @@ -76,6 +77,13 @@ void DescriptorTest::testFieldDescriptors() { OLA_ASSERT_TRUE(ipv4_descriptor.LimitedSize()); OLA_ASSERT_EQ(4u, ipv4_descriptor.MaxSize()); + // MAC address + MACFieldDescriptor mac_descriptor("mac"); + OLA_ASSERT_EQ(string("mac"), mac_descriptor.Name()); + OLA_ASSERT_TRUE(mac_descriptor.FixedSize()); + OLA_ASSERT_TRUE(mac_descriptor.LimitedSize()); + OLA_ASSERT_EQ(6u, mac_descriptor.MaxSize()); + // UID UIDFieldDescriptor uid_descriptor("uid"); OLA_ASSERT_EQ(string("uid"), uid_descriptor.Name()); diff --git a/common/messaging/MessagePrinterTest.cpp b/common/messaging/MessagePrinterTest.cpp index a096ab628d..0fdc2c2519 100644 --- a/common/messaging/MessagePrinterTest.cpp +++ b/common/messaging/MessagePrinterTest.cpp @@ -33,20 +33,23 @@ using std::string; using std::vector; using ola::rdm::UID; +using ola::network::MACAddress; using ola::messaging::BoolFieldDescriptor; using ola::messaging::BoolMessageField; using ola::messaging::FieldDescriptor; using ola::messaging::FieldDescriptorGroup; -using ola::messaging::GroupMessageField; -using ola::messaging::IPV4FieldDescriptor; using ola::messaging::GenericMessagePrinter; -using ola::messaging::IPV4MessageField; +using ola::messaging::GroupMessageField; using ola::messaging::Int16FieldDescriptor; using ola::messaging::Int16MessageField; using ola::messaging::Int8FieldDescriptor; using ola::messaging::Int8MessageField; +using ola::messaging::IPV4FieldDescriptor; +using ola::messaging::IPV4MessageField; +using ola::messaging::MACFieldDescriptor; +using ola::messaging::MACMessageField; using ola::messaging::Message; using ola::messaging::MessageFieldInterface; using ola::messaging::StringFieldDescriptor; @@ -87,6 +90,7 @@ void GenericMessagePrinterTest::testSimplePrinter() { // setup some fields BoolFieldDescriptor bool_descriptor("On/Off"); IPV4FieldDescriptor ipv4_descriptor("ip"); + MACFieldDescriptor mac_descriptor("mac"); UIDFieldDescriptor uid_descriptor("uid"); StringFieldDescriptor string_descriptor("Name", 0, 32); UInt32FieldDescriptor uint32_descriptor("Id"); @@ -100,6 +104,9 @@ void GenericMessagePrinterTest::testSimplePrinter() { fields.push_back( new IPV4MessageField(&ipv4_descriptor, ola::network::HostToNetwork(0x0a000001))); + fields.push_back( + new MACMessageField(&mac_descriptor, + MACAddress::FromStringOrDie("01:23:45:67:89:ab"))); fields.push_back(new UIDMessageField(&uid_descriptor, UID(0x7a70, 1))); fields.push_back(new StringMessageField(&string_descriptor, "foobar")); fields.push_back(new UInt32MessageField(&uint32_descriptor, 42)); @@ -109,8 +116,9 @@ void GenericMessagePrinterTest::testSimplePrinter() { Message message(fields); string expected = ( - "On/Off: false\nip: 10.0.0.1\nuid: 7a70:00000001\nName: foobar\nId: 42\n" - "Count: 4 x 10 ^ -3\nDelta: 10 x 10 ^ 1\nRate: 10 x 10 ^ -1\n"); + "On/Off: false\nip: 10.0.0.1\nmac: 01:23:45:67:89:ab\n" + "uid: 7a70:00000001\nName: foobar\nId: 42\nCount: 4 x 10 ^ -3\n" + "Delta: 10 x 10 ^ 1\nRate: 10 x 10 ^ -1\n"); OLA_ASSERT_EQ(expected, m_printer.AsString(&message)); } diff --git a/common/rdm/GroupSizeCalculatorTest.cpp b/common/rdm/GroupSizeCalculatorTest.cpp index a47b80d6c0..02559f5074 100644 --- a/common/rdm/GroupSizeCalculatorTest.cpp +++ b/common/rdm/GroupSizeCalculatorTest.cpp @@ -37,6 +37,7 @@ using ola::messaging::IPV4FieldDescriptor; using ola::messaging::Int16FieldDescriptor; using ola::messaging::Int32FieldDescriptor; using ola::messaging::Int8FieldDescriptor; +using ola::messaging::MACFieldDescriptor; using ola::messaging::StringFieldDescriptor; using ola::messaging::UIDFieldDescriptor; using ola::messaging::UInt16FieldDescriptor; @@ -83,6 +84,7 @@ void GroupSizeCalculatorTest::testSimpleCases() { fields.push_back(new Int8FieldDescriptor("int8")); fields.push_back(new Int16FieldDescriptor("int16")); fields.push_back(new Int32FieldDescriptor("int32")); + fields.push_back(new MACFieldDescriptor("mac")); fields.push_back(new StringFieldDescriptor("string", 0, 32)); fields.push_back(new IPV4FieldDescriptor("address")); fields.push_back(new UIDFieldDescriptor("uid")); @@ -91,7 +93,8 @@ void GroupSizeCalculatorTest::testSimpleCases() { unsigned int token_count, group_repeat_count; OLA_ASSERT_TRUE( m_static_calculator.CalculateTokensRequired(&descriptor, &token_count)); - OLA_ASSERT_EQ(10u, token_count); + OLA_ASSERT_EQ(11u, token_count); // Actual token count + OLA_ASSERT_EQ( GroupSizeCalculator::INSUFFICIENT_TOKENS, @@ -103,21 +106,21 @@ void GroupSizeCalculatorTest::testSimpleCases() { OLA_ASSERT_EQ( GroupSizeCalculator::INSUFFICIENT_TOKENS, m_calculator.CalculateGroupSize( - 9, + 10, // Actual token count - 1 &descriptor, &group_repeat_count)); OLA_ASSERT_EQ( GroupSizeCalculator::NO_VARIABLE_GROUPS, m_calculator.CalculateGroupSize( - 10, + 11, // Actual token count &descriptor, &group_repeat_count)); OLA_ASSERT_EQ( GroupSizeCalculator::EXTRA_TOKENS, m_calculator.CalculateGroupSize( - 11, + 12, // Actual token count + 1 &descriptor, &group_repeat_count)); } From e85896d4d10e11eb67a95c9c4ec31ffe47111d51 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Sep 2023 21:38:12 +0000 Subject: [PATCH 23/56] Bump actions/checkout from 3 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yaml | 4 ++-- .github/workflows/debian.yml | 4 ++-- .github/workflows/isort.yml | 2 +- .github/workflows/lint.yaml | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index fb0bfe819e..8408df474e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -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: | diff --git a/.github/workflows/debian.yml b/.github/workflows/debian.yml index dbf285ba85..0ae5317ba0 100644 --- a/.github/workflows/debian.yml +++ b/.github/workflows/debian.yml @@ -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 diff --git a/.github/workflows/isort.yml b/.github/workflows/isort.yml index f314e5b555..9aff6b16d1 100644 --- a/.github/workflows/isort.yml +++ b/.github/workflows/isort.yml @@ -8,5 +8,5 @@ jobs: isort: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: isort/isort-action@v1 diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 731f617f5c..0c49e768a0 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -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: | @@ -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: From d158bdde091363004c47c5272ea0e1d7a72f95d0 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Fri, 10 Jan 2020 05:08:51 +0000 Subject: [PATCH 24/56] Add the ability to set a universe to blackout instead via ola_set_dmx Currently untested (cherry picked from commit 54ac1fb6ec9376944b0aec0a8c12f0d1a74243a0) --- examples/ola-client.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/examples/ola-client.cpp b/examples/ola-client.cpp index f6eeab53c9..aa001d2d2e 100644 --- a/examples/ola-client.cpp +++ b/examples/ola-client.cpp @@ -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; @@ -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; } @@ -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'}, @@ -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; @@ -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; @@ -656,7 +662,8 @@ void DisplayUniverseMergeHelp(const options &opts) { * Help message for set dmx */ void DisplaySetDmxHelp(const options &opts) { - cout << "Usage: " << opts.cmd << " --universe --dmx \n" + cout << "Usage: " << opts.cmd << " --universe [ --dmx ] " + "[ --blackout ]\n" "\n" "Sets the DMX values for a universe.\n" "\n" @@ -665,6 +672,7 @@ void DisplaySetDmxHelp(const options &opts) { " -d, --dmx 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; } @@ -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); } From 1d1c91a8fd7ffaa0f9bcd34e1991d2d213c22370 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Fri, 10 Jan 2020 05:13:46 +0000 Subject: [PATCH 25/56] Update the man page (cherry picked from commit bdb844efb97c5961223222014dd4bf76f111123b) --- man/ola_set_dmx.1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/man/ola_set_dmx.1 b/man/ola_set_dmx.1 index 0de61b95f7..89f95379bb 100644 --- a/man/ola_set_dmx.1 +++ b/man/ola_set_dmx.1 @@ -4,7 +4,7 @@ ola_set_dmx \- Sets the DMX values for a universe. .SH SYNOPSIS .B ola_set_dmx -\fI--universe --dmx \fR +\fI--universe [ --dmx ] [ --blackout ]\fR .SH DESCRIPTION Sets the DMX values for a universe. .TP @@ -15,3 +15,7 @@ Display this help message and exit. .TP \fB\-d\fR, \fB\-\-dmx\fR Comma separated DMX values, e.g. 0,255,128 sets first channel to 0, second channel to 255 and third channel to 128. +.HP +\fB\-b\fR, \fB\-\-blackout\fR +Send a universe to blackout instead. +.TP From e22dbcb0fa5188aad0e8837886c3a7dbf4af6817 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Thu, 7 Sep 2023 16:00:58 +0100 Subject: [PATCH 26/56] Fix the compilation --- examples/ola-client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ola-client.cpp b/examples/ola-client.cpp index aa001d2d2e..c639889efd 100644 --- a/examples/ola-client.cpp +++ b/examples/ola-client.cpp @@ -873,7 +873,7 @@ int SendDmx(OlaClientWrapper *wrapper, const options &opts) { } // A dmx string and blackout are mutually exclusive - if (opts.uni < 0 || !status || (opts.blackout && !opts.dmx.empty) || + if (opts.uni < 0 || !status || (opts.blackout && !opts.dmx.empty()) || buffer.Size() == 0) { DisplaySetDmxHelp(opts); exit(1); From b1da6ed0c72abcee49978373f8de8fddeafc1816 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Mon, 18 Sep 2023 23:08:07 +0100 Subject: [PATCH 27/56] Initial IPv6 classes --- common/network/IPV4Address.cpp | 2 +- common/network/IPV6Address.cpp | 168 ++++++++++++++++++++ common/network/IPV6AddressTest.cpp | 198 ++++++++++++++++++++++++ common/network/Makefile.mk | 2 + include/ola/network/IPV4Address.h | 2 +- include/ola/network/IPV6Address.h | 238 +++++++++++++++++++++++++++++ include/ola/network/Makefile.mk | 1 + 7 files changed, 609 insertions(+), 2 deletions(-) create mode 100644 common/network/IPV6Address.cpp create mode 100644 common/network/IPV6AddressTest.cpp create mode 100644 include/ola/network/IPV6Address.h diff --git a/common/network/IPV4Address.cpp b/common/network/IPV4Address.cpp index 3dba9a8fb8..ba619ad0e8 100644 --- a/common/network/IPV4Address.cpp +++ b/common/network/IPV4Address.cpp @@ -14,7 +14,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * IPV4Address.cpp - * A IPV4 address + * An IPV4 address * Copyright (C) 2011 Simon Newton */ diff --git a/common/network/IPV6Address.cpp b/common/network/IPV6Address.cpp new file mode 100644 index 0000000000..82a2b6e173 --- /dev/null +++ b/common/network/IPV6Address.cpp @@ -0,0 +1,168 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * IPV6Address.cpp + * An IPV6 address + * Copyright (C) 2023 Peter Newman + */ + +#if HAVE_CONFIG_H +#include +#endif // HAVE_CONFIG_H + +#ifdef HAVE_SYS_SOCKET_H +#include // Required by FreeBSD +#endif // HAVE_SYS_SOCKET_H +#ifdef HAVE_ARPA_INET_H +#include +#endif // HAVE_ARPA_INET_H +#ifdef HAVE_NETINET_IN_H +#include // Required by FreeBSD +#endif // HAVE_NETINET_IN_H + +#include +#include +#include +#include +#include + +#include "common/network/NetworkUtilsInternal.h" +#include "ola/Logging.h" +#include "ola/network/IPV6Address.h" +#include "ola/network/NetworkUtils.h" + +namespace ola { +namespace network { + +using std::string; + +IPV6Address::IPV6Address(const uint8_t *address) { + // TODO(Peter): Deal with network byte order? + memcpy(&m_address.s6_addr[0], address, sizeof (struct in6_addr)); +} + +bool IPV6Address::operator<(const IPV6Address &other) const { + // TODO(Peter): Deal with network byte order? + // Stored in network byte order, so convert to sort appropriately + return (memcmp(&m_address.s6_addr[0], &other.m_address.s6_addr[0], sizeof (struct in6_addr)) < 0); +} + +bool IPV6Address::operator>(const IPV6Address &other) const { + // TODO(Peter): Deal with network byte order? + // Stored in network byte order, so convert to sort appropriately + return (memcmp(&m_address.s6_addr[0], &other.m_address.s6_addr[0], sizeof (struct in6_addr)) > 0); +} + +bool IPV6StringToAddress(const string &address, struct in6_addr *addr) { + bool ok; +//// TODO(Peter): This currently allows some rather quirky values as per +//// inet_pton, we may want to restrict that in future to match IPV6Validator +//// if that deviates + + if (address.empty()) { + // Don't bother trying to extract an address if we weren't given one + return false; + } + +#ifdef HAVE_INET_PTON + ok = (1 == inet_pton(AF_INET6, address.data(), addr)); +#else + OLA_FATAL << "Failed to convert string to address, inet_pton unavailable"; + return false; +#endif // HAVE_INET_PTON + + if (!ok) { + OLA_WARN << "Could not convert address " << address; + } + return ok; +} + +bool IPV6Address::IsWildcard() const { + return IN6_IS_ADDR_UNSPECIFIED(&m_address); +} + +string IPV6Address::ToString() const { + struct in6_addr addr; + addr = m_address; +#ifdef HAVE_INET_NTOP + char str[INET6_ADDRSTRLEN]; + if (inet_ntop(AF_INET6, &addr, str, INET6_ADDRSTRLEN) == NULL) { + OLA_FATAL << "Failed to convert address to string using inet_ntop"; + return NULL; + } + return str; +#else + OLA_FATAL << "Failed to convert address to string, inet_ntop unavailable"; + return NULL; +#endif // HAVE_INET_NTOP +} + +IPV6Address* IPV6Address::FromString(const string &address) { + struct in6_addr addr; + if (!IPV6StringToAddress(address, &addr)) { + return NULL; + } + + return new IPV6Address(addr); +} + +bool IPV6Address::FromString(const string &address, IPV6Address *target) { + struct in6_addr addr; + if (!IPV6StringToAddress(address, &addr)) { + return false; + } + *target = IPV6Address(addr); + return true; +} + +IPV6Address IPV6Address::FromStringOrDie(const string &address) { + struct in6_addr addr; + assert(IPV6StringToAddress(address, &addr)); + return IPV6Address(addr); +} + +/*bool IPV6Address::ToCIDRMask(IPV6Address address, uint8_t *mask) { + uint32_t netmask = NetworkToHost(address.AsInt()); + uint8_t bits = 0; + bool seen_one = false; + for (uint8_t i = 0; i < std::numeric_limits::digits; i++) { + if (netmask & 1) { + bits++; + seen_one = true; + } else { + if (seen_one) { + return false; + } + } + netmask = netmask >> 1; + } + *mask = bits; + return true; +}*/ + +IPV6Address IPV6Address::WildCard() { + in6_addr wildCard = IN6ADDR_ANY_INIT; + // TODO(Peter): Deal with host to network conversion... + return IPV6Address(wildCard); +} + +IPV6Address IPV6Address::Loopback() { + in6_addr loopback = IN6ADDR_LOOPBACK_INIT; + // TODO(Peter): Deal with host to network conversion... + //return IPV6Address(HostToNetwork(IN6ADDR_LOOPBACK_INIT)); + return IPV6Address(loopback); +} +} // namespace network +} // namespace ola diff --git a/common/network/IPV6AddressTest.cpp b/common/network/IPV6AddressTest.cpp new file mode 100644 index 0000000000..72880788e1 --- /dev/null +++ b/common/network/IPV6AddressTest.cpp @@ -0,0 +1,198 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * IPV6AddressTest.cpp + * Test fixture for the IPV6Address class + * Copyright (C) 2023 Peter Newman + */ + +#include + +#include +#include +#include +#include +#include +#include +#include "common/network/NetworkUtilsInternal.h" +#include "ola/network/IPV6Address.h" +#include "ola/network/NetworkUtils.h" +#include "ola/testing/TestUtils.h" + + +using ola::network::IPV6Address; +using ola::network::HostToNetwork; +using std::auto_ptr; +using std::string; +using std::vector; + +class IPV6AddressTest: public CppUnit::TestFixture { + CPPUNIT_TEST_SUITE(IPV6AddressTest); + CPPUNIT_TEST(testIPV6Address); + CPPUNIT_TEST(testWildcard); + CPPUNIT_TEST(testLoopback); + CPPUNIT_TEST_SUITE_END(); + + public: + void testIPV6Address(); + void testWildcard(); + // TODO(Peter): Test the all-nodes link-local multicast group if we add it + void testLoopback(); +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(IPV6AddressTest); + + +/* + * Test the IPV6 Address class works + */ +void IPV6AddressTest::testIPV6Address() { + IPV6Address wildcard_address; + OLA_ASSERT_EQ(string("::"), wildcard_address.ToString()); +// OLA_ASSERT_EQ(static_cast(0), wildcard_address.AsInt()); + OLA_ASSERT_TRUE(wildcard_address.IsWildcard()); + + IPV6Address address1 = IPV6Address::FromStringOrDie("::ffff:c0a8:101"); +// int ip_as_int = address1.AsInt(); + OLA_ASSERT_NE(wildcard_address, address1); +// OLA_ASSERT_NE(HostToNetwork(0xc0a811), ip_as_int); +// OLA_ASSERT_EQ(HostToNetwork(0xc0a80101), static_cast(ip_as_int)); + OLA_ASSERT_EQ(string("::ffff:192.168.1.1"), address1.ToString()); + + IPV6Address address2 = IPV6Address::FromStringOrDie("2001:db8:1234:5678:90ab:cdef:feed:face"); +// int ip_as_int = address2.AsInt(); + OLA_ASSERT_NE(wildcard_address, address2); +// OLA_ASSERT_NE(HostToNetwork(0xc0a811), ip_as_int); +// OLA_ASSERT_EQ(HostToNetwork(0xc0a80101), static_cast(ip_as_int)); + + const uint8_t big_endian_address_data[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 10, 0, 0, 1}; + IPV6Address binary_address(big_endian_address_data); + OLA_ASSERT_EQ(string("::ffff:10.0.0.1"), binary_address.ToString()); + + // Test Get() + uint8_t address_data[] = {32, 1, 13, 184, 18, 52, 86, 120, 144, 171, 205, 239, 254, 237, 250, 206}; + uint8_t addr[IPV6Address::LENGTH]; + address2.Get(addr); + OLA_ASSERT_DATA_EQUALS(addr, + sizeof(addr), + reinterpret_cast(&address_data), + sizeof(address_data)); + + // test copy and assignment + IPV6Address address3(address1); + OLA_ASSERT_EQ(address1, address3); + IPV6Address address4 = address1; + OLA_ASSERT_EQ(address1, address4); + + // test stringification + OLA_ASSERT_EQ(string("::ffff:192.168.1.1"), address1.ToString()); + std::ostringstream str; + str << address1; + OLA_ASSERT_EQ(string("::ffff:192.168.1.1"), str.str()); + + // test from string + auto_ptr string_address(IPV6Address::FromString("::ffff:10.0.0.1")); + OLA_ASSERT_NOT_NULL(string_address.get()); + OLA_ASSERT_EQ(string("::ffff:10.0.0.1"), string_address->ToString()); + + auto_ptr string_address2(IPV6Address::FromString("foo")); + OLA_ASSERT_NULL(string_address2.get()); + + // and the second form + IPV6Address string_address3; + OLA_ASSERT_TRUE(IPV6Address::FromString("::ffff:172.16.4.1", &string_address3)); + OLA_ASSERT_EQ(string("::ffff:172.16.4.1"), string_address3.ToString()); + + IPV6Address string_address4; + // Add the leading zero to the second group + OLA_ASSERT_TRUE(IPV6Address::FromString("2001:0db8:1234:5678:90ab:cdef:feed:face", &string_address4)); + // Confirm it's not rendered when we convert to a string + OLA_ASSERT_EQ(string("2001:db8:1234:5678:90ab:cdef:feed:face"), string_address4.ToString()); + + IPV6Address string_address5; + OLA_ASSERT_TRUE(IPV6Address::FromString("2001:db8:dead:beef:dead:beef:dead:beef", &string_address5)); + OLA_ASSERT_EQ(string("2001:db8:dead:beef:dead:beef:dead:beef"), string_address5.ToString()); + + IPV6Address string_address6; + OLA_ASSERT_FALSE(IPV6Address::FromString("", &string_address6)); + + // make sure sorting works + vector addresses; + addresses.push_back(address1); + addresses.push_back(*string_address); + addresses.push_back(string_address3); + addresses.push_back(string_address4); + addresses.push_back(string_address5); + std::sort(addresses.begin(), addresses.end()); + + // The comparisons take into account network byte order automagically. + OLA_ASSERT_EQ(string("::ffff:10.0.0.1"), addresses[0].ToString()); + OLA_ASSERT_EQ(string("::ffff:172.16.4.1"), addresses[1].ToString()); + OLA_ASSERT_EQ(string("::ffff:192.168.1.1"), addresses[2].ToString()); + OLA_ASSERT_EQ(string("2001:db8:1234:5678:90ab:cdef:feed:face"), addresses[3].ToString()); + OLA_ASSERT_EQ(string("2001:db8:dead:beef:dead:beef:dead:beef"), addresses[4].ToString()); + +/* uint8_t mask = 255; // UINT8_MAX; + OLA_ASSERT_TRUE( + IPV6Address::ToCIDRMask(IPV6Address::FromStringOrDie("0.0.0.0"), &mask)); + OLA_ASSERT_EQ(0, static_cast(mask)); + + OLA_ASSERT_TRUE( + IPV6Address::ToCIDRMask(IPV6Address::FromStringOrDie("255.0.0.0"), + &mask)); + OLA_ASSERT_EQ(8, static_cast(mask)); + + OLA_ASSERT_TRUE( + IPV6Address::ToCIDRMask(IPV6Address::FromStringOrDie("255.255.255.0"), + &mask)); + OLA_ASSERT_EQ(24, static_cast(mask)); + + OLA_ASSERT_TRUE( + IPV6Address::ToCIDRMask(IPV6Address::FromStringOrDie("255.255.255.252"), + &mask)); + OLA_ASSERT_EQ(30, static_cast(mask)); + + OLA_ASSERT_TRUE( + IPV6Address::ToCIDRMask(IPV6Address::FromStringOrDie("255.255.255.255"), + &mask)); + OLA_ASSERT_EQ(32, static_cast(mask)); + + OLA_ASSERT_FALSE( + IPV6Address::ToCIDRMask(IPV6Address::FromStringOrDie("255.0.0.255"), + &mask));*/ +} + + +/* + * Test the wildcard address works. + */ +void IPV6AddressTest::testWildcard() { + IPV6Address wildcard_address; + OLA_ASSERT_EQ(string("::"), wildcard_address.ToString()); +// OLA_ASSERT_EQ(static_cast(0), wildcard_address.AsInt()); + OLA_ASSERT_TRUE(wildcard_address.IsWildcard()); + + IPV6Address wildcard_address2 = IPV6Address::WildCard(); + OLA_ASSERT_EQ(wildcard_address, wildcard_address2); +} + + +/* + * Test the loopback address works. + */ +void IPV6AddressTest::testLoopback() { + IPV6Address loopback_address = IPV6Address::Loopback(); + OLA_ASSERT_EQ(string("::1"), loopback_address.ToString()); +} diff --git a/common/network/Makefile.mk b/common/network/Makefile.mk index 44ef81f57d..fc9327e677 100644 --- a/common/network/Makefile.mk +++ b/common/network/Makefile.mk @@ -5,6 +5,7 @@ common_libolacommon_la_SOURCES += \ common/network/FakeInterfacePicker.h \ common/network/HealthCheckedConnection.cpp \ common/network/IPV4Address.cpp \ + common/network/IPV6Address.cpp \ common/network/Interface.cpp \ common/network/InterfacePicker.cpp \ common/network/MACAddress.cpp \ @@ -44,6 +45,7 @@ common_network_HealthCheckedConnectionTester_LDADD = $(COMMON_TESTING_LIBS) common_network_NetworkTester_SOURCES = \ common/network/IPV4AddressTest.cpp \ + common/network/IPV6AddressTest.cpp \ common/network/InterfacePickerTest.cpp \ common/network/InterfaceTest.cpp \ common/network/MACAddressTest.cpp \ diff --git a/include/ola/network/IPV4Address.h b/include/ola/network/IPV4Address.h index 06857af6f8..06139393d5 100644 --- a/include/ola/network/IPV4Address.h +++ b/include/ola/network/IPV4Address.h @@ -14,7 +14,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * IPV4Address.h - * Represents a IPv4 Address + * Represents an IPv4 Address * Copyright (C) 2011 Simon Newton */ diff --git a/include/ola/network/IPV6Address.h b/include/ola/network/IPV6Address.h new file mode 100644 index 0000000000..1409e3e382 --- /dev/null +++ b/include/ola/network/IPV6Address.h @@ -0,0 +1,238 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * IPV6Address.h + * Represents an IPv6 Address + * Copyright (C) 2023 Peter Newman + */ + +/** + * @addtogroup network + * @{ + * @file IPV6Address.h + * @brief Represents an IPv6 Address. + * @} + */ + +#ifndef INCLUDE_OLA_NETWORK_IPV6ADDRESS_H_ +#define INCLUDE_OLA_NETWORK_IPV6ADDRESS_H_ + +#include // Required by FreeBSD +#include // Required by FreeBSD +#include +#include +#include +#include + +namespace ola { +namespace network { + +/** + * @addtogroup network + * @{ + */ + +/** + * @brief Represents an IPv6 Address. + * + * All methods use network byte order unless otherwise mentioned. + */ +class IPV6Address { + public: + /** + * @brief The length in bytes of an IPv6 address. + */ + enum { LENGTH = 16 }; + + /** + * @brief Create a new IPv6 Address set to IN6ADDR_ANY_INIT (::). + */ + IPV6Address() { + m_address = IN6ADDR_ANY_INIT; + } + +// TODO(Peter): From uint128_t? + + /** + * @brief Construct a new IPv6 address from binary data. + * @param address a pointer to the memory containing the IPv6 address data. The + * data should be most significant byte first. + */ + explicit IPV6Address(const uint8_t *address); + + /** + * @brief Create a new IPv6 Address from a in6_addr struct. + * @param address the ip address, in network byte order. + */ + explicit IPV6Address(in6_addr address) { + m_address = address; + } + + /** + * @brief Copy constructor. + * @param other the IPV6Address to copy. + */ + IPV6Address(const IPV6Address &other) + : m_address(other.m_address) { + } + + /** + * @brief Assignment operator. + * @param other the IPV6Address to assign to this object. + */ + IPV6Address& operator=(const IPV6Address &other) { + if (this != &other) { + m_address = other.m_address; + } + return *this; + } + + /** + * @brief Equals operator. + * @param other the IPV6Address to compare. + * @returns true if both IPV6Addresses are equal. + */ + bool operator==(const IPV6Address &other) const { + return IN6_ARE_ADDR_EQUAL(&m_address, &other.m_address); + } + + /** + * @brief Not equals operator. + * @param other the IPV6Address to compare. + * @returns false if both IPV6Addresses are equal. + */ + bool operator!=(const IPV6Address &other) const { + return !(*this == other); + } + + /** + * @brief Less than operator for partial ordering. + */ + bool operator<(const IPV6Address &other) const; + + /** + * @brief Greater than operator. + */ + bool operator>(const IPV6Address &other) const; + + /** +// * @brief Return the IPV6Address as an int in network-byte order. +// * @returns An uint32 representing the IP address. + */ +// uint32_t AsInt() const { return m_address; } + + /** + * @brief Checks if this address is the wildcard address (::). + * @returns true if this address is the wildcard address. + */ + bool IsWildcard() const; + + /** + * @brief Copy the IPV6Address to a memory location. + * @param ptr the memory location to copy the address to. The location + * should be at least LENGTH bytes. + * @note The address is copied in network byte order. + */ + void Get(uint8_t ptr[LENGTH]) const { + memcpy(ptr, reinterpret_cast(&m_address.s6_addr[0]), LENGTH); + } + + /** + * @brief Write the binary representation of the IPv6 address to memory. + * @param buffer a pointer to memory to write the IPv6 address to + * @param length the size of the memory block, should be at least LENGTH. + * @returns true if length was >= LENGTH, false otherwise. + */ + bool Pack(uint8_t *buffer, unsigned int length) const { + if (length < LENGTH) + return false; + Get(buffer); + return true; + } + + /** + * @brief Convert the IPV6Address to a string. + * @returns the string representation of this IPV6Address. + */ + std::string ToString() const; + + /** + * @brief Write the string representation of this IPV6Address to an + * ostream. + * @param out the ostream to write to. + * @param address the address to write. + */ + friend std::ostream& operator<<(std::ostream &out, + const IPV6Address &address) { + return out << address.ToString(); + } + + /** + * @brief Convert a string to an IPV6Address. + * @param address the IP address string to convert. + * @returns a new IPV6Address or NULL if the string was invalid. The caller + * is responsible for deleting the IPV6Address object. + */ + static IPV6Address* FromString(const std::string &address); + + /** + * @brief Convert a string to an IPV6Address. + * @param address the IP address string to convert. + * @param[out] target the converted IPV6Address. + * @returns true if the string was a valid IPv6 address, false otherwise. + */ + static bool FromString(const std::string &address, IPV6Address *target); + + /** + * @brief Convert a string to an IPV6Address or abort. + * @note This should only be used within tests. + * @param address the IP address to convert. + * @return an IPV6Address matching the string. + */ + static IPV6Address FromStringOrDie(const std::string &address); + + /** +// * @brief Convert a subnet mask to its CIDR format value +// * @param address the subnet mask as an IPV6Address object + * @param mask the mask variable to populate + * @return true if we managed to convert the address to a CIDR value, false + otherwise + */ +// static bool ToCIDRMask(IPV6Address address, uint8_t *mask); + + /** + * @brief Returns the wildcard address IN6ADDR_ANY_INIT (::). + * @return an IPV6Address representing the wildcard address. + */ + static IPV6Address WildCard(); + + // TODO(Peter): Add support for the all-nodes link-local multicast group + + /** + * @brief Returns the loopback address (::1/128). + * @return an IPV6Address representing the loopback address. + */ + static IPV6Address Loopback(); + + private: + // TODO(Peter): Decide how to store the address internally... + in6_addr m_address; +}; +/** + * @} + */ +} // namespace network +} // namespace ola +#endif // INCLUDE_OLA_NETWORK_IPV6ADDRESS_H_ diff --git a/include/ola/network/Makefile.mk b/include/ola/network/Makefile.mk index fce6c1435d..f21c3533b7 100644 --- a/include/ola/network/Makefile.mk +++ b/include/ola/network/Makefile.mk @@ -3,6 +3,7 @@ olanetworkinclude_HEADERS = \ include/ola/network/AdvancedTCPConnector.h\ include/ola/network/HealthCheckedConnection.h \ include/ola/network/IPV4Address.h \ + include/ola/network/IPV6Address.h \ include/ola/network/Interface.h \ include/ola/network/InterfacePicker.h \ include/ola/network/MACAddress.h \ From 30490ee7aea849bfd0751750dcecd0062880abe7 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Mon, 18 Sep 2023 23:20:18 +0100 Subject: [PATCH 28/56] IPv6 preferences validator --- include/olad/Preferences.h | 16 +++++++++++++++ olad/plugin_api/Preferences.cpp | 29 +++++++++++++++++++++++++++ olad/plugin_api/PreferencesTest.cpp | 31 +++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) diff --git a/include/olad/Preferences.h b/include/olad/Preferences.h index 9c7ff4fa6b..65c921dca2 100644 --- a/include/olad/Preferences.h +++ b/include/olad/Preferences.h @@ -141,6 +141,22 @@ class IPv4Validator: public Validator { }; +/* + * Check an IPv6 address is valid + */ +class IPv6Validator: public Validator { + public: + explicit IPv6Validator(bool empty_ok = true): + m_empty_ok(empty_ok) {} + + bool IsValid(const std::string &value) const; + private: + bool m_empty_ok; + + DISALLOW_COPY_AND_ASSIGN(IPv6Validator); +}; + + /* * The abstract Preferences class */ diff --git a/olad/plugin_api/Preferences.cpp b/olad/plugin_api/Preferences.cpp index a2378f0a3d..32441b40d4 100644 --- a/olad/plugin_api/Preferences.cpp +++ b/olad/plugin_api/Preferences.cpp @@ -53,6 +53,7 @@ #include "ola/StringUtils.h" #include "ola/file/Util.h" #include "ola/network/IPV4Address.h" +#include "ola/network/IPV6Address.h" #include "ola/stl/STLUtils.h" #include "ola/thread/Thread.h" @@ -186,6 +187,34 @@ bool IPv4Validator::IsValid(const string &value) const { } +bool IPv6Validator::IsValid(const string &value) const { + if (value.empty()) { + return m_empty_ok; + } + + /*vector tokens; + // TODO(Peter): Deal with stuff like ::ffff:1.2.3.4 + // Maybe just fall back to the IPv6 string parsing for now...? + StringSplit(value, &tokens, ":"); + if (tokens.size() != ola::network::IPV6Address::LENGTH) { + return false; + } + + for (unsigned int i = 0 ; i < 4; i++) { + unsigned int octet; + if (!StringToInt(tokens[i], &octet)) { + return false; + } + if (octet > UINT8_MAX) { + return false; + } + } + return true;*/ + ola::network::IPV6Address validator_address; + return ola::network::IPV6Address::FromString(value, &validator_address); +} + + // Prefs Factory //----------------------------------------------------------------------------- diff --git a/olad/plugin_api/PreferencesTest.cpp b/olad/plugin_api/PreferencesTest.cpp index 9064444e19..051c1fa709 100644 --- a/olad/plugin_api/PreferencesTest.cpp +++ b/olad/plugin_api/PreferencesTest.cpp @@ -40,6 +40,7 @@ using ola::Preferences; using ola::SetValidator; using ola::StringValidator; using ola::IPv4Validator; +using ola::IPv6Validator; using std::string; using std::vector; @@ -131,6 +132,36 @@ void PreferencesTest::testValidators() { IPv4Validator ipv4_validator2(false); // empty not ok OLA_ASSERT_FALSE(ipv4_validator2.IsValid("")); + OLA_ASSERT(ipv4_validator2.IsValid("1.2.3.4")); + OLA_ASSERT(ipv4_validator2.IsValid("10.0.255.1")); + OLA_ASSERT_FALSE(ipv4_validator2.IsValid("foo")); + OLA_ASSERT_FALSE(ipv4_validator2.IsValid("1.2.3")); + OLA_ASSERT_FALSE(ipv4_validator2.IsValid("1.2.3.4.5")); + OLA_ASSERT_FALSE(ipv4_validator2.IsValid("1.f00.3.4")); + + IPv6Validator ipv6_validator; // empty ok + OLA_ASSERT(ipv6_validator.IsValid("")); + OLA_ASSERT(ipv6_validator.IsValid("2001:db8:1234:5678:90ab:cdef:feed:face")); + OLA_ASSERT(ipv6_validator.IsValid("::ffff:1.2.3.4")); + OLA_ASSERT(ipv6_validator.IsValid("::ffff:10.0.255.1")); + OLA_ASSERT_FALSE(ipv6_validator.IsValid("foo")); + OLA_ASSERT_FALSE(ipv6_validator.IsValid("2001:db8:1234:5678:90ab:cdef:feed:face:0000")); + OLA_ASSERT_FALSE(ipv6_validator.IsValid("2001:db8:1234:5678:90ab:cdef:feed:gggg")); + OLA_ASSERT_FALSE(ipv6_validator.IsValid("::ffff:1.2.3")); + OLA_ASSERT_FALSE(ipv6_validator.IsValid("::ffff:1.2.3.4.5")); + OLA_ASSERT_FALSE(ipv6_validator.IsValid("::ffff:1.f00.3.4")); + + IPv6Validator ipv6_validator2(false); // empty not ok + OLA_ASSERT_FALSE(ipv6_validator2.IsValid("")); + OLA_ASSERT(ipv6_validator2.IsValid("2001:db8:1234:5678:90ab:cdef:feed:face")); + OLA_ASSERT(ipv6_validator2.IsValid("::ffff:1.2.3.4")); + OLA_ASSERT(ipv6_validator2.IsValid("::ffff:10.0.255.1")); + OLA_ASSERT_FALSE(ipv6_validator2.IsValid("foo")); + OLA_ASSERT_FALSE(ipv6_validator2.IsValid("2001:db8:1234:5678:90ab:cdef:feed:face:0000")); + OLA_ASSERT_FALSE(ipv6_validator2.IsValid("2001:db8:1234:5678:90ab:cdef:feed:gggg")); + OLA_ASSERT_FALSE(ipv6_validator2.IsValid("::ffff:1.2.3")); + OLA_ASSERT_FALSE(ipv6_validator2.IsValid("::ffff:1.2.3.4.5")); + OLA_ASSERT_FALSE(ipv6_validator2.IsValid("::ffff:1.f00.3.4")); } From 8f5b1931dbc72136e821cf168f5338a6ae0e3290 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Tue, 19 Sep 2023 15:44:05 +0100 Subject: [PATCH 29/56] Do some minor formatting tweaks --- libs/acn/DMPE131Inflator.cpp | 67 +++++++++++++++++------------ libs/acn/DMPE131Inflator.h | 82 ++++++++++++++++++------------------ 2 files changed, 80 insertions(+), 69 deletions(-) diff --git a/libs/acn/DMPE131Inflator.cpp b/libs/acn/DMPE131Inflator.cpp index 3e11c3e4b2..58aea78a58 100644 --- a/libs/acn/DMPE131Inflator.cpp +++ b/libs/acn/DMPE131Inflator.cpp @@ -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(); @@ -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(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. @@ -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()) { @@ -156,8 +160,9 @@ bool DMPE131Inflator::HandlePDUData(uint32_t vector, universe_iter->second.buffer->Reset(); std::vector::const_iterator source_iter = universe_iter->second.sources.begin(); - for (; source_iter != universe_iter->second.sources.end(); ++source_iter) + 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; @@ -175,8 +180,9 @@ bool DMPE131Inflator::SetHandler(uint16_t universe, ola::DmxBuffer *buffer, uint8_t *priority, ola::Callback0 *closure) { - if (!closure || !buffer) + if (!closure || !buffer) { return false; + } UniverseHandlers::iterator iter = m_handlers.find(universe); @@ -265,38 +271,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(universe_data->active_priority) << " to " << - static_cast(priority); + OLA_INFO << "Raising priority for universe " << e131_header.Universe() + << " from " << static_cast(universe_data->active_priority) + << " to " << static_cast(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(); @@ -311,19 +320,21 @@ bool DMPE131Inflator::TrackSourceIfRequired( int8_t seq_diff = static_cast(e131_header.Sequence() - iter->sequence); if (seq_diff <= 0 && seq_diff > SEQUENCE_DIFF_THRESHOLD) { - OLA_INFO << "Old packet received, ignoring, this # " << - static_cast(e131_header.Sequence()) << ", last " << - static_cast(iter->sequence); + OLA_INFO << "Old packet received, ignoring, this # " + << static_cast(e131_header.Sequence()) << ", last " + << static_cast(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; diff --git a/libs/acn/DMPE131Inflator.h b/libs/acn/DMPE131Inflator.h index 35b62d845b..e1185b653b 100644 --- a/libs/acn/DMPE131Inflator.h +++ b/libs/acn/DMPE131Inflator.h @@ -36,58 +36,58 @@ class DMPE131Inflator: public DMPInflator { friend class DMPE131InflatorTest; public: - explicit DMPE131Inflator(bool ignore_preview): - DMPInflator(), - m_ignore_preview(ignore_preview) { - } - ~DMPE131Inflator(); + explicit DMPE131Inflator(bool ignore_preview): + DMPInflator(), + m_ignore_preview(ignore_preview) { + } + ~DMPE131Inflator(); - bool SetHandler(uint16_t universe, ola::DmxBuffer *buffer, - uint8_t *priority, ola::Callback0 *handler); - bool RemoveHandler(uint16_t universe); + bool SetHandler(uint16_t universe, ola::DmxBuffer *buffer, + uint8_t *priority, ola::Callback0 *handler); + bool RemoveHandler(uint16_t universe); - void RegisteredUniverses(std::vector *universes); + void RegisteredUniverses(std::vector *universes); protected: - virtual bool HandlePDUData(uint32_t vector, - const HeaderSet &headers, - const uint8_t *data, - unsigned int pdu_len); + virtual bool HandlePDUData(uint32_t vector, + const HeaderSet &headers, + const uint8_t *data, + unsigned int pdu_len); private: - typedef struct { - ola::acn::CID cid; - uint8_t sequence; - TimeStamp last_heard_from; - DmxBuffer buffer; - } dmx_source; + typedef struct { + ola::acn::CID cid; + uint8_t sequence; + TimeStamp last_heard_from; + DmxBuffer buffer; + } dmx_source; - typedef struct { - DmxBuffer *buffer; - Callback0 *closure; - uint8_t active_priority; - uint8_t *priority; - std::vector sources; - } universe_handler; + typedef struct { + DmxBuffer *buffer; + Callback0 *closure; + uint8_t active_priority; + uint8_t *priority; + std::vector sources; + } universe_handler; - typedef std::map UniverseHandlers; + typedef std::map UniverseHandlers; - UniverseHandlers m_handlers; - bool m_ignore_preview; - ola::Clock m_clock; + UniverseHandlers m_handlers; + bool m_ignore_preview; + ola::Clock m_clock; - bool TrackSourceIfRequired(universe_handler *universe_data, - const HeaderSet &headers, - DmxBuffer **buffer); + bool TrackSourceIfRequired(universe_handler *universe_data, + const HeaderSet &headers, + DmxBuffer **buffer); - // The max number of sources we'll track per universe. - static const uint8_t MAX_MERGE_SOURCES = 6; - // The max merge priority. - static const uint8_t MAX_E131_PRIORITY = 200; - // ignore packets that differ by less than this amount from the last one - static const int8_t SEQUENCE_DIFF_THRESHOLD = -20; - // expire sources after 2.5s - static const TimeInterval EXPIRY_INTERVAL; + // The max number of sources we'll track per universe. + static const uint8_t MAX_MERGE_SOURCES = 6; + // The max merge priority. + static const uint8_t MAX_E131_PRIORITY = 200; + // ignore packets that differ by less than this amount from the last one + static const int8_t SEQUENCE_DIFF_THRESHOLD = -20; + // expire sources after 2.5s + static const TimeInterval EXPIRY_INTERVAL; }; } // namespace acn } // namespace ola From 2f8ea5f6c17e0dae2e1587355e6db458558a7d37 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Tue, 19 Sep 2023 18:19:50 +0100 Subject: [PATCH 30/56] Fix some more typos Codespell found --- include/ola/io/MemoryBlock.h | 2 +- include/ola/rdm/StringMessageBuilder.h | 2 +- plugins/usbpro/DmxterWidget.cpp | 2 +- plugins/usbpro/DmxterWidget.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/ola/io/MemoryBlock.h b/include/ola/io/MemoryBlock.h index 464fdfd77b..2a053d52bb 100644 --- a/include/ola/io/MemoryBlock.h +++ b/include/ola/io/MemoryBlock.h @@ -63,7 +63,7 @@ class MemoryBlock { /** * @brief Move the insertation point to the end of the block. - * This is useful if you want to use the block in pre-pend mode. + * This is useful if you want to use the block in prepend mode. */ void SeekBack() { m_first = m_data_end; diff --git a/include/ola/rdm/StringMessageBuilder.h b/include/ola/rdm/StringMessageBuilder.h index 4f08afc85e..f66187e682 100644 --- a/include/ola/rdm/StringMessageBuilder.h +++ b/include/ola/rdm/StringMessageBuilder.h @@ -22,7 +22,7 @@ * @addtogroup rdm_helpers * @{ * @file include/ola/rdm/StringMessageBuilder.h - * @brief Builds a Messagse object from a list of strings and a Descriptor. + * @brief Builds a Message object from a list of strings and a Descriptor. * @} */ diff --git a/plugins/usbpro/DmxterWidget.cpp b/plugins/usbpro/DmxterWidget.cpp index aae5f95645..4b061aa3b9 100644 --- a/plugins/usbpro/DmxterWidget.cpp +++ b/plugins/usbpro/DmxterWidget.cpp @@ -325,7 +325,7 @@ void DmxterWidgetImpl::HandleRDMResponse(const uint8_t *data, case RC_NACK_FORMAT_ERROR: case RC_NACK_HARDWARE_FAULT: case RC_NACK_PROXY_REJECT: - case RC_NACK_WRITE_PROECT: + case RC_NACK_WRITE_PROTECT: case RC_NACK_COMMAND_CLASS: case RC_NACK_DATA_RANGE: case RC_NACK_BUFFER_FULL: diff --git a/plugins/usbpro/DmxterWidget.h b/plugins/usbpro/DmxterWidget.h index 44cde56723..3e48ef1763 100644 --- a/plugins/usbpro/DmxterWidget.h +++ b/plugins/usbpro/DmxterWidget.h @@ -107,7 +107,7 @@ class DmxterWidgetImpl: public BaseUsbProWidget, RC_NACK_FORMAT_ERROR = 25, RC_NACK_HARDWARE_FAULT = 26, RC_NACK_PROXY_REJECT = 27, - RC_NACK_WRITE_PROECT = 28, + RC_NACK_WRITE_PROTECT = 28, RC_NACK_COMMAND_CLASS = 29, RC_NACK_DATA_RANGE = 30, RC_NACK_BUFFER_FULL = 31, From 030a4fdb0348898ab6dbba546643890567b02b21 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Wed, 20 Sep 2023 11:23:16 +0100 Subject: [PATCH 31/56] Fix a lint issue and another minor tidy --- libs/acn/DMPE131Inflator.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libs/acn/DMPE131Inflator.cpp b/libs/acn/DMPE131Inflator.cpp index 58aea78a58..ed011161d8 100644 --- a/libs/acn/DMPE131Inflator.cpp +++ b/libs/acn/DMPE131Inflator.cpp @@ -159,8 +159,9 @@ bool DMPE131Inflator::HandlePDUData(uint32_t vector, // HTP Merge universe_iter->second.buffer->Reset(); std::vector::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(); From 3cc129222b65bf376d1e7c103fc5ab1a8432f0e1 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Wed, 20 Sep 2023 11:36:37 +0100 Subject: [PATCH 32/56] Fix some lint issues --- common/network/IPV6Address.cpp | 20 ++++++++++-------- common/network/IPV6AddressTest.cpp | 33 ++++++++++++++++++++---------- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/common/network/IPV6Address.cpp b/common/network/IPV6Address.cpp index 82a2b6e173..664cae6742 100644 --- a/common/network/IPV6Address.cpp +++ b/common/network/IPV6Address.cpp @@ -49,20 +49,24 @@ namespace network { using std::string; IPV6Address::IPV6Address(const uint8_t *address) { - // TODO(Peter): Deal with network byte order? + // TODO(Peter): Deal with any network byte order conversion? memcpy(&m_address.s6_addr[0], address, sizeof (struct in6_addr)); } bool IPV6Address::operator<(const IPV6Address &other) const { - // TODO(Peter): Deal with network byte order? + // TODO(Peter): Deal with any network byte order conversion? // Stored in network byte order, so convert to sort appropriately - return (memcmp(&m_address.s6_addr[0], &other.m_address.s6_addr[0], sizeof (struct in6_addr)) < 0); + return (memcmp(&m_address.s6_addr[0], + &other.m_address.s6_addr[0], + sizeof (struct in6_addr)) < 0); } bool IPV6Address::operator>(const IPV6Address &other) const { - // TODO(Peter): Deal with network byte order? + // TODO(Peter): Deal with any network byte order conversion? // Stored in network byte order, so convert to sort appropriately - return (memcmp(&m_address.s6_addr[0], &other.m_address.s6_addr[0], sizeof (struct in6_addr)) > 0); + return (memcmp(&m_address.s6_addr[0], + &other.m_address.s6_addr[0], + sizeof (struct in6_addr)) > 0); } bool IPV6StringToAddress(const string &address, struct in6_addr *addr) { @@ -154,14 +158,14 @@ IPV6Address IPV6Address::FromStringOrDie(const string &address) { IPV6Address IPV6Address::WildCard() { in6_addr wildCard = IN6ADDR_ANY_INIT; - // TODO(Peter): Deal with host to network conversion... + // TODO(Peter): Deal with any host to network conversion... return IPV6Address(wildCard); } IPV6Address IPV6Address::Loopback() { in6_addr loopback = IN6ADDR_LOOPBACK_INIT; - // TODO(Peter): Deal with host to network conversion... - //return IPV6Address(HostToNetwork(IN6ADDR_LOOPBACK_INIT)); + // TODO(Peter): Deal with any host to network conversion... + // return IPV6Address(HostToNetwork(IN6ADDR_LOOPBACK_INIT)); return IPV6Address(loopback); } } // namespace network diff --git a/common/network/IPV6AddressTest.cpp b/common/network/IPV6AddressTest.cpp index 72880788e1..05400cb82a 100644 --- a/common/network/IPV6AddressTest.cpp +++ b/common/network/IPV6AddressTest.cpp @@ -71,18 +71,21 @@ void IPV6AddressTest::testIPV6Address() { // OLA_ASSERT_EQ(HostToNetwork(0xc0a80101), static_cast(ip_as_int)); OLA_ASSERT_EQ(string("::ffff:192.168.1.1"), address1.ToString()); - IPV6Address address2 = IPV6Address::FromStringOrDie("2001:db8:1234:5678:90ab:cdef:feed:face"); + IPV6Address address2 = IPV6Address::FromStringOrDie( + "2001:db8:1234:5678:90ab:cdef:feed:face"); // int ip_as_int = address2.AsInt(); OLA_ASSERT_NE(wildcard_address, address2); // OLA_ASSERT_NE(HostToNetwork(0xc0a811), ip_as_int); // OLA_ASSERT_EQ(HostToNetwork(0xc0a80101), static_cast(ip_as_int)); - const uint8_t big_endian_address_data[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 10, 0, 0, 1}; + const uint8_t big_endian_address_data[] = + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 10, 0, 0, 1}; IPV6Address binary_address(big_endian_address_data); OLA_ASSERT_EQ(string("::ffff:10.0.0.1"), binary_address.ToString()); // Test Get() - uint8_t address_data[] = {32, 1, 13, 184, 18, 52, 86, 120, 144, 171, 205, 239, 254, 237, 250, 206}; + uint8_t address_data[] = {32, 1, 13, 184, 18, 52, 86, 120, + 144, 171, 205, 239, 254, 237, 250, 206}; uint8_t addr[IPV6Address::LENGTH]; address2.Get(addr); OLA_ASSERT_DATA_EQUALS(addr, @@ -103,7 +106,8 @@ void IPV6AddressTest::testIPV6Address() { OLA_ASSERT_EQ(string("::ffff:192.168.1.1"), str.str()); // test from string - auto_ptr string_address(IPV6Address::FromString("::ffff:10.0.0.1")); + auto_ptr string_address( + IPV6Address::FromString("::ffff:10.0.0.1")); OLA_ASSERT_NOT_NULL(string_address.get()); OLA_ASSERT_EQ(string("::ffff:10.0.0.1"), string_address->ToString()); @@ -112,18 +116,23 @@ void IPV6AddressTest::testIPV6Address() { // and the second form IPV6Address string_address3; - OLA_ASSERT_TRUE(IPV6Address::FromString("::ffff:172.16.4.1", &string_address3)); + OLA_ASSERT_TRUE(IPV6Address::FromString( + "::ffff:172.16.4.1", &string_address3)); OLA_ASSERT_EQ(string("::ffff:172.16.4.1"), string_address3.ToString()); IPV6Address string_address4; // Add the leading zero to the second group - OLA_ASSERT_TRUE(IPV6Address::FromString("2001:0db8:1234:5678:90ab:cdef:feed:face", &string_address4)); + OLA_ASSERT_TRUE(IPV6Address::FromString( + "2001:0db8:1234:5678:90ab:cdef:feed:face", &string_address4)); // Confirm it's not rendered when we convert to a string - OLA_ASSERT_EQ(string("2001:db8:1234:5678:90ab:cdef:feed:face"), string_address4.ToString()); + OLA_ASSERT_EQ(string("2001:db8:1234:5678:90ab:cdef:feed:face"), + string_address4.ToString()); IPV6Address string_address5; - OLA_ASSERT_TRUE(IPV6Address::FromString("2001:db8:dead:beef:dead:beef:dead:beef", &string_address5)); - OLA_ASSERT_EQ(string("2001:db8:dead:beef:dead:beef:dead:beef"), string_address5.ToString()); + OLA_ASSERT_TRUE(IPV6Address::FromString( + "2001:db8:dead:beef:dead:beef:dead:beef", &string_address5)); + OLA_ASSERT_EQ(string("2001:db8:dead:beef:dead:beef:dead:beef"), + string_address5.ToString()); IPV6Address string_address6; OLA_ASSERT_FALSE(IPV6Address::FromString("", &string_address6)); @@ -141,8 +150,10 @@ void IPV6AddressTest::testIPV6Address() { OLA_ASSERT_EQ(string("::ffff:10.0.0.1"), addresses[0].ToString()); OLA_ASSERT_EQ(string("::ffff:172.16.4.1"), addresses[1].ToString()); OLA_ASSERT_EQ(string("::ffff:192.168.1.1"), addresses[2].ToString()); - OLA_ASSERT_EQ(string("2001:db8:1234:5678:90ab:cdef:feed:face"), addresses[3].ToString()); - OLA_ASSERT_EQ(string("2001:db8:dead:beef:dead:beef:dead:beef"), addresses[4].ToString()); + OLA_ASSERT_EQ(string("2001:db8:1234:5678:90ab:cdef:feed:face"), + addresses[3].ToString()); + OLA_ASSERT_EQ(string("2001:db8:dead:beef:dead:beef:dead:beef"), + addresses[4].ToString()); /* uint8_t mask = 255; // UINT8_MAX; OLA_ASSERT_TRUE( From 87b1318ded6947d78be62ee8fda429305558f94b Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Wed, 20 Sep 2023 12:57:57 +0100 Subject: [PATCH 33/56] Fix the outstanding lint issues --- include/ola/network/IPV6Address.h | 4 +++- olad/plugin_api/PreferencesTest.cpp | 15 ++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/ola/network/IPV6Address.h b/include/ola/network/IPV6Address.h index 1409e3e382..23f6000c25 100644 --- a/include/ola/network/IPV6Address.h +++ b/include/ola/network/IPV6Address.h @@ -146,7 +146,9 @@ class IPV6Address { * @note The address is copied in network byte order. */ void Get(uint8_t ptr[LENGTH]) const { - memcpy(ptr, reinterpret_cast(&m_address.s6_addr[0]), LENGTH); + memcpy(ptr, + reinterpret_cast(&m_address.s6_addr[0]), + LENGTH); } /** diff --git a/olad/plugin_api/PreferencesTest.cpp b/olad/plugin_api/PreferencesTest.cpp index 051c1fa709..812863c57e 100644 --- a/olad/plugin_api/PreferencesTest.cpp +++ b/olad/plugin_api/PreferencesTest.cpp @@ -145,20 +145,25 @@ void PreferencesTest::testValidators() { OLA_ASSERT(ipv6_validator.IsValid("::ffff:1.2.3.4")); OLA_ASSERT(ipv6_validator.IsValid("::ffff:10.0.255.1")); OLA_ASSERT_FALSE(ipv6_validator.IsValid("foo")); - OLA_ASSERT_FALSE(ipv6_validator.IsValid("2001:db8:1234:5678:90ab:cdef:feed:face:0000")); - OLA_ASSERT_FALSE(ipv6_validator.IsValid("2001:db8:1234:5678:90ab:cdef:feed:gggg")); + OLA_ASSERT_FALSE(ipv6_validator.IsValid( + "2001:db8:1234:5678:90ab:cdef:feed:face:0000")); + OLA_ASSERT_FALSE(ipv6_validator.IsValid( + "2001:db8:1234:5678:90ab:cdef:feed:gggg")); OLA_ASSERT_FALSE(ipv6_validator.IsValid("::ffff:1.2.3")); OLA_ASSERT_FALSE(ipv6_validator.IsValid("::ffff:1.2.3.4.5")); OLA_ASSERT_FALSE(ipv6_validator.IsValid("::ffff:1.f00.3.4")); IPv6Validator ipv6_validator2(false); // empty not ok OLA_ASSERT_FALSE(ipv6_validator2.IsValid("")); - OLA_ASSERT(ipv6_validator2.IsValid("2001:db8:1234:5678:90ab:cdef:feed:face")); + OLA_ASSERT(ipv6_validator2.IsValid( + "2001:db8:1234:5678:90ab:cdef:feed:face")); OLA_ASSERT(ipv6_validator2.IsValid("::ffff:1.2.3.4")); OLA_ASSERT(ipv6_validator2.IsValid("::ffff:10.0.255.1")); OLA_ASSERT_FALSE(ipv6_validator2.IsValid("foo")); - OLA_ASSERT_FALSE(ipv6_validator2.IsValid("2001:db8:1234:5678:90ab:cdef:feed:face:0000")); - OLA_ASSERT_FALSE(ipv6_validator2.IsValid("2001:db8:1234:5678:90ab:cdef:feed:gggg")); + OLA_ASSERT_FALSE(ipv6_validator2.IsValid( + "2001:db8:1234:5678:90ab:cdef:feed:face:0000")); + OLA_ASSERT_FALSE(ipv6_validator2.IsValid( + "2001:db8:1234:5678:90ab:cdef:feed:gggg")); OLA_ASSERT_FALSE(ipv6_validator2.IsValid("::ffff:1.2.3")); OLA_ASSERT_FALSE(ipv6_validator2.IsValid("::ffff:1.2.3.4.5")); OLA_ASSERT_FALSE(ipv6_validator2.IsValid("::ffff:1.f00.3.4")); From 155d5391cabdd58cd6db58eb8c4771dc8a71f76e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Sep 2023 21:38:12 +0000 Subject: [PATCH 34/56] Bump actions/checkout from 3 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] (cherry picked from commit e85896d4d10e11eb67a95c9c4ec31ffe47111d51) --- .github/workflows/build.yaml | 4 ++-- .github/workflows/debian.yml | 4 ++-- .github/workflows/isort.yml | 2 +- .github/workflows/lint.yaml | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index fb0bfe819e..8408df474e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -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: | diff --git a/.github/workflows/debian.yml b/.github/workflows/debian.yml index dbf285ba85..0ae5317ba0 100644 --- a/.github/workflows/debian.yml +++ b/.github/workflows/debian.yml @@ -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 diff --git a/.github/workflows/isort.yml b/.github/workflows/isort.yml index f314e5b555..9aff6b16d1 100644 --- a/.github/workflows/isort.yml +++ b/.github/workflows/isort.yml @@ -8,5 +8,5 @@ jobs: isort: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: isort/isort-action@v1 diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 731f617f5c..0c49e768a0 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -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: | @@ -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: From af3a814e9e297dc07ee8c9e730a0d273698ece80 Mon Sep 17 00:00:00 2001 From: Perry Naseck Date: Tue, 10 Oct 2023 16:59:36 -0400 Subject: [PATCH 35/56] fix codespell typo --- common/web/SchemaParser.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/web/SchemaParser.h b/common/web/SchemaParser.h index dfbd34f44a..ba49dba29e 100644 --- a/common/web/SchemaParser.h +++ b/common/web/SchemaParser.h @@ -91,7 +91,7 @@ class SchemaParser : public JsonParserInterface { /** * @brief Claim the RootValidator that was created by parsing the schema. * @returns A new Validator, or NULL if the schema wasn't valid. Ownership of - * the validtor is transferred to the caller. + * the validator is transferred to the caller. */ ValidatorInterface* ClaimRootValidator(); From 3b18f4e4a24acadfc6f3a092fd427ce7c408c4ce Mon Sep 17 00:00:00 2001 From: Perry Naseck Date: Tue, 10 Oct 2023 17:06:38 -0400 Subject: [PATCH 36/56] fix flake8 errors --- python/ola/StringUtils.py | 6 +++--- tools/rdm/ResponderTest.py | 6 +++--- tools/rdm/TestHelpers.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/python/ola/StringUtils.py b/python/ola/StringUtils.py index a0f51cfafd..4a4d7dd7de 100644 --- a/python/ola/StringUtils.py +++ b/python/ola/StringUtils.py @@ -32,11 +32,11 @@ def StringEscape(s): """Escape unprintable characters in a string.""" # TODO(Peter): How does this interact with the E1.20 Unicode flag? # We don't use sys.version_info.major to support Python 2.6. - if sys.version_info[0] == 2 and type(s) == str: + if sys.version_info[0] == 2 and isinstance(s, str): return s.encode('string-escape') - elif sys.version_info[0] == 2 and type(s) == unicode: + elif sys.version_info[0] == 2 and isinstance(s, unicode): return s.encode('unicode-escape') - elif type(s) == str: + elif isinstance(s, str): # All strings in Python 3 are unicode # This encode/decode pair gets us an escaped string return s.encode('unicode-escape').decode(encoding="ascii", diff --git a/tools/rdm/ResponderTest.py b/tools/rdm/ResponderTest.py index 93490306ff..23a6f532da 100644 --- a/tools/rdm/ResponderTest.py +++ b/tools/rdm/ResponderTest.py @@ -612,15 +612,15 @@ def _CheckForAckOrNack(self, response, unpacked_data, unpack_exception): return True def _EscapeData(self, data): - if type(data) == list: + if isinstance(data, list): return [self._EscapeData(i) for i in data] - elif type(data) == dict: + elif isinstance(data, dict): d = {} for k, v in data.items(): # We can't escape the key as then it may become a new key d[k] = self._EscapeData(v) return d - elif type(data) == str or type(data) == unicode: + elif isinstance(data, str) or isinstance(data, unicode): return StringEscape(data) else: return data diff --git a/tools/rdm/TestHelpers.py b/tools/rdm/TestHelpers.py index 51eb606de7..4a157bcf63 100644 --- a/tools/rdm/TestHelpers.py +++ b/tools/rdm/TestHelpers.py @@ -31,7 +31,7 @@ def ContainsUnprintable(s): """Check if a string s contain unprintable characters.""" # TODO(Peter): How does this interact with the E1.20 Unicode flag? - if type(s) == str or type(s) == unicode: + if isinstance(s, str) or isinstance(s, unicode): # All strings in Python 3 are unicode, Python 2 ones might not be return s != StringEscape(s) else: From 66923704b6f5a21ae2b5cc09fa05b6b9b7368f58 Mon Sep 17 00:00:00 2001 From: Ken Harris Date: Thu, 19 Oct 2023 20:07:11 +0000 Subject: [PATCH 37/56] Fix spelling/grammar in RPC error message --- common/rpc/RpcChannel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/rpc/RpcChannel.cpp b/common/rpc/RpcChannel.cpp index 7d1c81d6fd..10b5211e93 100644 --- a/common/rpc/RpcChannel.cpp +++ b/common/rpc/RpcChannel.cpp @@ -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; } From 88cabc9eedd794ac689d60f01d6d9c4c892f3347 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Mon, 23 Oct 2023 10:39:15 +0100 Subject: [PATCH 38/56] Resolve the review comment --- common/network/IPV6Address.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/common/network/IPV6Address.cpp b/common/network/IPV6Address.cpp index 664cae6742..5a46d953cc 100644 --- a/common/network/IPV6Address.cpp +++ b/common/network/IPV6Address.cpp @@ -55,7 +55,6 @@ IPV6Address::IPV6Address(const uint8_t *address) { bool IPV6Address::operator<(const IPV6Address &other) const { // TODO(Peter): Deal with any network byte order conversion? - // Stored in network byte order, so convert to sort appropriately return (memcmp(&m_address.s6_addr[0], &other.m_address.s6_addr[0], sizeof (struct in6_addr)) < 0); @@ -63,7 +62,6 @@ bool IPV6Address::operator<(const IPV6Address &other) const { bool IPV6Address::operator>(const IPV6Address &other) const { // TODO(Peter): Deal with any network byte order conversion? - // Stored in network byte order, so convert to sort appropriately return (memcmp(&m_address.s6_addr[0], &other.m_address.s6_addr[0], sizeof (struct in6_addr)) > 0); From 27b40d2d38c4d6fe963cd7c93a54b984d555b8cc Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 28 Oct 2023 15:02:49 +0100 Subject: [PATCH 39/56] Fix a typo --- include/ola/network/HealthCheckedConnection.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ola/network/HealthCheckedConnection.h b/include/ola/network/HealthCheckedConnection.h index a4311f51eb..cbbe33e351 100644 --- a/include/ola/network/HealthCheckedConnection.h +++ b/include/ola/network/HealthCheckedConnection.h @@ -75,7 +75,7 @@ class HealthCheckedConnection { /** * Call this when a heartbeat is piggybacked on another message. This - * prevents sending heatbeats unless necessary. + * prevents sending heartbeats unless necessary. */ void HeartbeatSent(); From 2a2ab67f5fe6160ab45c43a25d97f4b69a135a2d Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 3 Dec 2023 01:10:09 +0000 Subject: [PATCH 40/56] Add support for the IPv6 data type to the RDM messaging and the additional E1.33 and E1.37-7 PIDs that enables --- common/messaging/DescriptorTest.cpp | 8 + common/messaging/MessagePrinter.cpp | 7 + common/messaging/MessagePrinterTest.cpp | 23 ++- common/messaging/SchemaPrinter.cpp | 6 + common/messaging/SchemaPrinterTest.cpp | 6 +- common/rdm/DescriptorConsistencyChecker.cpp | 5 + common/rdm/DescriptorConsistencyChecker.h | 1 + common/rdm/GroupSizeCalculator.cpp | 12 ++ common/rdm/GroupSizeCalculator.h | 2 + common/rdm/GroupSizeCalculatorTest.cpp | 12 +- common/rdm/MessageDeserializer.cpp | 31 ++- common/rdm/MessageDeserializerTest.cpp | 29 ++- common/rdm/MessageSerializer.cpp | 9 + common/rdm/MessageSerializerTest.cpp | 6 +- common/rdm/PidStoreLoader.cpp | 3 + common/rdm/Pids.proto | 1 + common/rdm/StringMessageBuilder.cpp | 40 +++- common/rdm/StringMessageBuilderTest.cpp | 12 +- common/rdm/VariableFieldSizeCalculator.cpp | 6 + common/rdm/VariableFieldSizeCalculator.h | 1 + data/rdm/pids.proto | 192 +++++++++++++++++++ include/ola/messaging/Descriptor.h | 20 ++ include/ola/messaging/DescriptorVisitor.h | 2 + include/ola/messaging/Message.h | 27 +++ include/ola/messaging/MessagePrinter.h | 2 + include/ola/messaging/MessageVisitor.h | 2 + include/ola/messaging/SchemaPrinter.h | 1 + include/ola/messaging/StringMessageBuilder.h | 1 + include/ola/rdm/MessageDeserializer.h | 1 + include/ola/rdm/MessageSerializer.h | 1 + include/ola/rdm/StringMessageBuilder.h | 1 + python/ola/PidStore.py | 24 +++ python/ola/PidStoreTest.py | 2 + 33 files changed, 461 insertions(+), 35 deletions(-) diff --git a/common/messaging/DescriptorTest.cpp b/common/messaging/DescriptorTest.cpp index 9c1bbcde44..37cce39c97 100644 --- a/common/messaging/DescriptorTest.cpp +++ b/common/messaging/DescriptorTest.cpp @@ -34,6 +34,7 @@ using ola::messaging::BoolFieldDescriptor; using ola::messaging::FieldDescriptor; using ola::messaging::FieldDescriptorGroup; using ola::messaging::IPV4FieldDescriptor; +using ola::messaging::IPV6FieldDescriptor; using ola::messaging::MACFieldDescriptor; using ola::messaging::StringFieldDescriptor; using ola::messaging::UIDFieldDescriptor; @@ -77,6 +78,13 @@ void DescriptorTest::testFieldDescriptors() { OLA_ASSERT_TRUE(ipv4_descriptor.LimitedSize()); OLA_ASSERT_EQ(4u, ipv4_descriptor.MaxSize()); + // IPv6 address + IPV6FieldDescriptor ipv6_descriptor("ipv6"); + OLA_ASSERT_EQ(string("ipv6"), ipv6_descriptor.Name()); + OLA_ASSERT_TRUE(ipv6_descriptor.FixedSize()); + OLA_ASSERT_TRUE(ipv6_descriptor.LimitedSize()); + OLA_ASSERT_EQ(16u, ipv6_descriptor.MaxSize()); + // MAC address MACFieldDescriptor mac_descriptor("mac"); OLA_ASSERT_EQ(string("mac"), mac_descriptor.Name()); diff --git a/common/messaging/MessagePrinter.cpp b/common/messaging/MessagePrinter.cpp index 07226b96fe..20e9ef1d89 100644 --- a/common/messaging/MessagePrinter.cpp +++ b/common/messaging/MessagePrinter.cpp @@ -58,6 +58,13 @@ void GenericMessagePrinter::Visit(const IPV4MessageField *message) { } +void GenericMessagePrinter::Visit(const IPV6MessageField *message) { + Stream() << string(m_indent, ' ') << + TransformLabel(message->GetDescriptor()->Name()) << ": " + << message->Value() << endl; +} + + void GenericMessagePrinter::Visit(const MACMessageField *message) { Stream() << string(m_indent, ' ') << TransformLabel(message->GetDescriptor()->Name()) << ": " diff --git a/common/messaging/MessagePrinterTest.cpp b/common/messaging/MessagePrinterTest.cpp index 0fdc2c2519..5484370aa0 100644 --- a/common/messaging/MessagePrinterTest.cpp +++ b/common/messaging/MessagePrinterTest.cpp @@ -32,8 +32,9 @@ using std::string; using std::vector; -using ola::rdm::UID; +using ola::network::IPV6Address; using ola::network::MACAddress; +using ola::rdm::UID; using ola::messaging::BoolFieldDescriptor; @@ -42,14 +43,16 @@ using ola::messaging::FieldDescriptor; using ola::messaging::FieldDescriptorGroup; using ola::messaging::GenericMessagePrinter; using ola::messaging::GroupMessageField; -using ola::messaging::Int16FieldDescriptor; -using ola::messaging::Int16MessageField; -using ola::messaging::Int8FieldDescriptor; -using ola::messaging::Int8MessageField; using ola::messaging::IPV4FieldDescriptor; using ola::messaging::IPV4MessageField; +using ola::messaging::IPV6FieldDescriptor; +using ola::messaging::IPV6MessageField; using ola::messaging::MACFieldDescriptor; using ola::messaging::MACMessageField; +using ola::messaging::Int16FieldDescriptor; +using ola::messaging::Int16MessageField; +using ola::messaging::Int8FieldDescriptor; +using ola::messaging::Int8MessageField; using ola::messaging::Message; using ola::messaging::MessageFieldInterface; using ola::messaging::StringFieldDescriptor; @@ -90,6 +93,7 @@ void GenericMessagePrinterTest::testSimplePrinter() { // setup some fields BoolFieldDescriptor bool_descriptor("On/Off"); IPV4FieldDescriptor ipv4_descriptor("ip"); + IPV6FieldDescriptor ipv6_descriptor("ipv6"); MACFieldDescriptor mac_descriptor("mac"); UIDFieldDescriptor uid_descriptor("uid"); StringFieldDescriptor string_descriptor("Name", 0, 32); @@ -104,6 +108,9 @@ void GenericMessagePrinterTest::testSimplePrinter() { fields.push_back( new IPV4MessageField(&ipv4_descriptor, ola::network::HostToNetwork(0x0a000001))); + fields.push_back( + new IPV6MessageField(&ipv6_descriptor, + IPV6Address::FromStringOrDie("::ffff:192.168.0.1"))); fields.push_back( new MACMessageField(&mac_descriptor, MACAddress::FromStringOrDie("01:23:45:67:89:ab"))); @@ -116,9 +123,9 @@ void GenericMessagePrinterTest::testSimplePrinter() { Message message(fields); string expected = ( - "On/Off: false\nip: 10.0.0.1\nmac: 01:23:45:67:89:ab\n" - "uid: 7a70:00000001\nName: foobar\nId: 42\nCount: 4 x 10 ^ -3\n" - "Delta: 10 x 10 ^ 1\nRate: 10 x 10 ^ -1\n"); + "On/Off: false\nip: 10.0.0.1\nipv6: ::ffff:192.168.0.1\n" + "mac: 01:23:45:67:89:ab\nuid: 7a70:00000001\nName: foobar\nId: 42\n" + "Count: 4 x 10 ^ -3\nDelta: 10 x 10 ^ 1\nRate: 10 x 10 ^ -1\n"); OLA_ASSERT_EQ(expected, m_printer.AsString(&message)); } diff --git a/common/messaging/SchemaPrinter.cpp b/common/messaging/SchemaPrinter.cpp index ba8258ef92..62b07146b2 100644 --- a/common/messaging/SchemaPrinter.cpp +++ b/common/messaging/SchemaPrinter.cpp @@ -43,6 +43,12 @@ void SchemaPrinter::Visit(const IPV4FieldDescriptor *descriptor) { } +void SchemaPrinter::Visit(const IPV6FieldDescriptor *descriptor) { + m_str << string(m_indent, ' ') << descriptor->Name() << ": IPv6 address" + << endl; +} + + void SchemaPrinter::Visit(const MACFieldDescriptor *descriptor) { m_str << string(m_indent, ' ') << descriptor->Name() << ": MAC" << endl; } diff --git a/common/messaging/SchemaPrinterTest.cpp b/common/messaging/SchemaPrinterTest.cpp index dbbe83be67..4b8d216804 100644 --- a/common/messaging/SchemaPrinterTest.cpp +++ b/common/messaging/SchemaPrinterTest.cpp @@ -33,6 +33,7 @@ using std::vector; using ola::messaging::BoolFieldDescriptor; using ola::messaging::IPV4FieldDescriptor; +using ola::messaging::IPV6FieldDescriptor; using ola::messaging::MACFieldDescriptor; using ola::messaging::Descriptor; using ola::messaging::FieldDescriptor; @@ -85,6 +86,8 @@ void SchemaPrinterTest::testPrinter() { "Count", false, 10); IPV4FieldDescriptor *ipv4_descriptor = new IPV4FieldDescriptor( "Address"); + IPV6FieldDescriptor *ipv6_descriptor = new IPV6FieldDescriptor( + "v6 Address"); MACFieldDescriptor *mac_descriptor = new MACFieldDescriptor( "MAC Address"); UIDFieldDescriptor *uid_descriptor = new UIDFieldDescriptor("Device"); @@ -95,6 +98,7 @@ void SchemaPrinterTest::testPrinter() { fields.push_back(string_descriptor); fields.push_back(uint8_descriptor); fields.push_back(ipv4_descriptor); + fields.push_back(ipv6_descriptor); fields.push_back(mac_descriptor); fields.push_back(uid_descriptor); @@ -104,7 +108,7 @@ void SchemaPrinterTest::testPrinter() { string expected = ( "On/Off: bool\nName: string [0, 32]\nCount: uint8\n" - "Address: IPv4 address\nMAC Address: MAC\nDevice: UID\n"); + "Address: IPv4 address\nv6 Address: IPv6 address\nMAC Address: MAC\nDevice: UID\n"); OLA_ASSERT_EQ(expected, printer.AsString()); } diff --git a/common/rdm/DescriptorConsistencyChecker.cpp b/common/rdm/DescriptorConsistencyChecker.cpp index ed224e4955..e947d6d14e 100644 --- a/common/rdm/DescriptorConsistencyChecker.cpp +++ b/common/rdm/DescriptorConsistencyChecker.cpp @@ -41,6 +41,11 @@ void DescriptorConsistencyChecker::Visit( } +void DescriptorConsistencyChecker::Visit( + const ola::messaging::IPV6FieldDescriptor*) { +} + + void DescriptorConsistencyChecker::Visit( const ola::messaging::MACFieldDescriptor*) { } diff --git a/common/rdm/DescriptorConsistencyChecker.h b/common/rdm/DescriptorConsistencyChecker.h index 294debf3f3..a1ed804841 100644 --- a/common/rdm/DescriptorConsistencyChecker.h +++ b/common/rdm/DescriptorConsistencyChecker.h @@ -52,6 +52,7 @@ class DescriptorConsistencyChecker void Visit(const ola::messaging::BoolFieldDescriptor*); void Visit(const ola::messaging::IPV4FieldDescriptor*); + void Visit(const ola::messaging::IPV6FieldDescriptor*); void Visit(const ola::messaging::MACFieldDescriptor*); void Visit(const ola::messaging::UIDFieldDescriptor*); void Visit(const ola::messaging::StringFieldDescriptor*); diff --git a/common/rdm/GroupSizeCalculator.cpp b/common/rdm/GroupSizeCalculator.cpp index d4287b5725..18eb334a0f 100644 --- a/common/rdm/GroupSizeCalculator.cpp +++ b/common/rdm/GroupSizeCalculator.cpp @@ -131,6 +131,12 @@ void GroupSizeCalculator::Visit( } +void GroupSizeCalculator::Visit( + const ola::messaging::IPV6FieldDescriptor *descriptor) { + m_non_groups.push_back(descriptor); +} + + void GroupSizeCalculator::Visit( const ola::messaging::MACFieldDescriptor *descriptor) { m_non_groups.push_back(descriptor); @@ -246,6 +252,12 @@ void StaticGroupTokenCalculator::Visit( } +void StaticGroupTokenCalculator::Visit( + OLA_UNUSED const ola::messaging::IPV6FieldDescriptor *descriptor) { + m_token_count.top()++; +} + + void StaticGroupTokenCalculator::Visit( OLA_UNUSED const ola::messaging::MACFieldDescriptor *descriptor) { m_token_count.top()++; diff --git a/common/rdm/GroupSizeCalculator.h b/common/rdm/GroupSizeCalculator.h index f2c8b4e8e4..c15ec07cda 100644 --- a/common/rdm/GroupSizeCalculator.h +++ b/common/rdm/GroupSizeCalculator.h @@ -53,6 +53,7 @@ class StaticGroupTokenCalculator void Visit(const ola::messaging::BoolFieldDescriptor*); void Visit(const ola::messaging::IPV4FieldDescriptor*); + void Visit(const ola::messaging::IPV6FieldDescriptor*); void Visit(const ola::messaging::MACFieldDescriptor*); void Visit(const ola::messaging::UIDFieldDescriptor*); void Visit(const ola::messaging::StringFieldDescriptor*); @@ -98,6 +99,7 @@ class GroupSizeCalculator: public ola::messaging::FieldDescriptorVisitor { void Visit(const ola::messaging::BoolFieldDescriptor*); void Visit(const ola::messaging::IPV4FieldDescriptor*); + void Visit(const ola::messaging::IPV6FieldDescriptor*); void Visit(const ola::messaging::MACFieldDescriptor*); void Visit(const ola::messaging::UIDFieldDescriptor*); void Visit(const ola::messaging::StringFieldDescriptor*); diff --git a/common/rdm/GroupSizeCalculatorTest.cpp b/common/rdm/GroupSizeCalculatorTest.cpp index 02559f5074..c86dd1dc18 100644 --- a/common/rdm/GroupSizeCalculatorTest.cpp +++ b/common/rdm/GroupSizeCalculatorTest.cpp @@ -34,6 +34,7 @@ using ola::messaging::Descriptor; using ola::messaging::FieldDescriptor; using ola::messaging::FieldDescriptorGroup; using ola::messaging::IPV4FieldDescriptor; +using ola::messaging::IPV6FieldDescriptor; using ola::messaging::Int16FieldDescriptor; using ola::messaging::Int32FieldDescriptor; using ola::messaging::Int8FieldDescriptor; @@ -84,16 +85,17 @@ void GroupSizeCalculatorTest::testSimpleCases() { fields.push_back(new Int8FieldDescriptor("int8")); fields.push_back(new Int16FieldDescriptor("int16")); fields.push_back(new Int32FieldDescriptor("int32")); - fields.push_back(new MACFieldDescriptor("mac")); fields.push_back(new StringFieldDescriptor("string", 0, 32)); fields.push_back(new IPV4FieldDescriptor("address")); + fields.push_back(new IPV6FieldDescriptor("addressv6")); + fields.push_back(new MACFieldDescriptor("mac")); fields.push_back(new UIDFieldDescriptor("uid")); Descriptor descriptor("Test Descriptor", fields); unsigned int token_count, group_repeat_count; OLA_ASSERT_TRUE( m_static_calculator.CalculateTokensRequired(&descriptor, &token_count)); - OLA_ASSERT_EQ(11u, token_count); // Actual token count + OLA_ASSERT_EQ(12u, token_count); // Actual token count OLA_ASSERT_EQ( @@ -106,21 +108,21 @@ void GroupSizeCalculatorTest::testSimpleCases() { OLA_ASSERT_EQ( GroupSizeCalculator::INSUFFICIENT_TOKENS, m_calculator.CalculateGroupSize( - 10, // Actual token count - 1 + 11, // Actual token count - 1 &descriptor, &group_repeat_count)); OLA_ASSERT_EQ( GroupSizeCalculator::NO_VARIABLE_GROUPS, m_calculator.CalculateGroupSize( - 11, // Actual token count + 12, // Actual token count &descriptor, &group_repeat_count)); OLA_ASSERT_EQ( GroupSizeCalculator::EXTRA_TOKENS, m_calculator.CalculateGroupSize( - 12, // Actual token count + 1 + 13, // Actual token count + 1 &descriptor, &group_repeat_count)); } diff --git a/common/rdm/MessageDeserializer.cpp b/common/rdm/MessageDeserializer.cpp index 28480da6e5..a3e6ec3360 100644 --- a/common/rdm/MessageDeserializer.cpp +++ b/common/rdm/MessageDeserializer.cpp @@ -114,7 +114,7 @@ void MessageDeserializer::Visit( } m_message_stack.top().push_back( - new ola::messaging::BoolMessageField(descriptor, m_data[m_offset++])); + new ola::messaging::BoolMessageField(descriptor, m_data[m_offset++])); } @@ -128,9 +128,22 @@ void MessageDeserializer::Visit( memcpy(&data, m_data + m_offset, sizeof(data)); m_offset += sizeof(data); m_message_stack.top().push_back( - new ola::messaging::IPV4MessageField( - descriptor, - ola::network::IPV4Address(data))); + new ola::messaging::IPV4MessageField( + descriptor, + ola::network::IPV4Address(data))); +} + + +void MessageDeserializer::Visit( + const ola::messaging::IPV6FieldDescriptor *descriptor) { + if (!CheckForData(descriptor->MaxSize())) { + return; + } + + ola::network::IPV6Address ipv6_address(m_data + m_offset); + m_offset += descriptor->MaxSize(); + m_message_stack.top().push_back( + new ola::messaging::IPV6MessageField(descriptor, ipv6_address)); } @@ -143,7 +156,7 @@ void MessageDeserializer::Visit( ola::network::MACAddress mac_address(m_data + m_offset); m_offset += descriptor->MaxSize(); m_message_stack.top().push_back( - new ola::messaging::MACMessageField(descriptor, mac_address)); + new ola::messaging::MACMessageField(descriptor, mac_address)); } @@ -156,7 +169,7 @@ void MessageDeserializer::Visit( ola::rdm::UID uid(m_data + m_offset); m_offset += descriptor->MaxSize(); m_message_stack.top().push_back( - new ola::messaging::UIDMessageField(descriptor, uid)); + new ola::messaging::UIDMessageField(descriptor, uid)); } @@ -179,7 +192,7 @@ void MessageDeserializer::Visit( ShortenString(&value); m_offset += string_size; m_message_stack.top().push_back( - new ola::messaging::StringMessageField(descriptor, value)); + new ola::messaging::StringMessageField(descriptor, value)); } @@ -226,7 +239,7 @@ void MessageDeserializer::Visit( const ola::messaging::FieldDescriptorGroup *descriptor) { unsigned int iterations = descriptor->FixedSize() ? descriptor->MinBlocks() : - m_variable_field_size; + m_variable_field_size; for (unsigned int i = 0; i < iterations; ++i) { vector fields; @@ -298,7 +311,7 @@ void MessageDeserializer::IntVisit( } m_message_stack.top().push_back( - new ola::messaging::BasicMessageField(descriptor, value)); + new ola::messaging::BasicMessageField(descriptor, value)); } } // namespace rdm } // namespace ola diff --git a/common/rdm/MessageDeserializerTest.cpp b/common/rdm/MessageDeserializerTest.cpp index b1660e5178..ec9e429425 100644 --- a/common/rdm/MessageDeserializerTest.cpp +++ b/common/rdm/MessageDeserializerTest.cpp @@ -34,7 +34,6 @@ using ola::messaging::BoolFieldDescriptor; -using ola::messaging::IPV4FieldDescriptor; using ola::messaging::Descriptor; using ola::messaging::FieldDescriptor; using ola::messaging::FieldDescriptorGroup; @@ -42,6 +41,7 @@ using ola::messaging::Int16FieldDescriptor; using ola::messaging::Int32FieldDescriptor; using ola::messaging::Int8FieldDescriptor; using ola::messaging::IPV4FieldDescriptor; +using ola::messaging::IPV6FieldDescriptor; using ola::messaging::MACFieldDescriptor; using ola::messaging::Message; using ola::messaging::GenericMessagePrinter; @@ -62,6 +62,7 @@ class MessageDeserializerTest: public CppUnit::TestFixture { CPPUNIT_TEST(testSimpleBigEndian); CPPUNIT_TEST(testSimpleLittleEndian); CPPUNIT_TEST(testIPV4); + CPPUNIT_TEST(testIPV6); CPPUNIT_TEST(testMAC); CPPUNIT_TEST(testString); CPPUNIT_TEST(testUID); @@ -75,6 +76,7 @@ class MessageDeserializerTest: public CppUnit::TestFixture { void testSimpleBigEndian(); void testSimpleLittleEndian(); void testIPV4(); + void testIPV6(); void testMAC(); void testString(); void testUID(); @@ -246,6 +248,31 @@ void MessageDeserializerTest::testIPV4() { } +/** + * Test IPV6 inflation. + */ +void MessageDeserializerTest::testIPV6() { + // build the descriptor + vector fields; + fields.push_back(new IPV6FieldDescriptor("Addressv6")); + Descriptor descriptor("Test Descriptor", fields); + + // now setup the data + const uint8_t big_endian_data[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 10, 0, 0, 1}; + + // now the correct amount & verify + auto_ptr message(m_deserializer.InflateMessage( + &descriptor, + big_endian_data, + sizeof(big_endian_data))); + OLA_ASSERT_NOT_NULL(message.get()); + OLA_ASSERT_EQ(1u, message->FieldCount()); + + const string expected = "Addressv6: ::ffff:10.0.0.1\n"; + OLA_ASSERT_EQ(expected, m_printer.AsString(message.get())); +} + + /** * Test MAC inflation. */ diff --git a/common/rdm/MessageSerializer.cpp b/common/rdm/MessageSerializer.cpp index 8fe5198d2f..8181157642 100644 --- a/common/rdm/MessageSerializer.cpp +++ b/common/rdm/MessageSerializer.cpp @@ -77,6 +77,15 @@ void MessageSerializer::Visit( } +void MessageSerializer::Visit( + const ola::messaging::IPV6MessageField *message) { + unsigned int size = message->GetDescriptor()->MaxSize(); + CheckForFreeSpace(size); + message->Value().Pack(m_data + m_offset, size); + m_offset += size; +} + + void MessageSerializer::Visit( const ola::messaging::MACMessageField *message) { unsigned int size = message->GetDescriptor()->MaxSize(); diff --git a/common/rdm/MessageSerializerTest.cpp b/common/rdm/MessageSerializerTest.cpp index 9d6163fa7d..2eca076471 100644 --- a/common/rdm/MessageSerializerTest.cpp +++ b/common/rdm/MessageSerializerTest.cpp @@ -41,6 +41,7 @@ using ola::messaging::Int16FieldDescriptor; using ola::messaging::Int32FieldDescriptor; using ola::messaging::Int8FieldDescriptor; using ola::messaging::IPV4FieldDescriptor; +using ola::messaging::IPV6FieldDescriptor; using ola::messaging::MACFieldDescriptor; using ola::messaging::Message; using ola::messaging::StringFieldDescriptor; @@ -111,6 +112,7 @@ void MessageSerializerTest::testSimple() { fields.push_back(new UInt32FieldDescriptor("uint32")); fields.push_back(new Int32FieldDescriptor("int32")); fields.push_back(new IPV4FieldDescriptor("ip")); + fields.push_back(new IPV6FieldDescriptor("ipv6")); fields.push_back(new MACFieldDescriptor("mac")); fields.push_back(new StringFieldDescriptor("string", 0, 32)); Descriptor descriptor("Test Descriptor", fields); @@ -125,6 +127,7 @@ void MessageSerializerTest::testSimple() { inputs.push_back("66000"); inputs.push_back("-66000"); inputs.push_back("10.0.0.1"); + inputs.push_back("::ffff:192.168.0.1"); inputs.push_back("01:23:45:67:89:ab"); inputs.push_back("foo"); @@ -137,12 +140,13 @@ void MessageSerializerTest::testSimple() { const uint8_t *data = serializer.SerializeMessage(message.get(), &packed_length); OLA_ASSERT_NOT_NULL(data); - OLA_ASSERT_EQ(28u, packed_length); + OLA_ASSERT_EQ(44u, packed_length); uint8_t expected[] = { 1, 1, 253, 1, 44, 254, 112, 0, 1, 1, 208, 255, 254, 254, 48, 10, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 192, 168, 0, 1, 1, 35, 69, 103, 137, 171, 'f', 'o', 'o'}; diff --git a/common/rdm/PidStoreLoader.cpp b/common/rdm/PidStoreLoader.cpp index 70665f2852..adf5594e6b 100644 --- a/common/rdm/PidStoreLoader.cpp +++ b/common/rdm/PidStoreLoader.cpp @@ -478,6 +478,9 @@ const FieldDescriptor *PidStoreLoader::FieldToFieldDescriptor( case ola::rdm::pid::UID: descriptor = new ola::messaging::UIDFieldDescriptor(field.name()); break; + case ola::rdm::pid::IPV6: + descriptor = new ola::messaging::IPV6FieldDescriptor(field.name()); + break; default: OLA_WARN << "Unknown field type: " << field.type(); } diff --git a/common/rdm/Pids.proto b/common/rdm/Pids.proto index 841e1d7931..19010f7ad8 100644 --- a/common/rdm/Pids.proto +++ b/common/rdm/Pids.proto @@ -42,6 +42,7 @@ enum FieldType { IPV4 = 10; UID = 11; MAC = 12; + IPV6 = 13; } // A value which has a label applied diff --git a/common/rdm/StringMessageBuilder.cpp b/common/rdm/StringMessageBuilder.cpp index 63840d3198..da6fad314e 100644 --- a/common/rdm/StringMessageBuilder.cpp +++ b/common/rdm/StringMessageBuilder.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -127,8 +128,9 @@ const ola::messaging::Message *StringMessageBuilder::GetMessage( */ void StringMessageBuilder::Visit( const ola::messaging::BoolFieldDescriptor *descriptor) { - if (StopParsing()) + if (StopParsing()) { return; + } bool value = false; bool valid = false; @@ -170,8 +172,9 @@ void StringMessageBuilder::Visit( */ void StringMessageBuilder::Visit( const ola::messaging::IPV4FieldDescriptor *descriptor) { - if (StopParsing()) + if (StopParsing()) { return; + } string token = m_inputs[m_offset++]; ola::network::IPV4Address ip_address; @@ -185,13 +188,35 @@ void StringMessageBuilder::Visit( } +/** + * IPV6 Addresses + */ +void StringMessageBuilder::Visit( + const ola::messaging::IPV6FieldDescriptor *descriptor) { + if (StopParsing()) { + return; + } + + string token = m_inputs[m_offset++]; + ola::network::IPV6Address ipv6_address; + if (!ola::network::IPV6Address::FromString(token, &ipv6_address)) { + SetError(descriptor->Name()); + return; + } + + m_groups.top().push_back( + new ola::messaging::IPV6MessageField(descriptor, ipv6_address)); +} + + /** * MAC Addresses */ void StringMessageBuilder::Visit( const ola::messaging::MACFieldDescriptor *descriptor) { - if (StopParsing()) + if (StopParsing()) { return; + } string token = m_inputs[m_offset++]; ola::network::MACAddress mac_address; @@ -210,8 +235,9 @@ void StringMessageBuilder::Visit( */ void StringMessageBuilder::Visit( const ola::messaging::UIDFieldDescriptor *descriptor) { - if (StopParsing()) + if (StopParsing()) { return; + } string token = m_inputs[m_offset++]; auto_ptr uid(UID::FromString(token)); @@ -231,8 +257,9 @@ void StringMessageBuilder::Visit( */ void StringMessageBuilder::Visit( const ola::messaging::StringFieldDescriptor *descriptor) { - if (StopParsing()) + if (StopParsing()) { return; + } const string &token = m_inputs[m_offset++]; if (descriptor->MaxSize() != 0 && @@ -335,8 +362,9 @@ void StringMessageBuilder::SetError(const string &error) { template void StringMessageBuilder::VisitInt( const ola::messaging::IntegerFieldDescriptor *descriptor) { - if (StopParsing()) + if (StopParsing()) { return; + } type int_value; string input = m_inputs[m_offset++]; diff --git a/common/rdm/StringMessageBuilderTest.cpp b/common/rdm/StringMessageBuilderTest.cpp index de09265147..6ee21f16e8 100644 --- a/common/rdm/StringMessageBuilderTest.cpp +++ b/common/rdm/StringMessageBuilderTest.cpp @@ -38,6 +38,7 @@ using ola::messaging::Descriptor; using ola::messaging::FieldDescriptor; using ola::messaging::FieldDescriptorGroup; using ola::messaging::IPV4FieldDescriptor; +using ola::messaging::IPV6FieldDescriptor; using ola::messaging::Int16FieldDescriptor; using ola::messaging::Int32FieldDescriptor; using ola::messaging::Int8FieldDescriptor; @@ -136,6 +137,7 @@ void StringBuilderTest::testSimpleBuilder() { fields.push_back(new BoolFieldDescriptor("bool5")); fields.push_back(new BoolFieldDescriptor("bool6")); fields.push_back(new IPV4FieldDescriptor("ip1")); + fields.push_back(new IPV6FieldDescriptor("ipv61")); fields.push_back(new MACFieldDescriptor("mac1")); fields.push_back(new UInt8FieldDescriptor("uint8")); fields.push_back(new UInt16FieldDescriptor("uint16")); @@ -156,6 +158,7 @@ void StringBuilderTest::testSimpleBuilder() { inputs.push_back("TRUE"); inputs.push_back("FALSE"); inputs.push_back("10.0.0.1"); + inputs.push_back("::ffff:192.168.0.1"); inputs.push_back("01:23:45:67:89:ab"); inputs.push_back("255"); inputs.push_back("300"); @@ -171,13 +174,14 @@ void StringBuilderTest::testSimpleBuilder() { // verify OLA_ASSERT_TRUE(message.get()); OLA_ASSERT_EQ(static_cast(fields.size()), - message->FieldCount()); + message->FieldCount()); string expected = ( "bool1: true\nbool2: false\nbool3: true\nbool4: false\nbool5: true\n" - "bool6: false\nip1: 10.0.0.1\nmac1: 01:23:45:67:89:ab\nuint8: 255\n" - "uint16: 300\nuint32: 66000\nint8: -128\nint16: -300\nint32: -66000\n" - "string: foo\nhex uint16: 1024\n"); + "bool6: false\nip1: 10.0.0.1\nipv61: ::ffff:192.168.0.1\n" + "mac1: 01:23:45:67:89:ab\nuint8: 255\nuint16: 300\nuint32: 66000\n" + "int8: -128\nint16: -300\nint32: -66000\nstring: foo\n" + "hex uint16: 1024\n"); OLA_ASSERT_EQ(expected, m_printer.AsString(message.get())); } diff --git a/common/rdm/VariableFieldSizeCalculator.cpp b/common/rdm/VariableFieldSizeCalculator.cpp index b054a38589..4ef46ba2d0 100644 --- a/common/rdm/VariableFieldSizeCalculator.cpp +++ b/common/rdm/VariableFieldSizeCalculator.cpp @@ -124,6 +124,12 @@ void VariableFieldSizeCalculator::Visit( } +void VariableFieldSizeCalculator::Visit( + const ola::messaging::IPV6FieldDescriptor *descriptor) { + m_fixed_size_sum += descriptor->MaxSize(); +} + + void VariableFieldSizeCalculator::Visit( const ola::messaging::MACFieldDescriptor *descriptor) { m_fixed_size_sum += descriptor->MaxSize(); diff --git a/common/rdm/VariableFieldSizeCalculator.h b/common/rdm/VariableFieldSizeCalculator.h index d6208b323c..4e224b0afa 100644 --- a/common/rdm/VariableFieldSizeCalculator.h +++ b/common/rdm/VariableFieldSizeCalculator.h @@ -63,6 +63,7 @@ class VariableFieldSizeCalculator void Visit(const ola::messaging::BoolFieldDescriptor*); void Visit(const ola::messaging::IPV4FieldDescriptor*); + void Visit(const ola::messaging::IPV6FieldDescriptor*); void Visit(const ola::messaging::MACFieldDescriptor*); void Visit(const ola::messaging::UIDFieldDescriptor*); void Visit(const ola::messaging::StringFieldDescriptor*); diff --git a/data/rdm/pids.proto b/data/rdm/pids.proto index cebb8ef20e..50548ae6a0 100644 --- a/data/rdm/pids.proto +++ b/data/rdm/pids.proto @@ -4010,6 +4010,144 @@ pid { } set_sub_device_range: ROOT_OR_ALL_SUBDEVICE } +pid { + name: "COMPONENT_SCOPE" + value: 2048 + get_request { + field { + type: UINT16 + name: "scope_slot" + range { + min: 1 + max: 65535 + } + } + } + get_response { + field { + type: UINT16 + name: "scope_slot" + range { + min: 1 + max: 65535 + } + } + field { + type: STRING + name: "scope_string" + min_size: 63 + max_size: 63 + } + field { + type: UINT8 + name: "static_config_type" + label { + value: 0 + label: "No static config" + } + label { + value: 1 + label: "Static config IPv4" + } + label { + value: 1 + label: "Static config IPv6" + } + range { + min: 0 + max: 2 + } + } + field { + type: IPV4 + name: "static_broker_ipv4_address" + label { + value: 0 + label: "No static broker IPv4 address" + } + } + field { + type: IPV6 + name: "static_broker_ipv6_address" + label { + value: 0 + label: "No static broker IPv6 address" + } + } + field { + type: UINT16 + name: "static_broker_port" + label { + value: 0 + label: "No static broker port" + } + } + } + get_sub_device_range: ROOT_DEVICE + set_request { + field { + type: UINT16 + name: "scope_slot" + range { + min: 1 + max: 65535 + } + } + field { + type: STRING + name: "scope_string" + min_size: 63 + max_size: 63 + } + field { + type: UINT8 + name: "static_config_type" + label { + value: 0 + label: "No static config" + } + label { + value: 1 + label: "Static config IPv4" + } + label { + value: 1 + label: "Static config IPv6" + } + range { + min: 0 + max: 2 + } + } + field { + type: IPV4 + name: "static_broker_ipv4_address" + label { + value: 0 + label: "No static broker IPv4 address" + } + } + field { + type: IPV6 + name: "static_broker_ipv6_address" + label { + value: 0 + label: "No static broker IPv6 address" + } + } + field { + type: UINT16 + name: "static_broker_port" + label { + value: 0 + label: "No static broker port" + } + } + } + set_response { + } + set_sub_device_range: ROOT_DEVICE +} pid { name: "SEARCH_DOMAIN" value: 2049 @@ -4036,6 +4174,60 @@ pid { } set_sub_device_range: ROOT_DEVICE } +pid { + name: "TCP_COMMS_STATUS" + value: 2050 + get_request { + } + get_response { + field { + type: GROUP + name: "comms_statuses" + field { + type: STRING + name: "scope_string" + min_size: 63 + max_size: 63 + } + field { + type: IPV4 + name: "broker_ipv4_address" + label { + value: 0 + label: "No IPv4 Connection" + } + } + field { + type: IPV6 + name: "broker_ipv6_address" + label { + value: 0 + label: "No IPv6 Connection" + } + } + field { + type: UINT16 + name: "broker_port" + } + field { + type: UINT16 + name: "unhealthy_tcp_events" + } + } + } + get_sub_device_range: ROOT_DEVICE + set_request { + field { + type: STRING + name: "scope_string" + min_size: 63 + max_size: 63 + } + } + set_response { + } + set_sub_device_range: ROOT_DEVICE +} pid { name: "BROKER_STATUS" value: 2051 diff --git a/include/ola/messaging/Descriptor.h b/include/ola/messaging/Descriptor.h index 3f287141ea..f997a9a00d 100644 --- a/include/ola/messaging/Descriptor.h +++ b/include/ola/messaging/Descriptor.h @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -116,6 +117,25 @@ class IPV4FieldDescriptor: public FieldDescriptor { }; +/** + * A FieldDescriptor that represents a IPv6 Address + */ +class IPV6FieldDescriptor: public FieldDescriptor { + public: + explicit IPV6FieldDescriptor(const std::string &name) + : FieldDescriptor(name) { + } + + bool FixedSize() const { return true; } + bool LimitedSize() const { return true; } + unsigned int MaxSize() const { return ola::network::IPV6Address::LENGTH; } + + void Accept(FieldDescriptorVisitor *visitor) const { + visitor->Visit(this); + } +}; + + /** * A FieldDescriptor that represents a MAC Address */ diff --git a/include/ola/messaging/DescriptorVisitor.h b/include/ola/messaging/DescriptorVisitor.h index 43a64f572a..5b5820d588 100644 --- a/include/ola/messaging/DescriptorVisitor.h +++ b/include/ola/messaging/DescriptorVisitor.h @@ -30,6 +30,7 @@ namespace messaging { class BoolFieldDescriptor; class FieldDescriptorGroup; class IPV4FieldDescriptor; +class IPV6FieldDescriptor; class MACFieldDescriptor; class StringFieldDescriptor; class UIDFieldDescriptor; @@ -49,6 +50,7 @@ class FieldDescriptorVisitor { virtual void Visit(const BoolFieldDescriptor*) = 0; virtual void Visit(const IPV4FieldDescriptor*) = 0; + virtual void Visit(const IPV6FieldDescriptor*) = 0; virtual void Visit(const MACFieldDescriptor*) = 0; virtual void Visit(const UIDFieldDescriptor*) = 0; virtual void Visit(const StringFieldDescriptor*) = 0; diff --git a/include/ola/messaging/Message.h b/include/ola/messaging/Message.h index b8062f57c1..ecc56bd2a2 100644 --- a/include/ola/messaging/Message.h +++ b/include/ola/messaging/Message.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -125,6 +126,32 @@ class IPV4MessageField: public MessageFieldInterface { }; +/** + * A MessageField that represents a IPv6 Address + */ +class IPV6MessageField: public MessageFieldInterface { + public: + IPV6MessageField(const IPV6FieldDescriptor *descriptor, + const ola::network::IPV6Address &value) + : m_descriptor(descriptor), + m_value(value) { + } + + const IPV6FieldDescriptor *GetDescriptor() const { + return m_descriptor; + } + const ola::network::IPV6Address& Value() const { return m_value; } + + void Accept(MessageVisitor *visitor) const { + visitor->Visit(this); + } + + private: + const IPV6FieldDescriptor *m_descriptor; + ola::network::IPV6Address m_value; +}; + + /** * A MessageField that represents a MAC Address */ diff --git a/include/ola/messaging/MessagePrinter.h b/include/ola/messaging/MessagePrinter.h index 0053d16618..2f2f363664 100644 --- a/include/ola/messaging/MessagePrinter.h +++ b/include/ola/messaging/MessagePrinter.h @@ -40,6 +40,7 @@ class MessagePrinter: public MessageVisitor { virtual void Visit(const BoolMessageField*) {} virtual void Visit(const IPV4MessageField*) {} + virtual void Visit(const IPV6MessageField*) {} virtual void Visit(const MACMessageField*) {} virtual void Visit(const UIDMessageField*) {} virtual void Visit(const StringMessageField*) {} @@ -78,6 +79,7 @@ class GenericMessagePrinter: public MessagePrinter { virtual void Visit(const BoolMessageField*); virtual void Visit(const IPV4MessageField*); + virtual void Visit(const IPV6MessageField*); virtual void Visit(const MACMessageField*); virtual void Visit(const UIDMessageField*); virtual void Visit(const StringMessageField*); diff --git a/include/ola/messaging/MessageVisitor.h b/include/ola/messaging/MessageVisitor.h index 00812f8e56..81b55ed965 100644 --- a/include/ola/messaging/MessageVisitor.h +++ b/include/ola/messaging/MessageVisitor.h @@ -30,6 +30,7 @@ namespace messaging { class BoolMessageField; class GroupMessageField; class IPV4MessageField; +class IPV6MessageField; class MACMessageField; class StringMessageField; class UIDMessageField; @@ -46,6 +47,7 @@ class MessageVisitor { virtual void Visit(const BoolMessageField*) = 0; virtual void Visit(const IPV4MessageField*) = 0; + virtual void Visit(const IPV6MessageField*) = 0; virtual void Visit(const MACMessageField*) = 0; virtual void Visit(const UIDMessageField*) = 0; virtual void Visit(const StringMessageField*) = 0; diff --git a/include/ola/messaging/SchemaPrinter.h b/include/ola/messaging/SchemaPrinter.h index 21feb46090..95aa7c9e6b 100644 --- a/include/ola/messaging/SchemaPrinter.h +++ b/include/ola/messaging/SchemaPrinter.h @@ -50,6 +50,7 @@ class SchemaPrinter: public FieldDescriptorVisitor { void Visit(const BoolFieldDescriptor*); void Visit(const IPV4FieldDescriptor*); + void Visit(const IPV6FieldDescriptor*); void Visit(const MACFieldDescriptor*); void Visit(const UIDFieldDescriptor*); void Visit(const StringFieldDescriptor*); diff --git a/include/ola/messaging/StringMessageBuilder.h b/include/ola/messaging/StringMessageBuilder.h index 4bb9011c4b..12b7273fd3 100644 --- a/include/ola/messaging/StringMessageBuilder.h +++ b/include/ola/messaging/StringMessageBuilder.h @@ -42,6 +42,7 @@ class StringMessageBuilder: public FieldDescriptorVisitor { void Visit(const BoolFieldDescriptor*); void Visit(const IPV4FieldDescriptor*); + void Visit(const IPV6FieldDescriptor*); void Visit(const MACFieldDescriptor*); void Visit(const UIDFieldDescriptor*); void Visit(const StringFieldDescriptor*); diff --git a/include/ola/rdm/MessageDeserializer.h b/include/ola/rdm/MessageDeserializer.h index 4d228125e2..5e320653af 100644 --- a/include/ola/rdm/MessageDeserializer.h +++ b/include/ola/rdm/MessageDeserializer.h @@ -57,6 +57,7 @@ class MessageDeserializer: public ola::messaging::FieldDescriptorVisitor { void Visit(const ola::messaging::BoolFieldDescriptor*); void Visit(const ola::messaging::IPV4FieldDescriptor*); + void Visit(const ola::messaging::IPV6FieldDescriptor*); void Visit(const ola::messaging::MACFieldDescriptor*); void Visit(const ola::messaging::UIDFieldDescriptor*); void Visit(const ola::messaging::StringFieldDescriptor*); diff --git a/include/ola/rdm/MessageSerializer.h b/include/ola/rdm/MessageSerializer.h index 821f2097ea..cf6f51f86e 100644 --- a/include/ola/rdm/MessageSerializer.h +++ b/include/ola/rdm/MessageSerializer.h @@ -48,6 +48,7 @@ class MessageSerializer: public ola::messaging::MessageVisitor { void Visit(const ola::messaging::BoolMessageField*); void Visit(const ola::messaging::IPV4MessageField*); + void Visit(const ola::messaging::IPV6MessageField*); void Visit(const ola::messaging::MACMessageField*); void Visit(const ola::messaging::UIDMessageField*); void Visit(const ola::messaging::StringMessageField*); diff --git a/include/ola/rdm/StringMessageBuilder.h b/include/ola/rdm/StringMessageBuilder.h index f66187e682..ed2bfbdc49 100644 --- a/include/ola/rdm/StringMessageBuilder.h +++ b/include/ola/rdm/StringMessageBuilder.h @@ -62,6 +62,7 @@ class StringMessageBuilder: public ola::messaging::FieldDescriptorVisitor { void Visit(const ola::messaging::BoolFieldDescriptor*); void Visit(const ola::messaging::IPV4FieldDescriptor*); + void Visit(const ola::messaging::IPV6FieldDescriptor*); void Visit(const ola::messaging::MACFieldDescriptor*); void Visit(const ola::messaging::UIDFieldDescriptor*); void Visit(const ola::messaging::StringFieldDescriptor*); diff --git a/python/ola/PidStore.py b/python/ola/PidStore.py index 38fb200562..f9f62121c1 100644 --- a/python/ola/PidStore.py +++ b/python/ola/PidStore.py @@ -549,6 +549,28 @@ def Pack(self, args): return super(IntAtom, self).Pack(value) +class IPV6Atom(FixedSizeAtom): + """A sixteen-byte IPV6 address.""" + def __init__(self, name, **kwargs): + super(IPV6Atom, self).__init__(name, 'BBBBBBBBBBBBBBBB') + + def Unpack(self, data): + try: + return socket.inet_ntop(AF_INET6, data) + except socket.error as e: + raise ArgsValidationError("Can't unpack data: %s" % e) + + def Pack(self, args): + # TODO(Peter): This currently allows some rather quirky values as per + # inet_pton, we may want to restrict that in future + format_string = self._FormatString() + try: + data = struct.pack(format_string, socket.inet_pton(AF_INET6, args[0])) + except socket.error as e: + raise ArgsValidationError("Can't pack data: %s" % e) + return data, 1 + + class MACAtom(FixedSizeAtom): """A MAC address.""" def __init__(self, name, **kwargs): @@ -1271,6 +1293,8 @@ def _FieldToAtom(self, field): return UInt32(field_name, **args) elif field.type == Pids_pb2.IPV4: return IPV4(field_name, **args) + elif field.type == Pids_pb2.IPV6: + return IPV6Atom(field_name, **args) elif field.type == Pids_pb2.MAC: return MACAtom(field_name, **args) elif field.type == Pids_pb2.UID: diff --git a/python/ola/PidStoreTest.py b/python/ola/PidStoreTest.py index 600f1dd389..e09226f1fd 100755 --- a/python/ola/PidStoreTest.py +++ b/python/ola/PidStoreTest.py @@ -174,6 +174,8 @@ def testCmp(self): g1getreq = PidStore.Group("grg", [PidStore.UInt16("ui16"), PidStore.Int32("i32")]) g1setreq = PidStore.Group("srg", [PidStore.MACAtom("mac"), + PidStore.IPV4("ipv4"), + PidStore.IPV6Atom("ipv6"), PidStore.Int8("i32")]) p1b = PidStore.Pid("base", 42, None, None, g1getreq, g1setreq) From 92760e5aabc165a9e7d15d59838af0ccaade4322 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 3 Dec 2023 01:20:25 +0000 Subject: [PATCH 41/56] Minor formatting tweaks to match the rest of the codebase --- common/messaging/MessagePrinter.cpp | 43 +++++++++++++++-------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/common/messaging/MessagePrinter.cpp b/common/messaging/MessagePrinter.cpp index 20e9ef1d89..7123c15782 100644 --- a/common/messaging/MessagePrinter.cpp +++ b/common/messaging/MessagePrinter.cpp @@ -45,44 +45,44 @@ string MessagePrinter::AsString(const Message *message) { void GenericMessagePrinter::Visit(const BoolMessageField *message) { - Stream() << string(m_indent, ' ') << - TransformLabel(message->GetDescriptor()->Name()) << ": " - << (message->Value() ? "true" : "false") << endl; + Stream() << string(m_indent, ' ') + << TransformLabel(message->GetDescriptor()->Name()) << ": " + << (message->Value() ? "true" : "false") << endl; } void GenericMessagePrinter::Visit(const IPV4MessageField *message) { - Stream() << string(m_indent, ' ') << - TransformLabel(message->GetDescriptor()->Name()) << ": " - << message->Value() << endl; + Stream() << string(m_indent, ' ') + << TransformLabel(message->GetDescriptor()->Name()) << ": " + << message->Value() << endl; } void GenericMessagePrinter::Visit(const IPV6MessageField *message) { - Stream() << string(m_indent, ' ') << - TransformLabel(message->GetDescriptor()->Name()) << ": " - << message->Value() << endl; + Stream() << string(m_indent, ' ') + << TransformLabel(message->GetDescriptor()->Name()) << ": " + << message->Value() << endl; } void GenericMessagePrinter::Visit(const MACMessageField *message) { - Stream() << string(m_indent, ' ') << - TransformLabel(message->GetDescriptor()->Name()) << ": " - << message->Value().ToString() << endl; + Stream() << string(m_indent, ' ') + << TransformLabel(message->GetDescriptor()->Name()) << ": " + << message->Value().ToString() << endl; } void GenericMessagePrinter::Visit(const UIDMessageField *message) { - Stream() << string(m_indent, ' ') << - TransformLabel(message->GetDescriptor()->Name()) << ": " - << message->Value().ToString() << endl; + Stream() << string(m_indent, ' ') + << TransformLabel(message->GetDescriptor()->Name()) << ": " + << message->Value().ToString() << endl; } void GenericMessagePrinter::Visit(const StringMessageField *message) { - Stream() << string(m_indent, ' ') << - TransformLabel(message->GetDescriptor()->Name()) << ": " - << EncodeString(message->Value()) << endl; + Stream() << string(m_indent, ' ') + << TransformLabel(message->GetDescriptor()->Name()) << ": " + << EncodeString(message->Value()) << endl; } @@ -141,8 +141,8 @@ void GenericMessagePrinter::Visit(const BasicMessageField *message) { void GenericMessagePrinter::Visit(const GroupMessageField *message) { - Stream() << string(m_indent, ' ') << - TransformLabel(message->GetDescriptor()->Name()) << " {" << endl; + Stream() << string(m_indent, ' ') + << TransformLabel(message->GetDescriptor()->Name()) << " {" << endl; m_indent += m_indent_size; } @@ -185,8 +185,9 @@ void GenericMessagePrinter::AppendInt(const string &name, void GenericMessagePrinter::AppendMultiplier(int8_t multiplier) { - if (multiplier) + if (multiplier) { Stream() << " x 10 ^ " << static_cast(multiplier); + } } } // namespace messaging } // namespace ola From ad9aea5e8186b97adacd4e6df710e1d2561d7a09 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 3 Dec 2023 01:32:22 +0000 Subject: [PATCH 42/56] Fix some cpplint errors --- common/messaging/SchemaPrinterTest.cpp | 3 ++- common/rdm/MessageDeserializerTest.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/common/messaging/SchemaPrinterTest.cpp b/common/messaging/SchemaPrinterTest.cpp index 4b8d216804..0eda1f5a36 100644 --- a/common/messaging/SchemaPrinterTest.cpp +++ b/common/messaging/SchemaPrinterTest.cpp @@ -108,7 +108,8 @@ void SchemaPrinterTest::testPrinter() { string expected = ( "On/Off: bool\nName: string [0, 32]\nCount: uint8\n" - "Address: IPv4 address\nv6 Address: IPv6 address\nMAC Address: MAC\nDevice: UID\n"); + "Address: IPv4 address\nv6 Address: IPv6 address\nMAC Address: MAC\n" + "Device: UID\n"); OLA_ASSERT_EQ(expected, printer.AsString()); } diff --git a/common/rdm/MessageDeserializerTest.cpp b/common/rdm/MessageDeserializerTest.cpp index ec9e429425..d674b2c2f8 100644 --- a/common/rdm/MessageDeserializerTest.cpp +++ b/common/rdm/MessageDeserializerTest.cpp @@ -258,7 +258,8 @@ void MessageDeserializerTest::testIPV6() { Descriptor descriptor("Test Descriptor", fields); // now setup the data - const uint8_t big_endian_data[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 10, 0, 0, 1}; + const uint8_t big_endian_data[] = {0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 255, 255, 10, 0, 0, 1}; // now the correct amount & verify auto_ptr message(m_deserializer.InflateMessage( From 14c5d1921c14b8aaced71e7747852c6149a18819 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 10 Dec 2023 11:47:46 +0000 Subject: [PATCH 43/56] Fix some socket constant usage --- python/ola/PidStore.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/ola/PidStore.py b/python/ola/PidStore.py index f9f62121c1..f48db9656b 100644 --- a/python/ola/PidStore.py +++ b/python/ola/PidStore.py @@ -556,7 +556,7 @@ def __init__(self, name, **kwargs): def Unpack(self, data): try: - return socket.inet_ntop(AF_INET6, data) + return socket.inet_ntop(socket.AF_INET6, data) except socket.error as e: raise ArgsValidationError("Can't unpack data: %s" % e) @@ -565,7 +565,8 @@ def Pack(self, args): # inet_pton, we may want to restrict that in future format_string = self._FormatString() try: - data = struct.pack(format_string, socket.inet_pton(AF_INET6, args[0])) + data = struct.pack(format_string, + socket.inet_pton(socket.AF_INET6, args[0])) except socket.error as e: raise ArgsValidationError("Can't pack data: %s" % e) return data, 1 From c4cd3dc5dfed0d2b591aade1cdb2e6d914468d1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Offringa?= Date: Sun, 14 Jan 2024 16:36:28 +0100 Subject: [PATCH 44/56] Update plugins/usbdmx/EuroliteProFactory.cpp Co-authored-by: Peter Newman --- plugins/usbdmx/EuroliteProFactory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/usbdmx/EuroliteProFactory.cpp b/plugins/usbdmx/EuroliteProFactory.cpp index 984b9ba013..6503dc6812 100644 --- a/plugins/usbdmx/EuroliteProFactory.cpp +++ b/plugins/usbdmx/EuroliteProFactory.cpp @@ -118,7 +118,7 @@ bool EuroliteProFactory::DeviceAdded( } const bool serial_matches = - STLContains(m_expected_eurolite_mk2_serials, info.serial); + STLContains(m_expected_eurolite_mk2_serials, info.serial); if (m_enable_eurolite_mk2 || serial_matches) { if (serial_matches) { From 981f91f2c9edb4c6c089c23d495ed281a339adc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Offringa?= Date: Sun, 14 Jan 2024 16:36:54 +0100 Subject: [PATCH 45/56] Update plugins/usbdmx/EuroliteProFactory.cpp Co-authored-by: Peter Newman --- plugins/usbdmx/EuroliteProFactory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/usbdmx/EuroliteProFactory.cpp b/plugins/usbdmx/EuroliteProFactory.cpp index 6503dc6812..a0d8ef086a 100644 --- a/plugins/usbdmx/EuroliteProFactory.cpp +++ b/plugins/usbdmx/EuroliteProFactory.cpp @@ -123,7 +123,7 @@ bool EuroliteProFactory::DeviceAdded( if (m_enable_eurolite_mk2 || serial_matches) { if (serial_matches) { OLA_INFO << "Enabling new Eurolite USB-DMX512-PRO MK2 device " - "with matching serial " << info.serial; + << "with matching serial " << info.serial; } else { OLA_INFO << "Found a possible new Eurolite USB-DMX512-PRO MK2 device " "with serial " << info.serial; From f24f51e83b5a844201bf0bd3e36a7861f91bfa50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Offringa?= Date: Sun, 14 Jan 2024 16:37:04 +0100 Subject: [PATCH 46/56] Update plugins/usbdmx/EuroliteProFactory.cpp Co-authored-by: Peter Newman --- plugins/usbdmx/EuroliteProFactory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/usbdmx/EuroliteProFactory.cpp b/plugins/usbdmx/EuroliteProFactory.cpp index a0d8ef086a..280c35c4b7 100644 --- a/plugins/usbdmx/EuroliteProFactory.cpp +++ b/plugins/usbdmx/EuroliteProFactory.cpp @@ -126,7 +126,7 @@ bool EuroliteProFactory::DeviceAdded( << "with matching serial " << info.serial; } else { OLA_INFO << "Found a possible new Eurolite USB-DMX512-PRO MK2 device " - "with serial " << info.serial; + << "with serial " << info.serial; } if (!m_adaptor->CheckManufacturer(EXPECTED_MANUFACTURER_MK2, info)) { return false; From 2c398ecd1b2e251ce4208d8101a609340cf30292 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Offringa?= Date: Sun, 14 Jan 2024 16:37:15 +0100 Subject: [PATCH 47/56] Update plugins/usbdmx/EuroliteProFactory.cpp Co-authored-by: Peter Newman --- plugins/usbdmx/EuroliteProFactory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/usbdmx/EuroliteProFactory.cpp b/plugins/usbdmx/EuroliteProFactory.cpp index 280c35c4b7..6c0d161077 100644 --- a/plugins/usbdmx/EuroliteProFactory.cpp +++ b/plugins/usbdmx/EuroliteProFactory.cpp @@ -141,7 +141,7 @@ bool EuroliteProFactory::DeviceAdded( << " could be a Eurolite USB-DMX512-PRO MK2 but was " << "ignored, because " << ENABLE_EUROLITE_MK2_KEY << " was false and " - << "its serial number was not specifically specified with " + << "its serial number was not listed specifically with " << EUROLITE_MK2_SERIAL_KEY; return false; } From 92f1ba84b3009c0de7603a8c6030cccbcdea14be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Offringa?= Date: Sun, 14 Jan 2024 16:41:12 +0100 Subject: [PATCH 48/56] Textual review comment --- plugins/usbdmx/EuroliteProFactory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/usbdmx/EuroliteProFactory.cpp b/plugins/usbdmx/EuroliteProFactory.cpp index 6c0d161077..612e97c19b 100644 --- a/plugins/usbdmx/EuroliteProFactory.cpp +++ b/plugins/usbdmx/EuroliteProFactory.cpp @@ -122,10 +122,10 @@ bool EuroliteProFactory::DeviceAdded( if (m_enable_eurolite_mk2 || serial_matches) { if (serial_matches) { - OLA_INFO << "Enabling new Eurolite USB-DMX512-PRO MK2 device " + OLA_INFO << "Found a probable new Eurolite USB-DMX512-PRO MK2 device " << "with matching serial " << info.serial; } else { - OLA_INFO << "Found a possible new Eurolite USB-DMX512-PRO MK2 device " + OLA_INFO << "Found a probable new Eurolite USB-DMX512-PRO MK2 device " << "with serial " << info.serial; } if (!m_adaptor->CheckManufacturer(EXPECTED_MANUFACTURER_MK2, info)) { From ee8796219dd55a50cbbb6360a9804797fbc0b07d Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 3 Feb 2024 15:21:57 +0000 Subject: [PATCH 49/56] Minor wording improvements --- plugins/usbdmx/EuroliteProFactory.cpp | 4 ++-- plugins/usbdmx/README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/usbdmx/EuroliteProFactory.cpp b/plugins/usbdmx/EuroliteProFactory.cpp index 612e97c19b..f79c812602 100644 --- a/plugins/usbdmx/EuroliteProFactory.cpp +++ b/plugins/usbdmx/EuroliteProFactory.cpp @@ -67,7 +67,7 @@ EuroliteProFactory::EuroliteProFactory(ola::usb::LibUsbAdaptor *adaptor, iter != serials.end(); ++iter) { if (iter->empty()) { OLA_WARN << EUROLITE_MK2_SERIAL_KEY - << " requires a serial key string, but it is empty."; + << " requires a serial number, but it is empty."; } else if (STLContains(m_expected_eurolite_mk2_serials, *iter)) { OLA_WARN << EUROLITE_MK2_SERIAL_KEY << " lists serial " << *iter << " more than once."; @@ -141,7 +141,7 @@ bool EuroliteProFactory::DeviceAdded( << " could be a Eurolite USB-DMX512-PRO MK2 but was " << "ignored, because " << ENABLE_EUROLITE_MK2_KEY << " was false and " - << "its serial number was not listed specifically with " + << "its serial number was not listed specifically in " << EUROLITE_MK2_SERIAL_KEY; return false; } diff --git a/plugins/usbdmx/README.md b/plugins/usbdmx/README.md index 2a96cde46a..04696f1c38 100644 --- a/plugins/usbdmx/README.md +++ b/plugins/usbdmx/README.md @@ -29,7 +29,7 @@ Whether to enable detection of the Eurolite USB-DMX512 PRO MK2. Default = `false`. This device is indistinguishable from other devices with an FTDI chip, and is therefore disabled by default. When enabled, this plugin will conflict with the usbserial, StageProfi and FTDI USB DMX -plugins. If this is undesirable, the `eurolite_mk2_serial` key can be +plugins. If this is undesirable, the `eurolite_mk2_serial` setting can be used instead, which manually marks a specific USB device as a Eurolite USB-DMX512 PRO MK2. From 6a6b42ef7781db47fac73c5e9ba9faeebebfca76 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 3 Feb 2024 16:07:52 +0000 Subject: [PATCH 50/56] Track Eurolite MK2 by actual serial number where available --- plugins/usbdmx/EuroliteProFactory.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/plugins/usbdmx/EuroliteProFactory.cpp b/plugins/usbdmx/EuroliteProFactory.cpp index f79c812602..be380862a3 100644 --- a/plugins/usbdmx/EuroliteProFactory.cpp +++ b/plugins/usbdmx/EuroliteProFactory.cpp @@ -150,17 +150,21 @@ bool EuroliteProFactory::DeviceAdded( return false; } - // The Eurolite doesn't have a serial number, so instead we use the device & - // bus number. + // The original Eurolite doesn't have a serial number, so instead we use the + // device & bus number. The MK2 does, so we use that where available. // TODO(simon): check if this supports the SERIAL NUMBER label and use that // instead. - // There is no Serialnumber--> work around: bus+device number - int bus_number = libusb_get_bus_number(usb_device); - int device_address = libusb_get_device_address(usb_device); - std::ostringstream serial_str; - serial_str << bus_number << "-" << device_address; + if (is_mk2 && !info.serial.empty()) { + serial_str << info.serial; + } else { + // Original, there is no Serialnumber--> work around: bus+device number + int bus_number = libusb_get_bus_number(usb_device); + int device_address = libusb_get_device_address(usb_device); + + serial_str << bus_number << "-" << device_address; + } EurolitePro *widget = NULL; if (FLAGS_use_async_libusb) { From 949ce94bbd1e42855b074e9f49f8f5ef274239fa Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 3 Feb 2024 16:21:06 +0000 Subject: [PATCH 51/56] Add some potential TODO for another way to track devices without serial --- plugins/usbdmx/AVLdiyD512Factory.cpp | 3 +++ plugins/usbdmx/AnymauDMXFactory.cpp | 3 +++ plugins/usbdmx/DMXCreator512BasicFactory.cpp | 3 +++ plugins/usbdmx/ScanlimeFadecandyFactory.cpp | 3 +++ 4 files changed, 12 insertions(+) diff --git a/plugins/usbdmx/AVLdiyD512Factory.cpp b/plugins/usbdmx/AVLdiyD512Factory.cpp index 0f965ab7f7..2e0481636f 100644 --- a/plugins/usbdmx/AVLdiyD512Factory.cpp +++ b/plugins/usbdmx/AVLdiyD512Factory.cpp @@ -63,6 +63,9 @@ bool AVLdiyD512Factory::DeviceAdded( // Some AVLdiy devices don't have serial numbers. Since there isn't another // good way to uniquely identify a USB device, we only support one of these // types of devices per host. + // TODO(Peter): We could instead use the device & bus number (like the + // Eurolite plugin). You could use more than one device, but the patch + // wouldn't follow if you plugged it into a different port if (info.serial.empty()) { if (m_missing_serial_number) { OLA_WARN << "Failed to read serial number or serial number empty. " diff --git a/plugins/usbdmx/AnymauDMXFactory.cpp b/plugins/usbdmx/AnymauDMXFactory.cpp index 1995fd87b1..86df54f2d9 100644 --- a/plugins/usbdmx/AnymauDMXFactory.cpp +++ b/plugins/usbdmx/AnymauDMXFactory.cpp @@ -63,6 +63,9 @@ bool AnymauDMXFactory::DeviceAdded( // Some Anyma devices don't have serial numbers. Since there isn't another // good way to uniquely identify a USB device, we only support one of these // types of devices per host. + // TODO(Peter): We could instead use the device & bus number (like the + // Eurolite plugin). You could use more than one device, but the patch + // wouldn't follow if you plugged it into a different port if (info.serial.empty()) { if (m_missing_serial_number) { OLA_WARN << "Failed to read serial number or serial number empty. " diff --git a/plugins/usbdmx/DMXCreator512BasicFactory.cpp b/plugins/usbdmx/DMXCreator512BasicFactory.cpp index 0728e7a183..caa6a0de5d 100644 --- a/plugins/usbdmx/DMXCreator512BasicFactory.cpp +++ b/plugins/usbdmx/DMXCreator512BasicFactory.cpp @@ -55,6 +55,9 @@ bool DMXCreator512BasicFactory::DeviceAdded( // vendor and product ids. Also, since DMXCreator 512 Basic devices don't have // serial numbers and there is no other good way to uniquely identify a USB // device, we only support one of these types of devices per host. + // TODO(Peter): We could instead use the device & bus number (like the + // Eurolite plugin). You could use more than one device, but the patch + // wouldn't follow if you plugged it into a different port if (info.serial.empty()) { if (m_missing_serial_number) { OLA_WARN << "We can only support one device without a serial number."; diff --git a/plugins/usbdmx/ScanlimeFadecandyFactory.cpp b/plugins/usbdmx/ScanlimeFadecandyFactory.cpp index 4f1420a8b6..60f28d5dd9 100644 --- a/plugins/usbdmx/ScanlimeFadecandyFactory.cpp +++ b/plugins/usbdmx/ScanlimeFadecandyFactory.cpp @@ -64,6 +64,9 @@ bool ScanlimeFadecandyFactory::DeviceAdded( // Fadecandy devices may be missing serial numbers. Since there isn't another // good way to uniquely identify a USB device, we only support one of these // types of devices per host. + // TODO(Peter): We could instead use the device & bus number (like the + // Eurolite plugin). You could use more than one device, but the patch + // wouldn't follow if you plugged it into a different port if (info.serial.empty()) { if (m_missing_serial_number) { OLA_WARN << "Failed to read serial number or serial number empty. " From 0fac6e8e73e4a7fca6be10c84c788c208fc047b4 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 3 Feb 2024 16:52:22 +0000 Subject: [PATCH 52/56] Enable access to the device info outside the if statements --- plugins/usbdmx/EuroliteProFactory.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/usbdmx/EuroliteProFactory.cpp b/plugins/usbdmx/EuroliteProFactory.cpp index be380862a3..42efe7bea6 100644 --- a/plugins/usbdmx/EuroliteProFactory.cpp +++ b/plugins/usbdmx/EuroliteProFactory.cpp @@ -92,11 +92,11 @@ bool EuroliteProFactory::DeviceAdded( libusb_device *usb_device, const struct libusb_device_descriptor &descriptor) { bool is_mk2 = false; + LibUsbAdaptor::DeviceInformation info; // Eurolite USB-DMX512-PRO? if (descriptor.idVendor == VENDOR_ID && descriptor.idProduct == PRODUCT_ID) { OLA_INFO << "Found a new Eurolite USB-DMX512-PRO device"; - LibUsbAdaptor::DeviceInformation info; if (!m_adaptor->GetDeviceInfo(usb_device, descriptor, &info)) { return false; } @@ -112,7 +112,6 @@ bool EuroliteProFactory::DeviceAdded( // Eurolite USB-DMX512-PRO MK2? } else if (descriptor.idVendor == VENDOR_ID_MK2 && descriptor.idProduct == PRODUCT_ID_MK2) { - LibUsbAdaptor::DeviceInformation info; if (!m_adaptor->GetDeviceInfo(usb_device, descriptor, &info)) { return false; } From 2df204c5d5eaba6983fa3e9e6002aab26a98c002 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Dec 2023 21:34:03 +0000 Subject: [PATCH 53/56] Bump actions/download-artifact from 3 to 4 Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yaml | 2 +- .github/workflows/debian.yml | 2 +- .github/workflows/lint.yaml | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 8408df474e..a22a593886 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -165,7 +165,7 @@ jobs: - id: "distcheck-debian-stable-amd64-clang" steps: - name: Download built source tree archive - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: ola-${{ matrix.id }}-source-tree path: . diff --git a/.github/workflows/debian.yml b/.github/workflows/debian.yml index 0ae5317ba0..c06f7195c5 100644 --- a/.github/workflows/debian.yml +++ b/.github/workflows/debian.yml @@ -72,7 +72,7 @@ jobs: steps: - uses: actions/checkout@master - name: Download build artifact - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: ola-built-debian-${{ matrix.image_tag }}-${{ matrix.architecture }} path: built diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 0c49e768a0..d07b310836 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -67,7 +67,7 @@ jobs: needs: build steps: - name: Download built source tree archive - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: ola-debian-stable-built-source-tree path: . @@ -97,7 +97,7 @@ jobs: needs: build steps: - name: Download built source tree archive - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: ola-debian-stable-built-source-tree path: . @@ -123,7 +123,7 @@ jobs: needs: build steps: - name: Download built source tree archive - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: ola-debian-stable-built-source-tree path: . @@ -160,7 +160,7 @@ jobs: needs: build steps: - name: Download built source tree archive - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: ola-debian-stable-built-source-tree path: . @@ -197,7 +197,7 @@ jobs: needs: build steps: - name: Download built source tree archive - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: ola-debian-stable-built-source-tree path: . @@ -226,7 +226,7 @@ jobs: needs: build steps: - name: Download built source tree archive - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: ola-debian-stable-built-source-tree path: . From 8c78dbd7f0c160ca91ca49744b53953e1ba0e4d6 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Tue, 27 Feb 2024 23:11:32 +0000 Subject: [PATCH 54/56] Switch to actions/upload-artifact@v4 --- .github/workflows/lint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index d07b310836..12d892fb4c 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -56,7 +56,7 @@ jobs: tar --exclude=ola-debian-stable-built-source-tree.tar.gz -cvzf ola-debian-stable-built-source-tree.tar.gz . - name: SHA256 artifact archive run: sha256sum ola-debian-stable-built-source-tree.tar.gz - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: ola-debian-stable-built-source-tree path: ola-debian-stable-built-source-tree.tar.gz From 5e704b131fdc0038f64b7150a0b2b1cec6b44598 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Tue, 27 Feb 2024 23:12:06 +0000 Subject: [PATCH 55/56] Switch to actions/upload-artifact@v4 --- .github/workflows/build.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a22a593886..296da8211b 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -119,14 +119,14 @@ jobs: if: always() run: sha256sum ola-*.tar.gz - name: Upload source tree artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: always() with: name: ola-${{ matrix.id }}-source-tree path: ola-${{ matrix.id }}-source-tree.tar.gz - name: Upload built artifact if: matrix.task == 'distcheck' || matrix.task == 'dist' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ola-${{ matrix.id }}-dist path: | @@ -147,7 +147,7 @@ jobs: flag-name: ${{ matrix.id }} - name: Upload coverage artifacts if: always() && matrix.task == 'coverage' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ola-${{ matrix.id }}-coverage path: coverage/ From 2313c93e52cb22bca8a162a2c3ff6e0f6d6b2016 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Tue, 27 Feb 2024 23:12:39 +0000 Subject: [PATCH 56/56] Switch to actions/upload-artifact@v4 --- .github/workflows/debian.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/debian.yml b/.github/workflows/debian.yml index c06f7195c5..7fff3d801f 100644 --- a/.github/workflows/debian.yml +++ b/.github/workflows/debian.yml @@ -53,7 +53,7 @@ jobs: shell: bash run: find . -type f -exec sha256sum {} \; working-directory: built - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: always() with: name: ola-built-debian-${{ matrix.image_tag }}-${{ matrix.architecture }} @@ -85,7 +85,7 @@ jobs: run: apt-get -y install autopkgtest - name: Test run: autopkgtest --output-dir=test-output built/*ges -- null - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: always() # Always upload the test output, even on failed tests with: name: ola-test-output-debian-${{ matrix.image_tag }}-${{ matrix.architecture }}