# Pelco D, Pelco P, BBV422 and Bosch (Philips PCSS), Forward Vision, Vicon, American Dynamics(Sensormatic) and Panasonic Telemetry Decoder (node-pelcod-decoder)

This module reads Pelco D, Pelco P, BBV422, Bosch(Philips PCSS), Forward Vision, Vicon, American Dynamics(Sensormatic) and Panasonic CCTV Camera Pan/Tilt/Zoom data, validates each command and decodes its meaning.
The descripion of each command is written to the console.

The Pelco D, Pelco P and BBV422 commands decoded include  
  * Camera Number
  * Pan  (direction and speed)
  * Tilt (direction and speed)
  * Zoom (Tele/In and Wide/Out)
  * Manual Focus (Near and Far)
  * Manual Iris (Open and Close)
  * Store Preset / Goto Preset / Clear Preset
  * Set Auxiliary (Turn On) / Clear Auxiliary (Turn Off)
  * Start Learning Pattern (Tour) / Stop Learning Pattern (Tour) / Run Pattern (Tour)
  * Set Zoom Speed

The Bosch (Philips) commands decoded include
 * Camera Number
 * Op Code 5 - Start Stop Variable Speed PTZ (Pan, Tilt, Zoom, Manual Focus, Manual Iris) with Pan Speed, Tilt Speed and Zoom speed
 * Op Code 7 - Aux On, Aux Off, Store Pre-Position (store preset), Goto Pre-Position (goto preset)

The Forward Vision commands decoded include
  * Camera Number
  * Pan  (direction and speed)
  * Tilt (direction and speed)
  * Zoom (Tele/In and Wide/Out)
  * Manual Focus (Near and Far)
  * Manual Iris (Open and Close)
  * Store Preset / Goto Preset
  * Wiper, Washer, Lamp auxiliary On/Off
  * Set Zoom Speed

The Vicon commands decoded include
  * Camera Number
  * Pan  (direction and speed)
  * Tilt (direction and speed)
  * Zoom (Tele/In and Wide/Out)
  * Manual Focus (Near and Far)
  * Manual Iris (Open and Close)
  * Goto Preset
  * Auto Pan

The American Dynamics AD422/Sensormatic commands decoded include
  * Camera Number
  * Pan  (direction and speed)
  * Tilt (direction and speed)
  * Zoom (Tele/In and Wide/Out)
  * Manual Focus (Near and Far)
  * Manual Iris (Open and Close)
  * Goto Preset Position / Target
  * Store Preset Position / Target

The Panasonic commands decoded include
  * Camera Number
  * ASCII command string (which is not decoded at this time)


  
# Installation
Run the following command form the command line to install the NPM package
```
npm install pelcod-decoder
```

# Command Line Test Program
The command line test program is executed as
```
node read_serial_port.js
```
This opens a serial port, waits for bytes and then decodes their meaning.
The following flags customise the usage
 * -h    help
 * -l    list available serial port
 * -v    verbose. Show raw bytes read read from serial port
 * -V    version
 * --baud value
 * --parity value (values are none,even,odd)



# Baud Rates
Pelco D telemery is always 7 bytes long and always starts with 0xFF and ends with a checksum. On a Pelco KBD300A Pelco D runs at 2400 baud 8-N-1 with 4800 and 9600 also common on other installations.

Pelco P telemetry is always 8 bytes long and starts with 0xA0 and ends with 0xAF and a checksum. On a Pelco KBD300A Pelco P runs at 4800 baud 8-N-1 with 2400 and 9600 also common on other installations.

Bosch (Philips) is always 9600 baud 8-N-1

Forward Vision is always 9600 baud ODD Parity 8-O-1

The Vicon system tested ran at 9600 baud although the official speed is believed to be 4800 baud

# Stream Sources
The module processes data from a NodeJS Buffer object. A small example program, read_from_serial.js, will read from a Serial Port / COM Port (using node-serial) and pass data into the CCTV PTZ telemetry decoder.


# Pelco D Testing
The code has been tested with Pelco D telemetry generated by
 * Official Pelco KBD300A Keyboard (Rev A0, Ver 5.7)in Direct D mode 2400 baud 8-N-1 SW1-SW8: UP-UP-UP-UP-down-UP-down-UP
 * Bosch Universal Camset CCTV Engineer Tool
 * Bosch VIP X1 XF encoder
 * NodeJS Pelco D Generator https://github.com/Scoup/node-pelcod
 * ISpyConnect http://www.ispyconnect.com/

# Pelco P Testing
The code has been tested with Pelco P telemetry generated by
 * Official Pelco KBD300A Keyboard (Rev A0, Ver 5.7)in Direct P mode 4800 baud 8-N-1 SW1-SW8: UP-UP-UP-UP-down-UP-UP-UP
 * Bosch Universal Camset CCTV Engineer Tool
 * BBV 422 PC Keyboard software
 * Bosch VIP X1 XF encoder
 * Sample byte strings from Commfront

# Building Block Video BBV422 Testing
The code has been tested with BBV telemetry generated by
 * BBV 422 PC Keyboard software


# Bosch (Philips) Testing
The code has been tested with Bosch (Philips) telemetry generated by
 * Bosch Universal Camset CCTV Engeering Tool
 * Bosch VIP X1 XF encoder
 
# Forward Vision Testing
The code has been tested with Forward Vision telemetry generated by
 * Bosch Universal Camset CCTV Engeering Tool
 * Synectics Forward Vision interface

# Vicon Testing
The code has been tested with Vicon telemetry generated by
 * Bosch Universal Camset CCTV Engeering Tool
 * Synectics Vicon interface
 
# American Dynamics (Sensormatic) Testing
The code has been tested with AD422 telemetry generated by
 * Bosch VIP X1 XF encoder
 
# Panasonc Testing
The code has been tested with AD422 telemetry generated by
 * Bosch VIP X1 XF encoder
 * Axis M7001 encoder
