Browse Source

initial upload

master release-0.1
Kevin Matz 5 years ago
parent
commit
c7e5b385b3
  1. 70
      afuzz.cpp
  2. 72
      afuzz.h
  3. 13
      afuzz.pro

70
afuzz.cpp

@ -0,0 +1,70 @@
/*
* Copyright © 2017 Kevin Matz (kevin.matz@gmail.com)
*
* This file is part of afuzz (an Art-Net protocol utility).
*
* afuzz is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* afuzz 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with afuzz. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "afuzz.h"
#include <QCoreApplication>
#include <QtEndian>
#include <QTimer>
const QString ARTNET::ID = "Art-Net\x00";
Node::Node(QObject *parent) : QObject(parent)
{
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL( timeout() ), this, SLOT( sendDMX() ));
timer->start(1000/40);
}
void Node::sendDMX()
{
QByteArray datagram;
ARTNET::header h;
ARTNET::payload_DMX p;
quint16 size = 512;
strcpy( h.id, ARTNET::ID.toLocal8Bit().constData() );
h.opCode = ARTNET::OpDmx;
h.version = qToBigEndian( (quint16) ARTNET::VERSION );
p.sequence = 0;
p.physical = 0;
p.subuni = 0;
p.net = 0;
p.length = qToBigEndian(size);
datagram.append(QByteArray::fromRawData( (char*) &h, sizeof(h) ));
datagram.append(QByteArray::fromRawData( (char*) &p, sizeof(p) ));
for (int i = 0; i < size; i++)
datagram.append( (quint8) (i/2) );
socket.writeDatagram(datagram, QHostAddress::Broadcast, ARTNET::PORT);
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
Node n;
return a.exec();
}

72
afuzz.h

@ -0,0 +1,72 @@
/*
* Copyright © 2017 Kevin Matz (kevin.matz@gmail.com)
*
* This file is part of afuzz (an Art-Net protocol utility).
*
* afuzz is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* afuzz 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with afuzz. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef AFUZZ_H
#define AFUZZ_H
#include <QObject>
#include <QUdpSocket>
/**
* @brief The bare minimun to generate and send Art-Net
*/
class Node : public QObject
{
Q_OBJECT
public:
explicit Node(QObject *parent = 0);
private slots:
void sendDMX();
private:
QUdpSocket socket;
};
/**
* @brief A _minimal_ ARTNET protocol definition
*/
class ARTNET
{
public:
static const int PORT = 6454;
static const QString ID; // = "Art-Net";
static const quint16 VERSION = 14;
struct header {
char id[8]; //!< Array of 8 characters, the final character is a null termination.
quint16 opCode; //!< defines the class of data following ArtPoll within this UDP packet.
quint16 version; //!< the Art-Net protocol revision number. Current value 14.
} __attribute__((packed));
struct payload_DMX {
quint8 sequence; //!< The sequence number is used to ensure that ArtDmx packets are used in the correct order.
quint8 physical; //!< The physical input port from which DMX512 data was input.
quint8 subuni; //!< The low byte of the 15 bit Port-Address to which this packet is destined.
quint8 net; //!< The top 7 bits of the 15 bit Port-Address to which this packet is destined.
quint16 length; //!< The length of the DMX512 data array. This value should be an even number in the range 2 – 512.
} __attribute__((packed));
enum OpCodes {
OpDmx = 0x5000 //!< an ArtDmx data packet. It contains zero start code DMX512 information for a single Universe.
};
};
#endif // AFUZZ_H

13
afuzz.pro

@ -0,0 +1,13 @@
QT += core network
QT -= gui
CONFIG += c++11
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
TARGET = afuzz
SOURCES += afuzz.cpp
HEADERS += afuzz.h
OTHER_FILES += LICENSE \
README.md
Loading…
Cancel
Save