-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from cjk/fixBinFolderEncodings
Fix line-endings and whitespace issues in bin-folder files
- Loading branch information
Showing
5 changed files
with
223 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.'); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.'); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,6 @@ if(!host || !port) { | |
} else { | ||
console.error('[ERROR] '+err); | ||
} | ||
|
||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.