Closed skankerror closed 1 year ago
Hi, I noticed that as well recently and just pushed a quick fix that seems to work for me, let me know how it goes.
That worked for me too ! thanks
Actually it compiles, but I have difficulties to use the lib. would you provide an example ?
Yeah sure, just keep in mind this library is in very early development and the API is very likely to change from commit to commit. Obviously once I reach a point where I'm happy enough to make a release, I'll post documentation, examples and make sure to not break the API in the future (or at least give sufficient deprecation warning).
Also, since it is still in development, it is very likely to have bugs and crash... If you feel like it, I will happily accept a pull request :)
In this example I will omit all the Qt boilerplate code, the library needs to run within a Qt application of course:
#include <qdmxlib/QDmxManager>
void dmx_example()
{
// The QDmxManager is what you will use most of the time.
// It is responsible for managing which DMX data goes to which DMX device
// it provides patching methods to assign a physical device to a DMX universe
// and read and write methods to work with DMX data
// Please note that this the manager is implemented as a Singleton,
// There's one and only one global instance of the manager that you can
// retrieve using the following method anywhere in your program.
auto manager = QDmxManager::instance();
manager->init();
// The manager also has methods to get what driver are available and
// what devices within those drivers
qDebug() << "List all drivers:";
for(auto d : manager->availableDrivers())
qDebug() << "- " << d->name();
// Let's say you want to use the art-net driver
// you need to enable it first
auto driver = manager->driver("artnet");
Q_ASSERT(driver);
driver->setEnabled(true);
// now the driver is enabled you can list all available devices
qDebug() << "List all devices for the artnet driver:";
for(auto d : driver->availableDevices())
qDebug() << "- " << d->name();
// The art-net drivers (as all network based driver) creates one device per network interface
// the name the device is the name of said interface.
// Assuming you are on a unix machine, you can query the manager like so:
auto dev = manager->device("artnet", "eth0");
Q_ASSERT(dev); // The methods return nullptr if it can't find the device
// alternatively, you could have query the driver directly like this
dev = driver->device("eth0");
// then you need to patch the different input / output of your device to
// a DMX universe. Let's just patch the first output to the first universe here.
// note: this methods returns true on successful patch
manager->patch(QDmxManager::Output, /* Type of port to patch*/
dev, /* device to patch */
0, /* Port id on the device */
0); /* Universe id */
// let's also patch the first input port
manager->patch(QDmxManager::Input, dev, 0, 0);
// Now that things are patched, we can start playing with DMX
// you can get notification of incoming dmx data by connecting the following
// signal.
// The 2 parameters are the universe id and the raw dmx data as a byte array
QObject::connect(manager, &QDmxManager::inputDataChanged, [](quint8 universe, const QByteArray& dmxData)
{
qDebug() << "Received new data on universe" << universe;
qDebug() << dmxData;
});
// Alternatively you can read the output directly using:
QByteArray inputData = manager->readInputData(0 /* universe */);
// let's do a dirty ramp up from 0 to 255
for(int i = 0; i < 255; i++)
{
manager->writeData(0, /* Universe */
0, /* Channel */
i); /* Value */
// Please note: The channels indexing starts from 0 and ends at 511
// So what usually people call DMX channel 1, is index 0 in this library
}
// The writeData methods also have overloads that takes QByteArray argument
// to modify multiple consicutive value in one call like so:
QByteArray multiple;
multiple.append(10);
multiple.append(20);
multiple.append(30);
multiple.append(40);
// The channels with index 100, 101, 102 and 103 (DMX channel 101, 102, 103 and 104 in the "real" world)
// will be updated with the 4 values in the byte array
manager->writeData(0, 100, multiple);
// If you ever want to know what is currently being send you can also read
// the output buffer:
QByteArray outputData = manager->readOutputData(0 /* universe */);
// Once you're done, before your application shutdown, don't forget to call
// the teardown method
manager->teardown();
}
I hope this helps!
Oh yeah, that helped ! I get the point about early stage of devlopment, no problem.
Amazing, I'll close this ticket now. fell free to contact me / open a new ticket if you have other questions / issues. Also, out of curiosity, what project are you working on that uses DMX? I have a side project of computer / raspberry pi based lighting controller which is not on github yet that will use this library as well as QOsc and QMidi (If you're interested in other related protocols)
Hey, thanks for this code, this lib is perfect for me. Actually I work as a light technician for theater, contemporary dance, etc... I often also work with sound and video. And I use a lot my computer in my job. I wanna write my own controlling lighting software that fits my needs. I use qlcplus, sometimes DLight, but they all have things I don't like. For this software, I do need QMidi, QOsc, etc. For QMidi I use my own QMidi, which is a simple wrapper for rtmidi, which is inspired by QMidi. For Qosc I found this. I will take a look at yours. your libs seem to be written "dans les règles de l'art".
Hi ! when trying to compile on linux with qt6, here's the problem.
make [ 4%] Automatic MOC and UIC for target QDmxLib [ 4%] Built target QDmxLib_autogen [ 8%] Building CXX object src/CMakeFiles/QDmxLib.dir/QDmxLib_autogen/mocs_compilation.cpp.o Dans le fichier inclus depuis /usr/include/qt6/QtNetwork/qnetworkinterface.h:9, depuis /usr/include/qt6/QtNetwork/QNetworkInterface:1, depuis /home/ray/dev/QDmxLib-master/build/src/QDmxLib_autogen/WJQ6EGRBNO/../../../../include/qdmxlib/private/qdmxgenericnetworkdevice.h:4, depuis /home/ray/dev/QDmxLib-master/build/src/QDmxLib_autogen/WJQ6EGRBNO/../../../../include/qdmxlib/private/qartnetdevice.h:4, depuis /home/ray/dev/QDmxLib-master/build/src/QDmxLib_autogen/WJQ6EGRBNO/moc_qartnetdevice.cpp:10, depuis /home/ray/dev/QDmxLib-master/build/src/QDmxLib_autogen/mocs_compilation.cpp:2: /usr/include/qt6/QtCore/qscopedpointer.h: Dans l'instanciation de « static void QScopedPointerDeleter::cleanup(T) [with T = QDmxDriverPrivate] » :
/usr/include/qt6/QtCore/qscopedpointer.h:80:25: requis par « QScopedPointer<T, Cleanup>::~QScopedPointer() [with T = QDmxDriverPrivate; Cleanup = QScopedPointerDeleter] »
/home/ray/dev/QDmxLib-master/build/src/QDmxLib_autogen/WJQ6EGRBNO/../../../../include/qdmxlib/private/qdmxdriver.h:17:5: requis depuis ici
/usr/include/qt6/QtCore/qscopedpointer.h:21:40: erreur: utilisation invalide de « sizeof » sur le type incomplet « QDmxDriverPrivate »
21 | typedef char IsIncompleteType[ sizeof(T) ? 1 : -1 ];
| ^::cleanup(T ) [with T = QDmxDevicePrivate] » :
/usr/include/qt6/QtCore/qscopedpointer.h:80:25: requis par « QScopedPointer<T, Cleanup>::~QScopedPointer() [with T = QDmxDevicePrivate; Cleanup = QScopedPointerDeleter] »
/home/ray/dev/QDmxLib-master/build/src/QDmxLib_autogen/WJQ6EGRBNO/../../../../include/qdmxlib/private/qdmxdevice.h:20:5: requis depuis ici
/usr/include/qt6/QtCore/qscopedpointer.h:21:40: erreur: utilisation invalide de « sizeof » sur le type incomplet « QDmxDevicePrivate »
make[2]: [src/CMakeFiles/QDmxLib.dir/build.make:76 : src/CMakeFiles/QDmxLib.dir/QDmxLib_autogen/mocs_compilation.cpp.o] Erreur 1
make[1]: [CMakeFiles/Makefile2:99 : src/CMakeFiles/QDmxLib.dir/all] Erreur 2
make: *** [Makefile:91 : all] Erreur 2
~~~~ /usr/include/qt6/QtCore/qscopedpointer.h: Dans l'instanciation de « static void QScopedPointerDeleter