<commit_before>var app = module.parent.exports.app;
var serialPort = require("serialport");
var portName = ''; //change this to your Arduino port
var sendData = "";
var SerialPort = serialPort.SerialPort;

/* GET listado de puertos. */
app.get('/portslist', function(req, res){
  serialPort.list(function (err, ports){
    res.json(ports);
  });
});

/* GET home page. */
app.get('/', function(req, res){
  res.render('index.jade', {titulo: "Arduino" });
});



//serialListener();
app.io.on('connection', function (socket) {
  console.log("user connected");
  socket.emit('onconnection', {pollOneValue:sendData});
  app.io.on('update', function(data) {
  socket.emit('updateData',{pollOneValue:data});
  });
  socket.on('buttonval', function(data) {
    serialPort.write(data + 'E');
  });
  socket.on('sliderval', function(data) {
    serialPort.write(data + 'P');
  });
});


// Listen to serial port
function serialListener()
{
    var receivedData = "";
    serialPort = new SerialPort(portName, {
        baudrate: 9600,
        // defaults for Arduino serial communication
        dataBits: 8,
        parity: 'none',
        stopBits: 1,
        flowControl: false
    });

    serialPort.on("open", function () {
      console.log('open serial communication');
            // Listens to incoming data
        serialPort.on('data', function(data) {
            console.log('data received: ' + data);
            receivedData += data.toString();
          if (receivedData .indexOf('E') >= 0 && receivedData .indexOf('B') >= 0) {
            sendData = receivedData .substring(receivedData .indexOf('B') + 1, receivedData .indexOf('E'));
            receivedData = '';
         }
         // send the incoming data to browser with websockets.
       app.io.emit('update', sendData);
      });

    });
}
<commit_msg>listadode pueertos update<commit_after>var app = module.parent.exports.app;
var serialPort = require("serialport");
var portName = ''; //change this to your Arduino port
var sendData = "";
var SerialPort = serialPort.SerialPort;

/* GET listado de puertos. */
app.get('/portslist', function(req, res){
  serialPort.list(function (err, ports){
    res.json(ports);
  });
});

/* GET home page. */
app.get('/', function(req, res){
  res.render('index.jade', {titulo: "Arduino" });
});

app.get('/conect/:usb', function(req, res){

  res.json(req.params.usb);
});

//serialListener();
app.io.on('connection', function (socket) {
  console.log("user connected");
  socket.emit('onconnection', {pollOneValue:sendData});
  app.io.on('update', function(data) {
  socket.emit('updateData',{pollOneValue:data});
  });
  socket.on('buttonval', function(data) {
    serialPort.write(data + 'E');
  });
  socket.on('sliderval', function(data) {
    serialPort.write(data + 'P');
  });
});


// Listen to serial port
function serialListener()
{
    var receivedData = "";
    serialPort = new SerialPort(portName, {
        baudrate: 9600,
        // defaults for Arduino serial communication
        dataBits: 8,
        parity: 'none',
        stopBits: 1,
        flowControl: false
    });

    serialPort.on("open", function () {
      console.log('open serial communication');
            // Listens to incoming data
        serialPort.on('data', function(data) {
            console.log('data received: ' + data);
            receivedData += data.toString();
          if (receivedData .indexOf('E') >= 0 && receivedData .indexOf('B') >= 0) {
            sendData = receivedData .substring(receivedData .indexOf('B') + 1, receivedData .indexOf('E'));
            receivedData = '';
         }
         // send the incoming data to browser with websockets.
       app.io.emit('update', sendData);
      });

    });
}

{'fraction_non_alphanumeric': 0.1695232994108195, 'fraction_numerical': 0.0048205677557579, 'mean_word_length': 2.9903846153846154, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5140362', 'n_tokens_mistral': 1156, 'n_tokens_neox': 1123, 'n_words': 256}