NEWS
Script verursacht Fehlfunktionen
-
Ich habe ein Script welches Nachrichten über die serielle Schnittstelle an ein Funkkmodul sendet. Leider bekomme ich eine Fehlermeldung(nur ein kleines Dreieck an der seite wo Steht "too many errors"). Im log bekomme ich keine Meldungen. Das script funktioniert auch , jedoch andere Scripte nciht mehr. Kann mir jemand helfen?
Die Fehlermeldung steht in der bright Funtion beim break von case 1
! ````
var logging= false;
var SerialPort = require("serialport");
var messageon="",messageoff=""; //save selected Zone! var port = new SerialPort("/dev/ttyS0", {
baudRate: 9600,
xon: true,
xoff: true,
//flowControl: false
//parser: SerialPort.parsers.byteDelimiter([2,4])
platformOptions: {vmin: 0, vtime: 10, hupcl: false}
},
! function test(err) {
if (err) {
return console.log('Error: ', err.message);
}
});
! subscribe({id:"milight.0.Zone1.bright", change:"ne"}, function (obj) {
var dim = obj.newState.val;
var dimold = obj.oldState.val;
var dim_val=Math.round((dim-dimold)/10) ;if (dim === 0){ valup(-13,true,1,true);! if(logging)log("Milight: Zone 1 aus");
}if (obj.newState.val !== 0 ){ if(obj.newState.val === 100){ valup(13,false,1,true); } else{ valup(dim_val,false,1,true); } log("Milight: Zone "+ dim + "% geändert um "+ dim_val); }});
! subscribe({id:"milight.0.Zone2.bright", change:"ne"}, function (obj) {
var dim = obj.newState.val;
var dimold = obj.oldState.val;
var dim_val=Math.round((dim-dimold)/10) ;if (dim === 0){ valup(-13,true,2,true);! if(logging)log("Milight: Zone 3 aus");
}if (obj.newState.val !== 0 ){ if(obj.newState.val === 100){ valup(13,false,2,true); } else{ valup(dim_val,false,2,true); } log("Milight: Zone "+ dim + "% geändert um "+ dim_val); }});
subscribe({id:"milight.0.Zone3.bright", change:"ne"}, function (obj) {
var dim = obj.newState.val;
var dimold = obj.oldState.val;
var dim_val=Math.round((dim-dimold)/10) ;if (dim === 0){ valup(-13,true,3,true);! if(logging)log("Milight: Zone 3 aus");
}if (obj.newState.val !== 0 ){ if(obj.newState.val === 100){ valup(13,false,3,true); } else{ valup(dim_val,false,3,true); } log("Milight: Zone "+ dim + "% geändert um "+ dim_val); }});
subscribe({id:"milight.0.Zone4.bright", change:"ne"}, function (obj) {
var dim = obj.newState.val;
var dimold = obj.oldState.val;
var dim_val=Math.round((dim-dimold)/10) ;if (dim === 0){ valup(-13,true,4,true);! if(logging)log("Milight: Zone 4 aus");
}if (obj.newState.val !== 0 ){ if(obj.newState.val === 100){ valup(13,false,4,true); } else{ valup(dim_val,false,4,true); } log("Milight: Zone "+ dim + "% geändert um "+ dim_val); }});
subscribe({id:"milight.0.Zone1.white"/Farb Tepmperatur/, change:"ne"}, function (obj) {
var dim = obj.newState.val;
var dimold = obj.oldState.val;
var dim_val=Math.round((dim-dimold)/10) ;if (dim === 0){ bright(-13,1,true);! if(logging)log("Milight: Zone1 aus");
}if (obj.newState.val !== 0 ){ if(obj.newState.val === 100){ bright(13,1,true); } else{ bright(dim_val,1,true); } log("Milight: Zone "+ dim + "% geändert um "+ dim_val); }});
subscribe({id:"milight.0.Zone2.white"/Farb Tepmperatur/, change:"ne"}, function (obj) {
var dim = obj.newState.val;
var dimold = obj.oldState.val;
var dim_val=Math.round((dim-dimold)/10) ;if (dim === 0){ bright(-13,2,true);! if(logging)log("Milight: Zone2 aus");
}if (obj.newState.val !== 0 ){ if(obj.newState.val === 100){ bright(13,2,true); } else{ bright(dim_val,2,true); } log("Milight: Zone "+ dim + "% geändert um "+ dim_val); }});
! subscribe({id:"milight.0.Zone3.white"/Farb Tepmperatur/, change:"ne"}, function (obj) {
var dim = obj.newState.val;
var dimold = obj.oldState.val;
var dim_val=Math.round((dim-dimold)/10) ;if (dim === 0){ bright(-13,3,true);! if(logging)log("Milight: Zone3 aus");
}if (obj.newState.val !== 0 ){ if(obj.newState.val === 100){ bright(13,3,true); } else{ bright(dim_val,3,true); } log("Milight: Zone "+ dim + "% geändert um "+ dim_val); }});
subscribe({id:"milight.0.Zone4.white"/Farb Tepmperatur/, change:"ne"}, function (obj) {
var dim = obj.newState.val;
var dimold = obj.oldState.val;
var dim_val=Math.round((dim-dimold)/10) ;if (dim === 0){ bright(-13,4,true);! if(logging)log("Milight: Zone4 aus");
}if (obj.newState.val !== 0 ){ if(obj.newState.val === 100){ bright(13,4,true); } else{ bright(dim_val,4,true); } log("Milight: Zone "+ dim + "% geändert um "+ dim_val); }});
! port.on('data', function (data) {
console.log('Data: ' + data.toString('hex'));
});
! port.on('open', function() {
console.log('Connected');
});
! port.on('error', function(err) {
console.log('Error: ', err.message);
});
! // close port if the script stopped (to be able to open it again)
onStop(function (callback) {
if (port && port.isOpen()) {
port.close();
console.log('port closed');
}
callback();
});
! function serialsend(text){// Flush input port.flush(); port.write(text, function(err) { if (err) { return console.log('Error on write: ', err.message); } });}
! var valup = function(i,off,zone,flag) {
if(flag){ switch (zone) { case 0: messageon="\x35\x00\x55"; messageoff="\x39\x00\x55"; if(logging)console.log('Milight: Alle Bulbs ausgewählt'); break; case 1: messageon="\x38\x00\x55"; messageoff="\x3b\x00\x55"; if(logging)console.log('Milight: Alle Zone 1 ausgewählt'); break; case 2: messageon="\x3d\x00\x55"; messageoff="\x33\x00\x55"; if(logging)console.log('Milight: Alle Zone 2 ausgewählt'); break; case 3: messageon="\x37\x00\x55"; messageoff="\x3a\x00\x55"; if(logging)console.log('Milight: Alle Zone 3 ausgewählt'); break; case 4: messageon="\x32\x00\x55"; messageoff="\x36\x00\x55"; if(logging)console.log('Milight: Alle Zone 4 ausgewählt'); break; default: console.log('milight: Kiene Bulb ausgewählt'); } serialsend(messageon); setTimeout(function() { valup(i,off,zone,false) }, 200); } else{ i = i || 0; if(i > 0 && (11-i) < 11){ serialsend("\x3c\x00\x55"); if(logging)log(i+ " Durchlauf"); i--; setTimeout(function() { valup(i,off,zone,false) }, 200); } else if(i < 0 && (11+i) < 11){ serialsend("\x34\x00\x55"); if(logging)log(i+ " Durchlauf"); i++; setTimeout(function() { valup(i,off,zone,false) }, 200); } if(i===0 && off){ serialsend(messageoff); } }! };
! var bright = function(j,zone1,flag1) {
if(flag1){
switch (zone1) {
case 0:
messageon="\x35\x00\x55";
messageoff="\x39\x00\x55";
//if(logging)console.log('Milight: Alle Bulbs ausgewählt');
break;
case 1:
messageon="\x38\x00\x55";
messageoff="\x3b\x00\x55";
//if(logging)console.log('Milight: Alle Zone 1 ausgewählt');
break;
case 2:
messageon="\x3d\x00\x55";
messageoff="\x33\x00\x55";
if(logging)console.log('Milight: Alle Zone 2 ausgewählt');
break;
case 3:
messageon="\x37\x00\x55";
messageoff="\x3a\x00\x55";
if(logging)console.log('Milight: Alle Zone 3 ausgewählt');
break;
case 4:
messageon="\x32\x00\x55";
messageoff="\x36\x00\x55";
if(logging)console.log('Milight: Alle Zone 4 ausgewählt');
break;
default:
console.log('milight: Kiene Bulb ausgewählt');
}
serialsend(messageon);
setTimeout(function() { bright(j,zone1,false) }, 200);
}
else{
j = j || 0;if(j > 0 && (11-j) < 11){ serialsend("\x3e\x00\x55"); if(logging)log(j+ " Durchlauf"); j--; setTimeout(function() { bright(j,zone1,false) }, 200); } else if(j < 0 && (11+j) < 11){ serialsend("\x3f\x00\x55"); if(logging)log(j+ " Durchlauf"); j++; setTimeout(function() { bright(j,zone1,false) }, 200); } }};
! ````
Hey! Du scheinst an dieser Unterhaltung interessiert zu sein, hast aber noch kein Konto.
Hast du es satt, bei jedem Besuch durch die gleichen Beiträge zu scrollen? Wenn du dich für ein Konto anmeldest, kommst du immer genau dorthin zurück, wo du zuvor warst, und kannst dich über neue Antworten benachrichtigen lassen (entweder per E-Mail oder Push-Benachrichtigung). Du kannst auch Lesezeichen speichern und Beiträge positiv bewerten, um anderen Community-Mitgliedern deine Wertschätzung zu zeigen.
Mit deinem Input könnte dieser Beitrag noch besser werden 💗
Registrieren Anmelden