From 0f52fe2359e93c78a604bab2a9820d0ce8826328 Mon Sep 17 00:00:00 2001 From: amyhlback Date: Sun, 14 Jun 2020 08:44:15 +0200 Subject: [PATCH 1/5] Add mac address to ArtPollReply Note: reads the mac address from the ethernet shield every time, could probably be set at Artnet construction since it is probably static. --- Artnet.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Artnet.cpp b/Artnet.cpp index 419819c..e76345e 100755 --- a/Artnet.cpp +++ b/Artnet.cpp @@ -142,6 +142,12 @@ uint16_t Artnet::read() ArtPollReply.swremote = 0; ArtPollReply.style = 0; + #if !defined(ARDUINO_SAMD_ZERO) && !defined(ESP8266) && !defined(ESP32) + Ethernet.MACAddress(ArtPollReply.mac); + #else + WiFi.macAdress(ArtPollReply.mac); + #endif + ArtPollReply.numbportsH = 0; ArtPollReply.numbports = 4; ArtPollReply.status2 = 0x08; From 3456d2fb5fd27df7fcedabc1e058dea8e7575717 Mon Sep 17 00:00:00 2001 From: amyhlback Date: Sun, 14 Jun 2020 08:49:37 +0200 Subject: [PATCH 2/5] Fix PortTypes According to the Art-Net spec, 0xc0 is for units both transmitting and recieving. 0x80 is for only recieving. --- Artnet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Artnet.cpp b/Artnet.cpp index e76345e..5f75860 100755 --- a/Artnet.cpp +++ b/Artnet.cpp @@ -118,7 +118,7 @@ uint16_t Artnet::read() memset(ArtPollReply.goodinput, 0x08, 4); memset(ArtPollReply.goodoutput, 0x80, 4); - memset(ArtPollReply.porttypes, 0xc0, 4); + memset(ArtPollReply.porttypes, 0x80, 4); uint8_t shortname [18]; uint8_t longname [64]; From 615fd39efb1480fea2a1d284ec16e3ada89d18ee Mon Sep 17 00:00:00 2001 From: amyhlback Date: Sun, 14 Jun 2020 10:34:40 +0200 Subject: [PATCH 3/5] 0 pad shortname, longname and nodereport Set memory to 0 before writing the strings to 0 pad them. --- Artnet.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Artnet.cpp b/Artnet.cpp index 5f75860..df4ff3e 100755 --- a/Artnet.cpp +++ b/Artnet.cpp @@ -120,12 +120,10 @@ uint16_t Artnet::read() memset(ArtPollReply.goodoutput, 0x80, 4); memset(ArtPollReply.porttypes, 0x80, 4); - uint8_t shortname [18]; - uint8_t longname [64]; - sprintf((char *)shortname, "artnet arduino"); - sprintf((char *)longname, "Art-Net -> Arduino Bridge"); - memcpy(ArtPollReply.shortname, shortname, sizeof(shortname)); - memcpy(ArtPollReply.longname, longname, sizeof(longname)); + memset(ArtPollReply.shortname, 0, 16); + memset(ArtPollReply.longname, 0, 64); + sprintf((char *)ArtPollReply.shortname, "artnet arduino"); + sprintf((char *)ArtPollReply.longname, "Art-Net -> Arduino Bridge"); ArtPollReply.etsaman[0] = 0; ArtPollReply.etsaman[1] = 0; @@ -164,6 +162,7 @@ uint16_t Artnet::read() ArtPollReply.swout[i] = swout[i]; ArtPollReply.swin[i] = swin[i]; } + memset(ArtPollReply.nodereport, 0, 64); sprintf((char *)ArtPollReply.nodereport, "%i DMX output universes active.", ArtPollReply.numbports); Udp.beginPacket(broadcast, ART_NET_PORT);//send the packet to the broadcast address Udp.write((uint8_t *)&ArtPollReply, sizeof(ArtPollReply)); From d96f5ba1ae0e930f4fbcd71ec1ecd0865f67e67d Mon Sep 17 00:00:00 2001 From: amyhlback Date: Sun, 14 Jun 2020 12:12:01 +0200 Subject: [PATCH 4/5] Changed reply-address of ArtPollReply to ArtPoll-er The reply should only be sent to the requesting Controller, not multicast. From https://art-net.org.uk/structure/discovery-packets/ "Upon receipt of an ArtPoll, all Art-Net devices respond by unicasting an ArtPollReply." (this also solved the port-errors that i got, dont know if it was my network, but when sending the reply to broadcast the target port became "65") --- Artnet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Artnet.cpp b/Artnet.cpp index df4ff3e..1cb1b01 100755 --- a/Artnet.cpp +++ b/Artnet.cpp @@ -164,7 +164,7 @@ uint16_t Artnet::read() } memset(ArtPollReply.nodereport, 0, 64); sprintf((char *)ArtPollReply.nodereport, "%i DMX output universes active.", ArtPollReply.numbports); - Udp.beginPacket(broadcast, ART_NET_PORT);//send the packet to the broadcast address + Udp.beginPacket(remoteIP, ART_NET_PORT);//send the packet to the Controller that sent ArtPoll Udp.write((uint8_t *)&ArtPollReply, sizeof(ArtPollReply)); Udp.endPacket(); From 9d2e59cc870769c202c2530cc8aab324230077fc Mon Sep 17 00:00:00 2001 From: amyhlback Date: Sun, 14 Jun 2020 12:18:27 +0200 Subject: [PATCH 5/5] Changed swin and swout universes to 0-indexed. The universe-addressing is 0-indexed. --- Artnet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Artnet.cpp b/Artnet.cpp index 1cb1b01..9d376c2 100755 --- a/Artnet.cpp +++ b/Artnet.cpp @@ -155,8 +155,8 @@ uint16_t Artnet::read() ArtPollReply.bindip[2] = node_ip_address[2]; ArtPollReply.bindip[3] = node_ip_address[3]; - uint8_t swin[4] = {0x01,0x02,0x03,0x04}; - uint8_t swout[4] = {0x01,0x02,0x03,0x04}; + uint8_t swin[4] = {0x00,0x01,0x02,0x03}; + uint8_t swout[4] = {0x00,0x01,0x02,0x03}; for(uint8_t i = 0; i < 4; i++) { ArtPollReply.swout[i] = swout[i];