<commit_before>'use strict';
var serialport = require('serialport');
// var SerialPort = serialport.SerialPort;
var parsers = serialport.parsers;
const fs = require('fs');


var port = new serialport('/dev/ttyUSB0', {
	baudRate: 300,
	dataBits: 7,
	stopBits: 1,
	parity: 'even',
	parser: parsers.readline('\r\n')
});

port.on('open', function() {
	console.log('Port open');
	init();
});

port.on('data', function(data) {
	console.log('Line from file:', data);
  var d = data;
	if (d.lastIndexOf('/ISk5MT174', 0) === 0) {
		d = '\n' + new Date().getTime() + ';' + d;
	} else {
		d = ';' + d;
	}
	fs.appendFile('data.csv', d, function (err) {
	  	if (err) return console.log(err);
	});
});

function init() {
	port.write('/?!\r\n');
	setInterval(port.write('/?!\r\n'), 5*60*1000);
}
<commit_msg>interval fix<commit_after>'use strict';
var serialport = require('serialport');
// var SerialPort = serialport.SerialPort;
var parsers = serialport.parsers;
const fs = require('fs');


var port = new serialport('/dev/ttyUSB0', {
	baudRate: 300,
	dataBits: 7,
	stopBits: 1,
	parity: 'even',
	parser: parsers.readline('\r\n')
});

port.on('open', function() {
	console.log('Port open');
	init();
});

port.on('data', function(data) {
	console.log('Line from file:', data);
  var d = data;
	if (d.lastIndexOf('/ISk5MT174', 0) === 0) {
		d = '\n' + new Date().getTime() + ';' + d;
	} else {
		d = ';' + d;
	}
	fs.appendFile('data.csv', d, function (err) {
	  	if (err) return console.log(err);
	});
});

function init() {
	getData();
	setInterval(getData, 5*60*1000);
}

function getData() {
	port.write('/?!\r\n');
}

{'fraction_non_alphanumeric': 0.2271313005600498, 'fraction_numerical': 0.023646546359676415, 'mean_word_length': 4.104761904761904, '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': '3881316', 'n_tokens_mistral': 673, 'n_tokens_neox': 636, 'n_words': 138}