<commit_before>//Load and initialize the serial modem and set parser
var serialport = require("serialport");
var SerialPort = serialport.SerialPort;
var sp = new SerialPort(modemPort, {
  parser: serialport.parsers.readline("\n")
});

//Actively listen to the in app.js configured port.
sp.on("open", function () {
    console.log("Listening on port: " + modemPort);
	//Send command to modem to show caller-id in nice format.
    sp.write("AT+VCID=1", function(err, results) {
        sp.drain(console.log('Enabling CallerId nice format: ' + results));
    });    
    
	//Respond to data received from modem
    sp.on('data', function(data) {
        console.log('Data received: ' + data);
		//If data contains a number extract it and activate the current caller.
        if(data.indexOf("NMBR=") > -1){
            var phoneNumber = data.substring(5);
			console.log('Callers number: ' + phoneNumber);			
			global.callHandler.receiveCall(phoneNumber);
        }
    });
});

//Make listPorts function available to other parts of the program.
module.exports = {
  listPorts: function (callback) {
    listPorts(callback);
  }
};

//List ports that are available on this system.
function listPorts(callback){
    serialport.list(function (err, ports) {
        callback(ports);
    });
}<commit_msg>- Fixed bug where sending AT+VCID=1 to enable callerID setting in modem needed a \r to be send. TODO: figure out why every incoming message now contains \r (which needs to be filtered out)<commit_after>//Load and initialize the serial modem and set parser
var serialport = require("serialport");
var SerialPort = serialport.SerialPort;
var sp = new SerialPort(modemPort, {
  parser: serialport.parsers.readline("\n")
});

//Actively listen to the in app.js configured port.
sp.on("open", function () {
    console.log("Listening on port: " + modemPort);
	//Send command to modem to show caller-id in nice format.
    sp.write("AT+VCID=1\r", function(err, results) {
        sp.drain(console.log('Enabling CallerId nice format: ' + results));
    });    
    
	//Respond to data received from modem
    sp.on('data', function(data) {
        console.log('Data received: ' + data);
		//If data contains a number extract it and activate the current caller.
        if(data.indexOf("NMBR=") > -1){
            var phoneNumber = data.substring(5);
	    phoneNumber = phoneNumber.substring(0, phoneNumber.length-1);
	    console.log('Callers number: ' + phoneNumber);			
	    global.callHandler.receiveCall(phoneNumber);
        }
    });
});

//Make listPorts function available to other parts of the program.
module.exports = {
  listPorts: function (callback) {
    listPorts(callback);
  }
};

//List ports that are available on this system.
function listPorts(callback){
    serialport.list(function (err, ports) {
        callback(ports);
    });
}
{'fraction_non_alphanumeric': 0.12570224719101122, 'fraction_numerical': 0.0031601123595505617, 'mean_word_length': 3.362940275650842, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1640644', 'n_tokens_mistral': 860, 'n_tokens_neox': 827, 'n_words': 264}