<commit_before>/*
 *
 * Read and decode Pelco D and Pelco P CCTV commands from a Serial Port / COM Port (using node-serialport)
 * Copyright 2016 <NAME>
 *
 * You will need to set the SERIAL_PORT and the BAUD_RATE
 * Note that the Serial Port varies between operating systems
 * E.g.   COM1 on Windows
 * E.g.   /dev/ttyUSB0 on Linux
 * E.g.   /dev/cu.usbserial-141 on Mac
 *
 * The Baud Rate for Pelco D is often 2400 8-N-1
 * The Baud Rate for Pelco P is often 4800 8-N-1
 */

// External Dependencies
var SerialPort = require('serialport').SerialPort;
var PelcoD_Decoder = require('./pelcod_decoder');

// User Settings
var SERIAL_PORT = '/dev/ttyUSB0';
var BAUD_RATE = 2400;

// Globals
var pelco_d_decoder = new PelcoD_Decoder();
var port = new SerialPort(SERIAL_PORT, {
    baudrate: BAUD_RATE,
    parity: 'none',
    dataBits: 8,
    stopBits: 1,
});


// Callback - Open
port.on('open', function(err) {
    if (err) {
        console.log('Serial Port Error : ' + err);
    } else {
        console.log('Serial Port ' + SERIAL_PORT + ' open');
    }
});

// Callback - Data
port.on('data', function(buffer) {
    pelco_d_decoder.processBuffer(buffer);
});<commit_msg>Updated with new SerialPort library<commit_after>/*
 *
 * Read and decode Pelco D and Pelco P CCTV commands from a Serial Port / COM Port (using node-serialport)
 * Copyright 2016 <NAME>
 *
 * You will need to set the SERIAL_PORT and the BAUD_RATE
 * Note that the Serial Port varies between operating systems
 * E.g.   COM1 on Windows
 * E.g.   /dev/ttyUSB0 on Linux
 * E.g.   /dev/cu.usbserial-141 on Mac
 *
 * The Baud Rate for Pelco D is often 2400 8-N-1
 * The Baud Rate for Pelco P is often 4800 8-N-1
 */

// External Dependencies
var SerialPort = require('serialport');
var PelcoD_Decoder = require('./pelcod_decoder');

// User Settings
var SERIAL_PORT = 'COM1';
var BAUD_RATE = 2400;

// Globals
var pelco_d_decoder = new PelcoD_Decoder();
var port = new SerialPort(SERIAL_PORT, {
    baudrate: BAUD_RATE,
    parity: 'none',
    dataBits: 8,
    stopBits: 1,
});


// Callback - Open
port.on('open', function(err) {
    if (err) {
        console.log('Serial Port Error : ' + err);
    } else {
        console.log('Serial Port ' + SERIAL_PORT + ' open');
    }
});

// Callback - Data
port.on('data', function(buffer) {
    pelco_d_decoder.processBuffer(buffer);
});
{'fraction_non_alphanumeric': 0.12367190820229494, 'fraction_numerical': 0.02379940501487463, 'mean_word_length': 3.1298245614035087, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '725138', 'n_tokens_mistral': 854, 'n_tokens_neox': 803, 'n_words': 256}