artnet icon indicating copy to clipboard operation
artnet copied to clipboard

In a big for() loop, never sending data

Open hgshoggins opened this issue 2 years ago • 0 comments

I'm calling artnet.set() in a big (and nested in another for()) loop, and I can't see data output to the network (I'm using tcpdump to check), however a simple call effectively transmits data. I know we're not here to debug my own code, but could this be an sync/async issue, having the set() method being called when we're already outside the loop? It looks to me that ArtNet is rather sequential and that async calls are not very suitable, so I'm simply wondering if using NodeJS for this is relevant, and if I should simply try to stick to a more primitive and sequential language.

Anyway, trying to figure out the logic behind some simple code like this without being able to output data to an ArtNet node:

for(let i = 0; i <= maxval1; i++) {
        // computing some numbers
        for(let j = 0; j <= maxval2; j++){
                /* computing some other numbers
                   to make them available for outputting
                   in an array */
        }
        artnet.set(0, 1, data_array, function (err, res) {
                console.log("never reaching this point");
        });

}
artnet.close();

Should I ensure that something is correctly done before calling set()?

hgshoggins avatar Apr 20 '22 16:04 hgshoggins