wallcontrol10-protocol
v1.0.0
Published
Encode and decode Datapath WallControl 10 command line interface.
Downloads
4
Maintainers
Readme
Introduction
wallcontrol10-protocol is Node module. The main purpose of it is to decode Datapath WallControl 10 responses.
Main features
- no external dependencies
- regardless of connection type (tcp/serial)
- decode and encode functions
- no flow control
- helper constans for connection
- easy extensible
Usage
const WC10 = require('wallcontrol10-protocol');
let socket = net.createConnection(23, '192.168.4.111', () => {
let enc = WC10.encode('wcmd -wall=Blueprint -lauoyts');
console.log('>', enc)
socket.write(enc.encoded);
})
socket.on('data', data => {
console.log('<', WC10.decode(data));
})
/* Expected output
> {
command: 'wcmd -wall=Blueprint -layouts',
encodedStr: 'wcmd -wall=Blueprint -layouts -echo\n',
encoded: <Buffer 77 63 6d 64 20 2d 77 61 6c 6c 3d 42 6c 75 65 70 72 69 6e 74 20 2d 6c 61 79 6f 75 74 73 20 2d 65 63 68 6f 0a>,
duration: 1400
}
< {
raw: <Buffer 20 3d 77 63 6d 64 20 2d 77 61 6c 6c 3d 42 6c 75 65 70 72 69 6e 74 20 2d 6c 61 79 6f 75 74 73 20 2d 65 63 68 6f 0d 0a 45 78 69 74 43 6f 64 65 3a 30 0d ... 65 more bytes>,
rawStr: ' =wcmd -wall=Blueprint -layouts -echo\r\n' +
'ExitCode:0\r\n' +
'Int-vis5\r\n' +
'Vis4-5\r\n' +
'Onet WP\r\n' +
'Layout1\r\n' +
'trzy\r\n' +
'clear\r\n' +
'All sources\r\n' +
'\r\n',
status: 'OK',
req: 'layouts',
value: [
'Int-vis5',
'Vis4-5',
'Onet WP',
'Layout1',
'trzy',
'clear',
'All sources'
],
extra: { exitCode: 0, exitMsg: 'Success', wall: 'Blueprint ' },
params: [ { name: 'wall', value: 'Blueprint ' } ]
}
*/Commands
Wallcontrol10 protocol uses a set of ASCII based commands. They are rather simple and easy to understand.
They are described in WallControl 10 Client help/Tools/Command Line Interface. You must use them yourself.
Commonly used and most useful commands are:wcmd -wallstate[=wall_name] - Get info about of all/specific wall.wcmd [-wall=wall_name] -layouts - Get layout names for wall.wcmd [-wall=wall_name] -layout=layout_name - Apply layout for a wall.wcmd [-wall=wall_name] -layout - Get current layout name for a wall.wcmd [-wall=wall_name] -inputs - Get info about sources.wcmd [-wall=wall_name] -openwindows - Get list of opened windows with their properties.
WARNING: WallControl 10 server uses ASCII encoding. Do not use non-ASCII characters in layouts, input aliases, favouritrs or wall names. For names containing spaces use ""
encode(cmd) function
This function does not do any special processing. It simply appends -echo\n to the end of cmd. This helps in analyzing the responses.
cmd <string>- required. A native WallControl 10 command. Return value iscmdObj <Object>. The most important property isencodedwhich contains encoded command as Buffer. This buffer must be send to wall server. Other properties are helper ones.
decode(data) function
Decodes response from WallControl 10 server
data <Buffer|string>- data read from TCP socket or serial port
Returns response <Object> - an response object containing properties:
raw <Buffer>- same as datarawStr <string>- raw as stringexitCode <number>- response exit code from server.req <string>- a command name (request). Used to identify a response. Seecommandsarrayvalue <string|[string]|Object|[Object]>- decoded value. Return type depends on commandextra <Object>- other values which may be useful
The function does not control completeness of response data. It verifies if data is a valid response and tries to decode it. If data is not a valid response, a simple error object is returned.
