Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix line-endings and whitespace issues in bin-folder files #57

Merged
merged 1 commit into from
Jan 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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