adder-kvm-secure
v1.0.0
Published
Node module to control Adder secure KVM switch and flexi-switch using RS-232 serial connection
Downloads
4
Readme
Introduction
adder-kvm-secure
is module to control Adder secure KVM switch and flexi-switch using RS-232 interface. Supportet models are ADDER Secure KVM Switch(AVS 2114, 2214, 4114, 4214) and ADDER Secure Flexi-Switch(AVS 4128). It is NOT suitable for other Adder KVM switches.
Main features
- human friendly commands,
- responses decoded to JS objects
- command queuing and timing management
- events driven
Usage
const AdderKVM = require('adder-kvm-secure');
let dev = new AdderKVM({path: 'com3'});
dev.emitter.on('responseFromDevice', resp => console.log(resp));
dev.process('switch 2');
/* expected response
{
dev: 'AdderKVM',
raw: <Buffer 7e 30 30 40 41 46 50 5f 41 4c 49 56 45 20 4c 45 44 20 46 46 46 46 46 46 46 44 0d 0a>,
rawStr: '~00@AFP_ALIVE LED FFFFFFFD\r\n',
req: 'switch',
value: '2',
status: 'OK'
}
*/
AdderKVM Object
The primary exported object is AdderKVM
. It extensively uses RAW
object from raw-device
as its prototype.
Constructor new AdderKVM(AddressObject, OptionsObject)
AddressObject <Object>
- requiredname <string>
- default 'AdderKVM'path <string>
- required. Use valid serial path available in system.baudRate <number>
- default 115200dataBits <number>
- default 8parity <string>
- default 'none'stopBits <number>
- default 1
OptionsObject <Object>
- Optional, default is{encoding: 'ASCII', duration: 1000, disconnect: true, splitter: {delimiter: '\r\n', includeDelimiter: true}}
encoding <string>
duration <number>
- Inter-command period [ms]. A time for device to process command and to prepare and send a response.disconnect <boolean|number>
- Connecion cycle scheme. Use true, false or timeout[ms]. True means close connection when command queue is empty, false means do not close connection, number means close connection after some ms. of connection inactivity.splitter <Object>
Used to select one among three supported transform streams which merge incoming data chunks and split it into valid messages. Only single property from delimiter, regex, timeout can be used.delimiter <string>
- use@serialport/parser-delimiter
with string delimiterregex <Regex>
- use@serialport/parser-regex
with regextimeout <number>
- use@serialport/parser-inter-byte-timeout
with timeout. Response is completed if inter-byte time is longer then timeout. Please consider that timeout must be shorter than duration (inter-command period) and disconnect time (if disconnect use timeout scheme)
Method process(...commands)
Encode and send commands to device. You can use multiple commands in single call. Commands will be queued and executed FIFO.
Supported commands are:
switch input_name
- switch specified input to output. Valid input names are 1-8 and R1-R8 for flexi-switch. Response.req is 'switch'toggleMute
- toggle mute on/off. Response.req is 'mute'KMfocus left|right
- put keyboard/mouse focus to left o right display. Command valid only for flexi-switchaliveFrequency number
- Adder secure KVM reports periodically that he is OK. You can set frequency for this message using alivefrequency command. Number is given in 1/10 seconds (10 means 1sec.). Valid range for number is 1-99. This message from device is decoded also. You can filter the response using response.req=='alive'
Internal commands
There are some internal commands which start with #
. They are not sent to device, but are processed by software itself.
#pause duration
- Append additional pause between neighboring commands as number of miliseconds.#connect
- Force to open connection to device.#close
- Force to close connection to device.
Event: commandForDevice
Emited when command is properly encoded and sent to device. Of course only encoded
property is sent to device itself.
command <Object>
name <string>
- device namecommand <string>
- a command itself, not parsed or encodedencoded <Buffer>
- command encoded as BufferencodedStr <string>
- command encoded as stringduration <number>
- time [ms] for device to process the command.
Event: responseFromDevice
Emited when response from device is properly decoded.
response <Object>
dev <string>
- nameraw <string>
- not decoded responsestatus <string>
- response status. OK or ERRvalue <string|boolean>
- decoded response value. Returned type depends on request (response.req).req <string>
- command, for which response is for. Identifies the response
Event: connectionData
A RAW data which comes directly from device. Not decoded, merged or chopped by splitter
data <Buffer>