Skip to content

Commit

Permalink
Merge pull request #57 from cjk/fixBinFolderEncodings
Browse files Browse the repository at this point in the history
Fix line-endings and whitespace issues in bin-folder files
  • Loading branch information
andreek authored Jan 4, 2019
2 parents 99cf7bc + 7a2c9a0 commit adde3c5
Show file tree
Hide file tree
Showing 5 changed files with 223 additions and 225 deletions.
122 changes: 61 additions & 61 deletions bin/groupread
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
#!/usr/bin/env node

'use strict';

var eibd = require('../');
/**
* groupread
*/
function groupread(opts, gad, callback) {
var conn = new eibd.Connection();
conn.socketRemote(opts, function(err) {

if(err) {
callback(err);
return;
}

var address = eibd.str2addr(gad);
conn.openTGroup(address, 0, function (err) {
if(err) {
callback(err);
return;
}
var msg = eibd.createMessage('read');
conn.sendAPDU(msg, callback);
});
});
}

var host = process.argv[2];
var port = process.argv[3];
var gad = process.argv[4];

if(!host || !port) {
console.log('Usage:');
console.log('groupread <host> <port> <gad>');
console.log('Sends read request to the knxd listening on <host>:<port> for group address <gad>');
console.log('');
console.log('groupread --socket <path> <gad>');
console.log('Sends read request to the local knxd listening on unix socket <path> for group address <gad>');
console.log('');
console.error('Parameter missing.');
} else if(!gad) {
console.error('[ERROR] No gad given');
} else {
if (host==='--socket') {
var opts = {path:port}; //path is hiding behind port variable from args
} else {
opts = {
host: host,
port: port
};
}
groupread(opts, gad, function(err) {
if(err) {
console.error('[ERROR]'+err);
} else {
console.log('Read request sent.');
}
});
}
#!/usr/bin/env node

'use strict';

var eibd = require('../');
/**
* groupread
*/
function groupread(opts, gad, callback) {
var conn = new eibd.Connection();
conn.socketRemote(opts, function(err) {

if(err) {
callback(err);
return;
}

var address = eibd.str2addr(gad);
conn.openTGroup(address, 0, function (err) {
if(err) {
callback(err);
return;
}
var msg = eibd.createMessage('read');
conn.sendAPDU(msg, callback);
});
});
}

var host = process.argv[2];
var port = process.argv[3];
var gad = process.argv[4];

if(!host || !port) {
console.log('Usage:');
console.log('groupread <host> <port> <gad>');
console.log('Sends read request to the knxd listening on <host>:<port> for group address <gad>');
console.log('');
console.log('groupread --socket <path> <gad>');
console.log('Sends read request to the local knxd listening on unix socket <path> for group address <gad>');
console.log('');
console.error('Parameter missing.');
} else if(!gad) {
console.error('[ERROR] No gad given');
} else {
if (host==='--socket') {
var opts = {path:port}; //path is hiding behind port variable from args
} else {
opts = {
host: host,
port: port
};
}
groupread(opts, gad, function(err) {
if(err) {
console.error('[ERROR]'+err);
} else {
console.log('Read request sent.');
}
});
}
190 changes: 95 additions & 95 deletions bin/groupsend
Original file line number Diff line number Diff line change
@@ -1,95 +1,95 @@
#!/usr/bin/env node

'use strict';

var eibd = require('../');

/**
* groupsend
* Send a KNX telegram with support for read/write/response messages and DPT1, DPT2, DPT3, DPT5, DPT9 data format
* Contains functionality from groupread/groupwrite/groupswrite in one cmd line application
*
* Arguments: host port gad action dpt value
* host = ipadress (Ex. 127.0.0.1 - localhost - host.com)5
* port = portnumber (Ex. 6720)
* gad = groupnumber (Ex. 1/2/34)
* action = eibd action (read , write or response)
* dpt = data point type for write/response (Ex. DPT1, DPT2, DPT3, DPT5, DPT9)
* value = data value for write/response (Ex. true , 23 , 12.23)
*/
function send(opts, gad, action, dpt, value, callback) {
var conn = new eibd.Connection();
conn.socketRemote(opts, function(err) {

if(err) {
callback(err);
return;
}

var address = eibd.str2addr(gad);
conn.openTGroup(address, 0, function (err) {
if(err) {
callback(err);
return;
}
var msg = eibd.createMessage(action, dpt, parseFloat(value));
conn.sendAPDU(msg, callback);

});
});
}

var host = process.argv[2];
var port = process.argv[3];
var gad = process.argv[4];
var action = process.argv[5];
var dpt = process.argv[6];
var value = process.argv[7];


var argumentsError;
if(!host || !port) {
argumentsError = '[ERROR] No hostname and port or --socket and path';
} else if(!gad) {
argumentsError = '[ERROR] No gad given';
} else if(!action || action !== 'response' && action !== 'read' && action !== 'write') {
argumentsError = '[ERROR] Wrong action, should be read, write or response';
console.log(action);
} else if(!dpt && action !== 'read') {
argumentsError = '[ERROR] Response and write action require a DPT value';
} else if (action !== 'read' && dpt.indexOf('DPT1') !== 0 && dpt.indexOf('DPT5') !== 0 && dpt.indexOf('DPT9') !== 0) {
argumentsError = '[ERROR] Wrong DPT, only DPT1, DPT5 and DPT9 are implemented';
} else if(!value && (action === 'response' || action === 'write')) {
argumentsError = '[ERROR] Response and write actions require a value';
}

if(argumentsError) {
console.error('\n' + argumentsError + '\n\n');
console.log('Usage:')
console.log(' groupsend <host> <port> gad action dpt value');
console.log(' groupsend --socket <path> gad action dpt value \n\n');
console.log('host = ipadress (Ex. 127.0.0.1 - localhost - host.com)');
console.log('port = portnumber (Ex. 6720)');
console.log('<path> = alternative UNIX socket (Ex. /run/knx)')
console.log('gad = groupnumber (Ex. 1/2/34)');
console.log('action = eibd action (read , write or response)');
console.log('dpt = data point type (Ex. DPT1, DPT2, DPT3, DPT5, DPT9)');
console.log('value = data value for write/response (Ex. true , 23 , 12.23)');
} else {
if (host==='--socket') {
var opts = {path:port}; //path is hiding behind port variable from args
} else {
opts = {
host: host,
port: port
};
}
send(opts, gad, action, dpt, value, function(err) {
if(err) {
console.error('[ERROR]'+err);
} else {
console.log('Action completed.');
}
});
}
#!/usr/bin/env node

'use strict';

var eibd = require('../');

/**
* groupsend
* Send a KNX telegram with support for read/write/response messages and DPT1, DPT2, DPT3, DPT5, DPT9 data format
* Contains functionality from groupread/groupwrite/groupswrite in one cmd line application
*
* Arguments: host port gad action dpt value
* host = ipadress (Ex. 127.0.0.1 - localhost - host.com)5
* port = portnumber (Ex. 6720)
* gad = groupnumber (Ex. 1/2/34)
* action = eibd action (read , write or response)
* dpt = data point type for write/response (Ex. DPT1, DPT2, DPT3, DPT5, DPT9)
* value = data value for write/response (Ex. true , 23 , 12.23)
*/
function send(opts, gad, action, dpt, value, callback) {
var conn = new eibd.Connection();
conn.socketRemote(opts, function(err) {

if(err) {
callback(err);
return;
}

var address = eibd.str2addr(gad);
conn.openTGroup(address, 0, function (err) {
if(err) {
callback(err);
return;
}

var msg = eibd.createMessage(action, dpt, parseFloat(value));
conn.sendAPDU(msg, callback);

});
});
}

var host = process.argv[2];
var port = process.argv[3];
var gad = process.argv[4];
var action = process.argv[5];
var dpt = process.argv[6];
var value = process.argv[7];


var argumentsError;
if(!host || !port) {
argumentsError = '[ERROR] No hostname and port or --socket and path';
} else if(!gad) {
argumentsError = '[ERROR] No gad given';
} else if(!action || action !== 'response' && action !== 'read' && action !== 'write') {
argumentsError = '[ERROR] Wrong action, should be read, write or response';
console.log(action);
} else if(!dpt && action !== 'read') {
argumentsError = '[ERROR] Response and write action require a DPT value';
} else if (action !== 'read' && dpt.indexOf('DPT1') !== 0 && dpt.indexOf('DPT5') !== 0 && dpt.indexOf('DPT9') !== 0) {
argumentsError = '[ERROR] Wrong DPT, only DPT1, DPT5 and DPT9 are implemented';
} else if(!value && (action === 'response' || action === 'write')) {
argumentsError = '[ERROR] Response and write actions require a value';
}

if(argumentsError) {
console.error('\n' + argumentsError + '\n\n');
console.log('Usage:')
console.log(' groupsend <host> <port> gad action dpt value');
console.log(' groupsend --socket <path> gad action dpt value \n\n');
console.log('host = ipadress (Ex. 127.0.0.1 - localhost - host.com)');
console.log('port = portnumber (Ex. 6720)');
console.log('<path> = alternative UNIX socket (Ex. /run/knx)')
console.log('gad = groupnumber (Ex. 1/2/34)');
console.log('action = eibd action (read , write or response)');
console.log('dpt = data point type (Ex. DPT1, DPT2, DPT3, DPT5, DPT9)');
console.log('value = data value for write/response (Ex. true , 23 , 12.23)');
} else {
if (host==='--socket') {
var opts = {path:port}; //path is hiding behind port variable from args
} else {
opts = {
host: host,
port: port
};
}
send(opts, gad, action, dpt, value, function(err) {
if(err) {
console.error('[ERROR]'+err);
} else {
console.log('Action completed.');
}
});
}
2 changes: 1 addition & 1 deletion bin/groupsocketlisten
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ if(!host || !port) {
} else {
console.error('[ERROR] '+err);
}

});
}
8 changes: 3 additions & 5 deletions bin/groupswrite
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ if(!host || !port) {
if (host==='--socket') {
var opts = {path:port}; //path is hiding behind port variable from args
} else {
opts = {
host: host,
port: port
opts = {
host: host,
port: port
};
}
groupswrite(opts, gad, value, function(err) {
Expand All @@ -60,5 +60,3 @@ if(!host || !port) {
}
});
}


Loading

0 comments on commit adde3c5

Please sign in to comment.