Skip to content

Commit 14d736a

Browse files
committed
Refactor Art-Net, RDM and build system
Large refactor across Art-Net, RDM, DMX node utilities and build files: - Rename and relocate lib-dmxnode/include/dmxnode_utils.h -> common/include/common/utils/utils_port.h; change namespace json -> common and remove static qualifiers from PortSet/PortGet. - Update makefiles: add Timestamp.mk (adds -D_TIME_STAMP_ with epoch seconds), include it from gd32/Validate.mk; other small make tweaks and conditional source inclusion in lib-artnet/Rules.mk. - Bump copyright years in sources. - Remove/replace direct RdmDevice initialization/printing from several firmware mains; add product category/detail defines in gd32_rdm_responder/Common.mk instead and adjust LLRP-only behavior (print LLRP device, adjust FirmwareVersion construction). - Major rework of lib-artnet/include/artnet.h: rename many struct fields and constants to snake_case/clearer names, add port address bounds, add OpCodes (ArtCommand, ArtDataRequest/Reply), add ArtCommand struct, refine comments and bit/flag names, and other API/ABI-preserving layout clarifications. - Add/rename multiple RDM headers and sources (new rdm_device_*.h, discovery/statemachine renames, gd32 RDM device implementation), reorganize rdm-related source filenames. - Misc: several firmware mains adjusted for RDM/L RRP handling and minor cleanup across many modules. These changes standardize naming, improve build timestamping, consolidate utility code, and reorganize RDM/Art-Net interfaces for clearer semantics and conditional builds. Developers should verify ABI compatibility where packets/structs are serialized and update any code that referenced old identifiers.
1 parent 23cbae5 commit 14d736a

76 files changed

Lines changed: 2831 additions & 2218 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,25 @@
2323
* THE SOFTWARE.
2424
*/
2525

26-
#ifndef DMXNODE_UTILS_H_
27-
#define DMXNODE_UTILS_H_
26+
#ifndef COMMON_UTILS_UTILS_PORT_H_
27+
#define COMMON_UTILS_UTILS_PORT_H_
2828

2929
#include <cstdint>
3030

31-
namespace json
31+
namespace common
3232
{
33-
template <class S> static void PortSet(uint32_t port_index, S s, uint16_t& n)
33+
template <class S> void PortSet(uint32_t port_index, S s, uint16_t& n)
3434
{
3535
uint16_t value = n; // Create a local copy
3636
value &= static_cast<uint16_t>(~(0x3 << (port_index * 2)));
3737
value |= static_cast<uint16_t>((static_cast<uint32_t>(s) & 0x3) << (port_index * 2));
3838
n = value; // Write back to the original field
3939
}
4040

41-
template <class S> static S PortGet(uint32_t port_index, uint16_t n)
41+
template <class S> S PortGet(uint32_t port_index, uint16_t n)
4242
{
4343
return static_cast<S>((n >> (port_index * 2)) & 0x3);
4444
}
45-
} // namespace json
45+
} // namespace common
4646

47-
#endif // DMXNODE_UTILS_H_
47+
#endif // COMMON_UTILS_UTILS_PORT_H_

common/make/Timestamp.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ $(info "Timestamp.mk")
22

33
ifneq ($(findstring _TIME_STAMP_YEAR_,$(DEFINES)), _TIME_STAMP_YEAR_)
44
DEFINES += \
5-
-D_TIME_STAMP_YEAR_=$(shell date +"%Y") \
5+
-D_TIME_STAMP_=$(shell date "+%s") \
6+
-D_TIME_STAMP_YEAR_=$(shell date +"%Y") \
67
-D_TIME_STAMP_MONTH_=$(shell date +"%m" | sed 's/^0*//') \
78
-D_TIME_STAMP_DAY_=$(shell date +"%d" | sed 's/^0*//')
89
endif

common/make/gd32/Validate.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ifeq ($(FLAGS),)
88
endif
99

1010
ifneq ($(findstring _TIME_STAMP_YEAR_,$(FLAGS)),_TIME_STAMP_YEAR_)
11-
DEFINES+=-D_TIME_STAMP_YEAR_=$(shell date +"%Y") -D_TIME_STAMP_MONTH_=$(shell date +"%-m") -D_TIME_STAMP_DAY_=$(shell date +"%-d")
11+
include ../common/make/Timestamp.mk
1212
endif
1313

1414
ifneq (,$(findstring OUTPUT_DMX_SEND,$(FLAGS))$(findstring CONFIG_RDM,$(FLAGS))$(findstring RDM_CONTROLLER,$(FLAGS))$(findstring LTC,$(FLAGS)))

gd32_emac_e131_dmx_multi/firmware/main.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
#include "dmxnodemsgconst.h"
3636
#if defined(NODE_RDMNET_LLRP_ONLY)
3737
#include "rdmnetdevice.h"
38-
#include "rdmdevice.h"
39-
#include "rdm_e120.h"
4038
#endif
4139
#if defined(NODE_SHOWFILE)
4240
#include "showfile.h"
@@ -45,7 +43,6 @@
4543
#include "configstore.h"
4644
#include "firmwareversion.h"
4745
#include "software_version.h"
48-
#include "software_version_id.h"
4946

5047
namespace hal
5148
{
@@ -62,7 +59,7 @@ int main() // NOLINT
6259
DisplayUdf display;
6360
ConfigStore config_store;
6461
network::Init();
65-
FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__, DEVICE_SOFTWARE_VERSION_ID);
62+
FirmwareVersion fw(SOFTWARE_VERSION, __DATE__, __TIME__);
6663

6764
fw.Print("sACN E1.31 DMX {" STR(DMXNODE_PORTS) " Universes}");
6865

@@ -87,13 +84,8 @@ int main() // NOLINT
8784
const auto kActivePorts = dmxnode_node.GetActiveInputPorts() + dmxnode_node.GetActiveOutputPorts();
8885

8986
#if defined(NODE_RDMNET_LLRP_ONLY)
90-
auto& rdm_device = RdmDevice::Get();
91-
rdm_device.SetProductCategory(E120_PRODUCT_CATEGORY_DATA_DISTRIBUTION);
92-
rdm_device.SetProductDetail(E120_PRODUCT_DETAIL_ETHERNET_NODE);
93-
rdm_device.Init();
94-
rdm_device.Print();
95-
9687
RDMNetDevice llrp_only_device;
88+
llrp_only_device.Print();
9789
#endif
9890

9991
#if defined(NODE_SHOWFILE)

lib-artnet/Rules.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ ifneq ($(MAKE_FLAGS),)
1313
ifeq ($(findstring RDM_CONTROLLER,$(MAKE_FLAGS)), RDM_CONTROLLER)
1414
EXTRA_SRCDIR+=src/node/rdm
1515
EXTRA_SRCDIR+=src/node/rdm/controller
16+
ifeq ($(findstring ARTNET_HAVE_DMXIN,$(MAKE_FLAGS)), ARTNET_HAVE_DMXIN)
17+
EXTRA_SRCDIR+=src/node/rdm/controller/rdmin
18+
endif
1619
EXTRA_INCLUDES+=../lib-rdm/include ../lib-dmx/include
1720
ifeq ($(findstring ENABLE_HTTPD,$(MAKE_FLAGS)), ENABLE_HTTPD)
1821
EXTRA_SRCDIR+=src/node/rdm/controller/json

lib-artnet/include/artnet.h

Lines changed: 245 additions & 220 deletions
Large diffs are not rendered by default.

lib-artnet/include/artnetcontroller.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class ArtNetController : public ArtNetPollTable
140140
union artnet::UArtPacket ArtPacket;
141141
uint32_t IPAddressFrom;
142142
uint16_t nLength;
143-
artnet::OpCodes OpCode;
143+
artnet::OpCodes op_code;
144144
};
145145
TArtNetPacket* m_pArtNetPacket;
146146

lib-artnet/include/artnetnode.h

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include <cstdint>
3434
#include <cstdarg>
3535
#include <cstring>
36-
#include <cassert>
3736

3837
#if !defined(ARTNET_VERSION)
3938
#error ARTNET_VERSION is not defined
@@ -58,12 +57,14 @@
5857
#if defined(RDM_RESPONDER)
5958
#include "artnetrdmresponder.h"
6059
#endif
60+
#if defined(ARTNET_HAVE_TIMECODE)
61+
#include "network_udp.h"
62+
#endif
6163
#if (ARTNET_VERSION >= 4)
6264
#include "e131bridge.h"
6365
#endif
6466
#include "dmxnode.h"
6567
#include "dmxnode_outputtype.h"
66-
#include "network.h"
6768
#include "firmware/debug/debug_debug.h"
6869

6970
#ifndef ALIGNED
@@ -73,6 +74,7 @@
7374
namespace artnetnode
7475
{
7576
inline constexpr uint32_t kPollReplyQueueSize = 4;
77+
inline constexpr uint32_t kTodRequestListSize = 4;
7678

7779
enum class PollReplyState : uint8_t
7880
{
@@ -90,6 +92,9 @@ struct State
9092
uint32_t poll_reply_delay_millis;
9193
uint32_t dmx_ip;
9294
uint32_t sync_millis; ///< Latest ArtSync received time
95+
#if defined(RDM_CONTROLLER)
96+
uint32_t tod_request_ip_list[kTodRequestListSize];
97+
#endif
9398
artnet::ArtPollQueue poll_reply_queue[kPollReplyQueueSize];
9499
uint8_t poll_reply_queue_index;
95100
uint8_t poll_reply_port_index;
@@ -226,9 +231,9 @@ class ArtNetNode
226231
bool GetRdm() const { return state_.is_rdm_enabled; }
227232

228233
void SetRdm(uint32_t port_index, bool enable);
229-
bool GetRdm(uint32_t port_index) const;
234+
bool Rdm(uint32_t port_index) const;
230235

231-
void SendTod(uint32_t port_index);
236+
void SendArtTodData(uint32_t port_index);
232237

233238
void Print();
234239

@@ -261,16 +266,15 @@ class ArtNetNode
261266

262267
bool GetOutputPort(uint16_t universe, uint32_t& port_index);
263268

264-
void RestartOutputPort(uint32_t port_index);
269+
void StopOutputPort(uint32_t port_index);
265270

266271
#if defined(RDM_CONTROLLER)
267-
void SetRdmController(ArtNetRdmController* art_net_rdm_controller, bool do_enable = true);
268272
uint32_t RdmCopyWorkingQueue(char* out_buffer, uint32_t out_buffer_size);
269-
uint32_t RdmGetUidCount(uint32_t port_index);
273+
uint32_t RdmTodUidCount(uint32_t port_index);
270274
uint32_t RdmCopyTod(uint32_t port_index, char* out_buffer, uint32_t out_buffer_size);
271275
bool RdmIsRunning(uint32_t port_index);
272276
bool RdmIsRunning(uint32_t port_index, bool& is_incremental);
273-
bool GetRdmDiscovery(uint32_t port_index);
277+
bool RdmBgDiscovery(uint32_t port_index);
274278
#endif
275279

276280
#if defined(RDM_RESPONDER)
@@ -281,7 +285,7 @@ class ArtNetNode
281285
void SendTimeCode(const struct artnet::TimeCode* timecode)
282286
{
283287
assert(timecode != nullptr);
284-
memcpy(&art_time_code_.Frames, timecode, sizeof(struct artnet::TimeCode));
288+
memcpy(&art_time_code_.frames, timecode, sizeof(struct artnet::TimeCode));
285289
network::udp::Send(handle_, reinterpret_cast<const uint8_t*>(&art_time_code_), sizeof(struct artnet::ArtTimeCode), node_.ip_timecode, artnet::kUdpPort);
286290
}
287291

@@ -319,23 +323,6 @@ class ArtNetNode
319323
return 0;
320324
}
321325

322-
/**
323-
* LLRP
324-
*/
325-
void SetRdmUID(const uint8_t* uid, bool supports_llrp = false)
326-
{
327-
memcpy(art_poll_reply_.DefaultUidResponder, uid, sizeof(art_poll_reply_.DefaultUidResponder));
328-
329-
if (supports_llrp)
330-
{
331-
art_poll_reply_.Status3 |= artnet::Status3::kSupportsLlrp;
332-
}
333-
else
334-
{
335-
art_poll_reply_.Status3 &= static_cast<uint8_t>(~artnet::Status3::kSupportsLlrp);
336-
}
337-
}
338-
339326
void static StaticCallbackFunction(const uint8_t* buffer, uint32_t size, uint32_t from_ip, uint16_t from_port)
340327
{
341328
s_this->InputUdp(buffer, size, from_ip, from_port);
@@ -397,6 +384,7 @@ class ArtNetNode
397384

398385
void ProcessPollReply(uint32_t port_index);
399386
void SendPollReply(uint32_t port_index, uint32_t destination_ip, artnet::ArtPollQueue* poll_queue = nullptr);
387+
void PollReplyQueueAdd(uint16_t target_port_address_bottom, uint16_t target_port_address_top);
400388

401389
void SendTodRequest(uint32_t port_index);
402390

@@ -405,10 +393,6 @@ class ArtNetNode
405393
void FailSafeRecord();
406394
void FailSafePlayback();
407395

408-
#if defined(RDM_CONTROLLER)
409-
bool RdmDiscoveryRun();
410-
#endif
411-
412396
void InputUdp(const uint8_t* buffer, uint32_t size, uint32_t from_ip, uint16_t from_port);
413397

414398
private:
@@ -444,7 +428,7 @@ class ArtNetNode
444428
ArtNetRdmController rdm_controller_;
445429
#endif
446430
#if defined(RDM_RESPONDER)
447-
ArtNetRdmResponder* rdm_responder_;
431+
ArtNetRdmResponder* rdm_responder_{nullptr};
448432
#endif
449433
#endif
450434
#if defined(ARTNET_HAVE_TIMECODE)

lib-artnet/include/artnetnode4_inline_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ inline void ArtNetNode::SetPriority4(uint32_t port_index, uint8_t priority)
134134

135135
inline void ArtNetNode::SetPriority4(uint32_t priority)
136136
{
137-
art_poll_reply_.AcnPriority = static_cast<uint8_t>(priority);
137+
art_poll_reply_.acn_priority = static_cast<uint8_t>(priority);
138138

139139
for (uint32_t port_index = 0; port_index < dmxnode::kMaxPorts; port_index++)
140140
{

lib-artnet/include/artnetnode_inline_impl.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ inline DmxNodeOutputType* ArtNetNode::GetOutput() const
6464

6565
inline const char* ArtNetNode::GetLongName() const
6666
{
67-
return reinterpret_cast<const char*>(art_poll_reply_.LongName);
67+
return reinterpret_cast<const char*>(art_poll_reply_.long_name);
6868
}
6969

7070
inline void ArtNetNode::SetDisableMergeTimeout(bool disable)
@@ -156,7 +156,7 @@ inline void ArtNetNode::SetFailSafe(dmxnode::FailSafe fail_safe)
156156

157157
inline dmxnode::FailSafe ArtNetNode::GetFailSafe()
158158
{
159-
const auto kNetworkloss = (art_poll_reply_.Status3 & artnet::Status3::kNetworklossMask);
159+
const auto kNetworkloss = (art_poll_reply_.status3 & artnet::Status3::kNetworklossMask);
160160
switch (kNetworkloss)
161161
{
162162
case artnet::Status3::kNetworklossLastState:
@@ -214,7 +214,7 @@ inline void ArtNetNode::SetRdm(uint32_t port_index, bool enable)
214214
}
215215
}
216216

217-
inline bool ArtNetNode::GetRdm(uint32_t port_index) const
217+
inline bool ArtNetNode::Rdm(uint32_t port_index) const
218218
{
219219
assert(port_index < dmxnode::kMaxPorts);
220220
return !((output_port_[port_index].good_output_b & artnet::GoodOutputB::kRdmDisabled) == artnet::GoodOutputB::kRdmDisabled);
@@ -278,13 +278,13 @@ inline bool ArtNetNode::GetOutputPort(uint16_t universe, uint32_t& port_index)
278278
return false;
279279
}
280280

281-
inline void ArtNetNode::RestartOutputPort(uint32_t port_index)
281+
inline void ArtNetNode::StopOutputPort(uint32_t port_index)
282282
{
283-
if (output_port_[port_index].is_transmitting)
284-
{
285-
dmxnode_output_type_->Stop(port_index);
286-
dmxnode_output_type_->Start(port_index);
287-
}
283+
if (output_port_[port_index].is_transmitting)
284+
{
285+
output_port_[port_index].is_transmitting = false;
286+
dmxnode_output_type_->Stop(port_index); // Stop DMX if was running
287+
}
288288
}
289289

290290
inline void ArtNetNode::Run()
@@ -311,7 +311,7 @@ inline void ArtNetNode::Run()
311311
}
312312

313313
#if (DMXNODE_PORTS > 0)
314-
if ((((art_poll_reply_.Status1 & artnet::Status1::kIndicatorMask) == artnet::Status1::kIndicatorNormalMode)) &&
314+
if ((((art_poll_reply_.status1 & artnet::Status1::kIndicatorMask) == artnet::Status1::kIndicatorNormalMode)) &&
315315
(hal::statusled::GetMode() != hal::statusled::Mode::FAST))
316316
{
317317
#if (ARTNET_VERSION >= 4)
@@ -354,7 +354,7 @@ inline void ArtNetNode::Run()
354354

355355
state_.art.poll_reply_port_index++;
356356

357-
if (state_.art.poll_reply_port_index == dmxnode::kMaxPorts)
357+
if (state_.art.poll_reply_port_index >= dmxnode::kMaxPorts)
358358
{
359359
entry.art_poll_millis = 0;
360360
state_.art.poll_reply_state = artnetnode::PollReplyState::kWaitingTimeout;
@@ -393,7 +393,7 @@ inline void ArtNetNode::SendDiag([[maybe_unused]] const artnet::PriorityCodes kP
393393
return;
394394
}
395395

396-
diag_data_.Priority = static_cast<uint8_t>(kPriorityCode);
396+
diag_data_.priority = static_cast<uint8_t>(kPriorityCode);
397397

398398
va_list arp;
399399

@@ -404,12 +404,12 @@ inline void ArtNetNode::SendDiag([[maybe_unused]] const artnet::PriorityCodes kP
404404
va_end(arp);
405405

406406
diag_data_.data[sizeof(diag_data_.data) - 1] = '\0'; // Just be sure we have a last '\0'
407-
diag_data_.LengthLo = static_cast<uint8_t>(i + 1); // Text length including the '\0'
407+
diag_data_.length_lo = static_cast<uint8_t>(i + 1); // Text length including the '\0'
408408

409-
const uint16_t kSize = sizeof(struct artnet::ArtDiagData) - sizeof(diag_data_.data) + diag_data_.LengthLo;
409+
const uint16_t kSize = sizeof(struct artnet::ArtDiagData) - sizeof(diag_data_.data) + diag_data_.length_lo;
410410

411411
network::udp::Send(handle_, reinterpret_cast<const uint8_t*>(&diag_data_), kSize, state_.art.diag_ip, artnet::kUdpPort);
412412
#endif
413413
}
414414

415-
#endif // ARTNETNODE_INLINE_IMPL_H_
415+
#endif // ARTNETNODE_INLINE_IMPL_H_

0 commit comments

Comments
 (0)