Added source and cid to e1.31 driver. (#207)

source defaults to "hyperion on <hostname>"
cid defautls to randomly generated on each startup

        "device" :
        {
                "name"       : "DMX_e131",
                "type"       : "e131",
                "universe"   : 1,
                "cid" : "{204b83c-efb5-4b23-b2d0-35939d561061}",
                "source-name": "This is my custom e1.31 source",
                "host"       : "239.255.0.1",
                "port"       : 5568,
                "colorOrder" : "rgb"
        },
This commit is contained in:
penfold42 2016-08-28 18:45:18 +10:00 committed by redPanther
parent cc8185691a
commit c13f2e20ec
2 changed files with 22 additions and 6 deletions

View File

@ -9,6 +9,9 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <QHostInfo>
#include <QUuid>
// hyperion local includes // hyperion local includes
#include "LedDeviceUdpE131.h" #include "LedDeviceUdpE131.h"
@ -24,6 +27,17 @@ bool LedDeviceUdpE131::setConfig(const Json::Value &deviceConfig)
ProviderUdp::setConfig(deviceConfig); ProviderUdp::setConfig(deviceConfig);
_LatchTime_ns = deviceConfig.get("latchtime",104000).asInt(); _LatchTime_ns = deviceConfig.get("latchtime",104000).asInt();
_e131_universe = deviceConfig.get("universe",1).asInt(); _e131_universe = deviceConfig.get("universe",1).asInt();
_e131_source_name = deviceConfig.get("source-name","hyperion on "+QHostInfo::localHostName().toStdString()).asString();
QString _json_cid = QString::fromStdString(deviceConfig.get("cid","").asString());
if (_json_cid.isEmpty())
{
_e131_cid = QUuid::createUuid();
Debug( _log, "e131 no cid found, generated %s", _e131_cid.toString().toStdString().c_str());
} else {
_e131_cid = QUuid(_json_cid);
Debug( _log, "e131 cid found, using %s", _e131_cid.toString().toStdString().c_str());
}
return true; return true;
} }
@ -33,8 +47,6 @@ LedDevice* LedDeviceUdpE131::construct(const Json::Value &deviceConfig)
return new LedDeviceUdpE131(deviceConfig); return new LedDeviceUdpE131(deviceConfig);
} }
#define CID "hyperion!\0"
#define SOURCE_NAME "hyperion on hostname\0"
// populates the headers // populates the headers
void LedDeviceUdpE131::prepare(const unsigned this_universe, const unsigned this_dmxChannelCount) void LedDeviceUdpE131::prepare(const unsigned this_universe, const unsigned this_dmxChannelCount)
@ -47,12 +59,12 @@ void LedDeviceUdpE131::prepare(const unsigned this_universe, const unsigned this
memcpy (e131_packet.acn_id, _acn_id, 12); memcpy (e131_packet.acn_id, _acn_id, 12);
e131_packet.root_flength = htons(0x7000 | (110+this_dmxChannelCount) ); e131_packet.root_flength = htons(0x7000 | (110+this_dmxChannelCount) );
e131_packet.root_vector = htonl(VECTOR_ROOT_E131_DATA); e131_packet.root_vector = htonl(VECTOR_ROOT_E131_DATA);
memcpy (e131_packet.cid, CID, sizeof(CID) ); memcpy (e131_packet.cid, _e131_cid.toRfc4122().constData() , sizeof(e131_packet.cid) );
/* Frame Layer */ /* Frame Layer */
e131_packet.frame_flength = htons(0x7000 | (88+this_dmxChannelCount)); e131_packet.frame_flength = htons(0x7000 | (88+this_dmxChannelCount));
e131_packet.frame_vector = htonl(VECTOR_E131_DATA_PACKET); e131_packet.frame_vector = htonl(VECTOR_E131_DATA_PACKET);
memcpy (e131_packet.source_name, SOURCE_NAME, sizeof(SOURCE_NAME)); snprintf (e131_packet.source_name, sizeof(e131_packet.source_name), "%s", _e131_source_name.c_str() );
e131_packet.priority = 100; e131_packet.priority = 100;
e131_packet.reserved = htons(0); e131_packet.reserved = htons(0);
e131_packet.options = 0; // Bit 7 = Preview_Data e131_packet.options = 0; // Bit 7 = Preview_Data

View File

@ -6,6 +6,8 @@
// hyperion includes // hyperion includes
#include "ProviderUdp.h" #include "ProviderUdp.h"
#include <QUuid>
/* /*
* *
* https://raw.githubusercontent.com/forkineye/ESPixelStick/master/_E131.h * https://raw.githubusercontent.com/forkineye/ESPixelStick/master/_E131.h
@ -55,12 +57,12 @@ typedef union {
uint8_t acn_id[12]; uint8_t acn_id[12];
uint16_t root_flength; uint16_t root_flength;
uint32_t root_vector; uint32_t root_vector;
uint8_t cid[16]; char cid[16];
/* Frame Layer */ /* Frame Layer */
uint16_t frame_flength; uint16_t frame_flength;
uint32_t frame_vector; uint32_t frame_vector;
uint8_t source_name[64]; char source_name[64];
uint8_t priority; uint8_t priority;
uint16_t reserved; uint16_t reserved;
uint8_t sequence_number; uint8_t sequence_number;
@ -135,4 +137,6 @@ private:
uint8_t _e131_seq = 0; uint8_t _e131_seq = 0;
uint8_t _e131_universe = 1; uint8_t _e131_universe = 1;
uint8_t _acn_id[12] = {0x41, 0x53, 0x43, 0x2d, 0x45, 0x31, 0x2e, 0x31, 0x37, 0x00, 0x00, 0x00 }; uint8_t _acn_id[12] = {0x41, 0x53, 0x43, 0x2d, 0x45, 0x31, 0x2e, 0x31, 0x37, 0x00, 0x00, 0x00 };
std::string _e131_source_name;
QUuid _e131_cid;
}; };