naychrist / ofxLibArtnet

OF wrapper for libartnet
13 stars 6 forks source link

Need help to send data #2

Closed martialgallorini closed 11 years ago

martialgallorini commented 11 years ago

Hi,

Thanks a lot for this addon. I try to use it but i must make some mistake somewhere. I have read artnet specs but i can't find out how to use the addon to send artnet commands. Well yes i do understand how to use it : i installed it and included the addon, everything compiled... but nothing works !

I think i don't understand how to build the data packet and what its format looks like. can you just tell me and give an exemple of the format of data you send with libArtnet ?

for example i would like to send the value 255 to a fader of a GrandMA. IP is 2.168.5.23. The fader is on the DMX address 1 of subnet 16 universe 3.

I tried a lot of things but i can't make it work...

Thanks

naychrist commented 11 years ago

hi there. best thing to do is start with the included sample.

By default this addon creates one universe when setup (universe 0). When you add more universes their numbers grow incrementally. In this case you need to setup the addon to use 4 universes to access universe 3. Then you call updateByIndex and tell it to update the universe at index 3 and it should send the data to the universe you are working with. The sample data sends the same value from 0-255 to all 512 addresses of the universe based on where the mouse cursor is.

This should work but I think the data you would be after is something like: unsigned char * data = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255 }; node.updateDataAtIndex(3,data,17);

Note that I have made some updates that make adding/selecting universes cleaner to my cinder version of this addon on my github account but have not had a chance to move the changes over yet.

The IP address you setup the addon to work with needs to be the IP address of your computer that has access to the artnet hardware e.g. 2.168.5.1 (I assume you can ping the hardware from your machine?)

martialgallorini commented 11 years ago

Hey,

Thanks a lot for your answer, this really helps !

Some more questions :

naychrist commented 11 years ago

not sure what you mean by 'manage subnet'.

you will need to call send after updating data - this will only send data updated since last send.

martialgallorini commented 11 years ago

Artnet protocol specifies you can address 16 subnet of 16 universes each. A net is a group of 16 consecutive subnets or 256 universes. A subnet is a group of 16 consecutive universes. So choosing an address to send a command consists in choosing a Port-Address = one of the 32,768 possible addresses to which a DMX frame can be directed. The Port-Address is a 15 bit number composed of Net+Sub-Net+Universe

In the GrandMA you can make triggers that "listen" for values. You can address these triggers by setting its subnet+universe like this (in hexadecimal) : "F:3" is Subnet 16 universe 3

But i can't see how to choose the subnet in your library so i assume you are working only on subnet 0 ?

martialgallorini commented 11 years ago

Here is what i did :

in testApp.h : ofxLibArtnet::Node anNode; int universe; unsigned char dmxData[512];

testApp.cpp :

in setup() : anNode.addUniverses(4); anNode.setup("127.0.0.1",true); universe = 3;

when i click a button : dmxData[universe] = 2; anNode.updateDataByIndex(universe, dmxData, 512); anNode.send();

it compiles but when executed i get : Program received signal: “EXC_BAD_ACCESS”. sharedlibrary apply-load-rules all

naychrist commented 11 years ago

Can't speak to the subnet config as I have never used it. But this won't work if you connect to local host. You will need to set up your machine with an IP address on the 2.x range and use this.

Note that in this case dmxData is the entire data for universe 3. It looks like you are creating an array without initialising the values, and then setting the value for address 3 within this array to 2. This is then being sent to universe 3. Not sure if that is what you're after.

martialgallorini commented 11 years ago

Standard address are 10.x.x.x or 2.x.x.x for artnet but you should be able to specify any address you want. i have already did it. But anyway it is not a problem for me here.

Ok i understand so i added an init to dmxData : for (int i=0; i<512; i++) dmxData[i] = 0;

But problem still exists.

i must be missing something... What i want is to set the value 255 to address 1 of universe 3.

Also the question is : if i init whole dmxData to 0, updating with updateDataByIndex() and then send() will send all these values (which i don't want) ?

naychrist commented 11 years ago

not sure where your runtime memory access is happening - does the sample compile and run? did you add the pre-processor macro as per the readme file?

the way this addon works it will always send all values from the first address up to the length of the array - should be fine if the array is less than 512 though. I wrote this for applications where pixels are mapped directly to lights and refreshed each frame.

martialgallorini commented 11 years ago

Yes the example compile and run. I must admit i added the preprocessor macro but it ended with a lot of errors : it acted like the compiler didn't find the other libraries and addons anymore.

martialgallorini commented 11 years ago

besides, i have the message in console : "cannot connect to ip 2.168.14.52"

I gave a try to MaxMSP by creating a simple patch and i can control the fader seemlessly. so the connection is ok.

I join the picture of the patch if it helps

artnet_maxpatch

naychrist commented 11 years ago

You need to be able to compile with the macro for the IP to be found and connected to. If this creates linker problems then something is likely not included properly. Sample should be fine but please note the last version of OF this was tested with is 072.

Just to clarify, the machine you are compiling on has the ip 2.168.14.52 and you are talking to hardware at 2.168.14.23? The machine you are compiling on can ping both of these IPs?

martialgallorini commented 11 years ago

ok, i will try to find a way out and compile under oF 0.72

machine with ip 2.168.14.52 is the node i am talking to (GrandMA). Mine is 2.22.22.22. I don't know the ip 2.168.14.23

naychrist commented 11 years ago

then you want to use the IP "2.22.22.22" when setting up the library.

martialgallorini commented 11 years ago

oh i see ! my bad. So i should set ip address of my computer in the library and set it as a Node (not server) in Output mode ?

When you talk about Port, you talk about Artnet port not UDP port which is fixed to 6454 right ?

So where / when do i specify the IP address of the device i want to communicate with ?

In setup() what does subnet_addr stands for ? i ask you that because i see very different words for naming the same thing so i want to be sure. Some name Subnet the duet Subnet+Universe. Is that the case here ? What is the format of this address ? if i need to reach Subnet 16 Universe 13 is the subnet_adr = 0xFD right ?

thanks a lot for your answers

naychrist commented 11 years ago

yes you want to call the addons setup method with your machine's IP - you do not need to specify the IP of the device, if the universes match up it will find it.

if you want to delve into the code inside the addon I'd suggest looking into the LibArtnet library it wraps. This is being maintained by the OLA community. The link that got me started is in the readme file: http://www.opendmx.net/index.php/IPad_ArtNet_Node

I'm offline for a few days so good luck!

martialgallorini commented 11 years ago

Hi,

Thanks for all the help you provided. I managed to make another artnet addon to work, but i am unable to use yours. Whatever i try, it says it cannot connect to node. Could it be the version of LibArtnet ?

I use oF 0.7.4 under macOSX Snow Leopard.

I will try again and fix it if needed and i come back to you.

thanks a lot anyway

naychrist commented 11 years ago

glad you have something working

that version libartnet is working here with OF 072 and latest cinder on OSX 10.8.3. Should be fine. Will update the sample for OF 074 when I get a chance. cheers.