<commit_before>"use strict";
var commands = require('./commands');
var debug = require('debug')('rotelctl');
var events = require('events');
var util = require('util');
var serialport = require("serialport");

exports.list = function(cb) {
  serialport.list(cb);
};

var RotelCtl = exports.RotelCtl = function(port) {
  events.EventEmitter.call(this);
  this.port = port;
  this.buffer = new Buffer(0);
  this.handlerQueue = [];
};
util.inherits(RotelCtl, events.EventEmitter);

RotelCtl.prototype.open = function(cb) {
  var self = this;
  self.sp = new serialport.SerialPort("/dev/ttyUSB0", {
    baudrate: 115200,
    databits: 8,
    stopbits: 1,
    parity: 'none'
  });

  var openErrorListener = function(err) {
    self.sp.removeListener('error', openErrorListener);
    cb(err);
  };

  self.sp.once('open', function(err) {
    if (err) {
      return cb(err);
    }
    debug('open');
    self.sp.removeListener('error', openErrorListener);
    self.sp.on('error', function(err) {
      self.emit('error', err);
    });
    cb(null);<commit_msg>use port variable<commit_after>"use strict";
var commands = require('./commands');
var debug = require('debug')('rotelctl');
var events = require('events');
var util = require('util');
var serialport = require('serialport');

exports.list = function(cb) {
  serialport.list(cb);
};

var RotelCtl = exports.RotelCtl = function(port) {
  events.EventEmitter.call(this);
  this.port = port;
  this.buffer = new Buffer(0);
  this.handlerQueue = [];
};
util.inherits(RotelCtl, events.EventEmitter);

RotelCtl.prototype.open = function(cb) {
  var self = this;
  self.sp = new serialport.SerialPort(self.port, {
    baudrate: 115200,
    databits: 8,
    stopbits: 1,
    parity: 'none'
  });

  var openErrorListener = function(err) {
    self.sp.removeListener('error', openErrorListener);
    cb(err);
  };

  self.sp.once('open', function(err) {
    if (err) {
      return cb(err);
    }
    debug('open');
    self.sp.removeListener('error', openErrorListener);
    self.sp.on('error', function(err) {
      self.emit('error', err);
    });
    cb(null);
{'fraction_non_alphanumeric': 0.1721194879089616, 'fraction_numerical': 0.009009009009009009, 'mean_word_length': 3.8617511520737327, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6151171', 'n_tokens_mistral': 733, 'n_tokens_neox': 716, 'n_words': 139}