To unsubscribe from this group, send email to open-lighting+unsubscribe@googlegroups.com
# By default this script does nothing.# Print the IP address_IP=$(hostname -I) || trueif [ "$_IP" ]; thenprintf "My IP address is %s\n" "$_IP"fi#For OLAD delayecho 'Sleep 15 seconds before starting olad'sleep 15echo 'Starting olad'sudo -u pi olad -f --no-http-quit --syslog#Start OPC-Server after OLAD... it works!sudo node /home/pi/opctest/node_modules/node-opc-server/opc-server/index.jsexit 0
Wants=
,
Requires=
, Before=
, After=
keywords..I would check that "ws281x.render(pixelsUint32);" is only used once and on the last server. This means the whole setup will only updat if that server is triggered.
Putting this on say server 2 and 4 will mean the system will render the first two universes and leave the last two blank... it's not particularly nice and rather hacky but that's the best way I've seen this work.
Let me know if this helps,
Edd
I'm away from my laptop, can grab the files tomorrow. From what you discribe it sounds like it can be caused by something in index:I would check that "ws281x.render(pixelsUint32);" is only used once and on the last server. This means the whole setup will only updat if that server is triggered.
Putting this on say server 2 and 4 will mean the system will render the first two universes and leave the last two blank... it's not particularly nice and rather hacky but that's the best way I've seen this work.
Let me know if this helps,
Edd
1) As for the rest of the questions. I will try tcpdump as soon as I found how to do this (will need to google a bit).
var server = net.createServer(function(c) { //'connection' listener
var parseState = 0;
console.log('client connected');
c.on('end', function() {
console.log('client disconnected');
});
c.on('data', function(data) {
opcparse.parseOPC(data, function(rgb, count) {
//console.log('rgb count', count);
for (var i = 0; i < count; i+=3) {
pixelsUint32[i/3] = rgb2int(rgb[i],rgb[i+1],rgb[i+2]);
}
console.log('server 1 data');
//ws281x.render(pixelsUint32);
});
});
});
var server2 = net.createServer(function(c) { //'connection' listener
var parseState = 0;
console.log('client2 connected');
c.on('end', function() {
console.log('client2 disconnected');
});
c.on('data', function(data) {
opcparse.parseOPC(data, function(rgb, count) {
for (var i = 0; i < count; i+=3) {
pixelsUint32[170 + i/3] = rgb2int(rgb[i],rgb[i+1],rgb[i+2]);
}
console.log('server 2_ data');
//ws281x.render(pixelsUint32);
});
});
});
var server3 = net.createServer(function(c) { //'connection' listener
console.log('client3 connected');
c.on('end', function() {
console.log('client3 disconnected');
});
c.on('data', function(data) {
opcparse.parseOPC(data, function(rgb, count) {
for (var i = 0; i < count; i+=3) {
pixelsUint32[340 + i/3] = rgb2int(rgb[i],rgb[i+1],rgb[i+2]);
}
console.log('server 3__ data', count);
ws281x.render(pixelsUint32);
});
});
});
server.listen(7890, function() { //'listening' listener
console.log('server bound');
});
server2.listen(7891, function() { //'listening' listener
console.log('server2 bound');
});
server3.listen(7892, function() { //'listening' listener
console.log('server3 bound');
});
enabled = true
target = 127.0.0.1:7890
target_127.0.0.1:7890_channel = 0
target = 127.0.0.1:7891
target_127.0.0.1:7891_channel = 0
target = 127.0.0.1:7892
target_127.0.0.1:7892_channel = 0
target = 127.0.0.1:7893
target_127.0.0.1:7893_channel = 0
/* jslint node: true */
'use strict';
var ws281x = require('rpi-ws281x-native');
var NUM_LEDS = parseInt(process.argv[2], 600) || 600;
var pixelsUint32 = new Uint32Array(NUM_LEDS);
ws281x.init(NUM_LEDS);
var GAMMA_CORRECT = true;
// ---- trap the SIGINT and reset before exit
process.on('SIGINT', function () {
ws281x.reset();
process.nextTick(function () { process.exit(0); });
});
var opcparse = require('../opcparse.js');
var net = require('net');
var server1 = net.createServer(function(c) { //'connection' listener
var parseState = 0;
console.log('client1 connected');
c.on('end', function() {
console.log('client1 disconnected');
});
c.on('data', function(data) {
opcparse.parseOPC(data, function(rgb, count) {
//console.log('rgb count', count);
for (var i = 0; i < count; i+=3) {
pixelsUint32[i/3] = rgb2int(rgb[i],rgb[i+1],rgb[i+2]);
}
// ws281x.render(pixelsUint32);
});
});
});
var server2 = net.createServer(function(c) { //'connection' listener
var parseState = 0;
console.log('client2 connected');
c.on('end', function() {
console.log('client2 disconnected');
});
c.on('data', function(data) {
opcparse.parseOPC(data, function(rgb, count) {
//console.log('rgb count', count);
for (var i = 0; i < count; i+=3) {
pixelsUint32[170 + (i/3)] = rgb2int(rgb[i],rgb[i+1],rgb[i+2]);
}
//ws281x.render(pixelsUint32);
});
});
});
var server3 = net.createServer(function(c) { //'connection' listener
var parseState = 0;
console.log('client3 connected');
c.on('end', function() {
console.log('client3 disconnected');
});
c.on('data', function(data) {
opcparse.parseOPC(data, function(rgb, count) {
//console.log('rgb count', count);
for (var i = 0; i < count; i+=3) {
pixelsUint32[340 + (i/3)] = rgb2int(rgb[i],rgb[i+1],rgb[i+2]);
}
//ws281x.render(pixelsUint32);
});
});
});
var server4 = net.createServer(function(c) { //'connection' listener
var parseState = 0;
console.log('client4 connected');
c.on('end', function() {
console.log('client4 disconnected');
});
c.on('data', function(data) {
opcparse.parseOPC(data, function(rgb, count) {
//console.log('rgb count', count);
for (var i = 0; i < count; i+=3) {
pixelsUint32[510 + (i/3)] = rgb2int(rgb[i],rgb[i+1],rgb[i+2]);
}
ws281x.render(pixelsUint32);
});
});
});
server1.listen(7890, function() { //'listening' listener
console.log('server1 bound');
});
server2.listen(7891, function() { //'listening' listener
console.log('server2 bound');
});
server3.listen(7892, function() { //'listening' listener
console.log('server3 bound');
});
server4.listen(7893, function() { //'listening' listener
console.log('server4 bound');
});
// gamma = 2.2
var GammaLUT=new Uint8Array([0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,8,8,8,9,9,9,10,10,10,11,11,11,12,12,13,13,14,14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,22,22,23,23,24,24,25,26,26,27,28,28,29,30,30,31,32,32,33,34,34,35,36,37,37,38,39,40,41,41,42,43,44,45,46,46,47,48,49,50,51,52,53,54,55,56,56,57,58,59,60,61,62,63,64,66,67,68,69,70,71,72,73,74,75,76,78,79,80,81,82,83,85,86,87,88,89,91,92,93,94,96,97,98,100,101,102,104,105,106,108,109,110,112,113,115,116,118,119,120,122,123,125,126,128,129,131,132,134,136,137,139,140,142,143,145,147,148,150,152,153,155,157,158,160,162,163,165,167,169,170,172,174,176,177,179,181,183,185,187,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,245,247,249,251,253,255]);
function rgb2int(r, g, b) {
if (GAMMA_CORRECT) {
return (GammaLUT[r & 0xff] << 16) | (GammaLUT[g & 0xff] << 8) | (GammaLUT[b & 0xff]);
}
else {
return ((r & 0xff) << 16) | ((g & 0xff) << 8) | ((b & 0xff));
}
}
what happens if you set your channel to zero on each client in OLA and just keep the port different. That's rather a stab in the dark though.
/* jslint node: true */
'use strict';
var ws281x = require('rpi-ws281x-native');
var NUM_LEDS = parseInt(process.argv[2]) || 100;
var pixelsUint32 = new Uint32Array(NUM_LEDS);
console.log('NUM_LEDS: ');
console.log(NUM_LEDS);
var ledsInUniverse = parseInt(process.argv[3]) || 170;
var universeCount = parseInt(process.argv[4]) || 1;
ws281x.init(NUM_LEDS);
var GAMMA_CORRECT = true;
// ---- trap the SIGINT and reset before exit
process.on('SIGINT', function () {
ws281x.reset();
process.nextTick(function () { process.exit(0); });
});
var opcparse = require('../opcparse.js');
var net = require('net');
function LEDServer(ledCount, serverIndex) {
this.ledCount = ledCount;
this.serverIndex = serverIndex;
this.srvFunction = function(c) { //'connection' listener
console.log('client%d connected', serverIndex);
c.on('end', function() {
console.log('client%d disconnected', serverIndex);
});
c.on('data', function(data) {
opcparse.parseOPC(data, function(rgb, count) {
for (var i = 0; i < count; i+=3) {
pixelsUint32[ledCount*serverIndex + i/3] = rgb2int(rgb[i],rgb[i+1],rgb[i+2]);
}
if (serverIndex == (universeCount - 1)) ws281x.render(pixelsUint32);
});
});
};
}
var ledservers = new Array(universeCount);
var servers = new Array(universeCount);
for (var i = 0; i < universeCount; i++){
ledservers[i] = new LEDServer(ledsInUniverse,i);
servers[i] = net.createServer(ledservers[i].srvFunction.bind(ledservers[i]));
}
for (var i = 0; i < universeCount; i++){
servers[i].listen(7890 + i, function() { //'listening' listener
console.log('server%d bound', i);
});
}
// gamma = 2.2
var GammaLUT=new Uint8Array([0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,8,8,8,9,9,9,10,10,10,11,11,11,12,12,13,13,14,14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,22,22,23,23,24,24,25,26,26,27,28,28,29,30,30,31,32,32,33,34,34,35,36,37,37,38,39,40,41,41,42,43,44,45,46,46,47,48,49,50,51,52,53,54,55,56,56,57,58,59,60,61,62,63,64,66,67,68,69,70,71,72,73,74,75,76,78,79,80,81,82,83,85,86,87,88,89,91,92,93,94,96,97,98,100,101,102,104,105,106,108,109,110,112,113,115,116,118,119,120,122,123,125,126,128,129,131,132,134,136,137,139,140,142,143,145,147,148,150,152,153,155,157,158,160,162,163,165,167,169,170,172,174,176,177,179,181,183,185,187,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,245,247,249,251,253,255]);
function rgb2int(r, g, b) {
if (GAMMA_CORRECT) {
return (GammaLUT[r & 0xff] << 16) | (GammaLUT[g & 0xff] << 8) | (GammaLUT[b & 0xff]);
}
else {
return ((r & 0xff) << 16) | ((g & 0xff) << 8) | ((b & 0xff));
}
}
I give up...
Hello Peter!
Sorry for the delay, but I had some trouble with my LAN.
After fixing that, everything is normal now. I think I had a bad setup, so sometimes there was simply no connection possible using my LAN.
No everything works as expected!
Sorry for wasting your time!
Wolfgang
--
Hello Peter!
Sorry for the delay. The reason for the delay AND the troble with OLA was a malfunction of my LAN.
Everything is well now!
Sorry for wasting your time!
Wolfgang
--
To unsubscribe from this group, send email to open-lighting+unsubscribe@googlegroups.com