nach sehr langem debuggen von node eiscp.js habe ich nun einen weg gefunden die Daten auszufiltern…
on('data', function (data) {
if(first) {
xml = eiscp_packet_extract(data);
first = false;
var result = iscp_to_command(xml);
result.iscp_command = xml;
result.host = config.host;
result.port = config.port;
result.model = config.model;
}
else {
xml = xml + data.toString('ascii', 18); // evtl. data.toString() ?
self.emit('debug', util.format("DEBUG (XML) command %s", xml));
var result = iscp_to_command(xml);
result.iscp_command = xml;
result.host = config.host;
result.port = config.port;
result.model = config.model;
if(xml.indexOf('') != -1) {
self.emit('data', result);
first = true
if (typeof result.command !== 'undefined') {
if (Array.isArray(result.command)) {
result.command.forEach(function (cmd) {
self.emit(cmd, result.argument);
});
} else {
self.emit(result.command, result.argument);
}
}
}
}
if(result.command !== 'receiver-information' | result.command !== 'net-usb-list-info-allitems') {
first = true;
self.emit('debug', util.format("DEBUG (received_data) Received data from %s:%s - %j", config.host, config.port, result));
self.emit('data', result);
// If the command is supported we emit it as well
if (typeof result.command !== 'undefined') {
if (Array.isArray(result.command)) {
result.command.forEach(function (cmd) {
self.emit(cmd, result.argument);
});
} else {
self.emit(result.command, result.argument);
}
}
}
});
da es nur zwei commands gibt, die eine xml als Anwort erhalten sollte das eigendlich funktionionieren.
das ist sicher nicht der eleganteste Weg aber so komme ich auf jedenfall erst einmal weiter… (hoffe) ich