<commit_before>#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

static struct termios oldterminfo;

void closeserial(int fd)
{
	tcsetattr(fd, TCSANOW, &oldterminfo);
	if (close(fd) < 0)
		perror("closeserial()");
}


int openserial(char *devicename, int seconds)
{
	int fd;
	struct termios attr;

	if ((fd = open(devicename, O_RDWR)) == -1) {
		perror("openserial(): open()");
		return 0;
	}

	if (tcgetattr(fd, &oldterminfo) == -1) {
		perror("openserial(): tcgetattr()");
		return 0;
	}
	attr = oldterminfo;
	attr.c_cflag |= CRTSCTS | CLOCAL;
	attr.c_oflag = 0;

	if (tcflush(fd, TCIOFLUSH) == -1) {
		perror("openserial(): tcflush()");
		return 0;
	}

	sleep(seconds);

	if (tcsetattr(fd, TCSANOW, &attr) == -1) {
		perror("initserial(): tcsetattr()");
		return 0;
	}
	return fd;
}

int main(int argc, char *argv[])
{
	int arg_seconds;
	int fd;
	char *serialdev = "/dev/ttyS0";

	if(argc > 1) {
		arg_seconds=atoi(argv[1]);
	}
	else {
		printf("Please introduce the sleep time in seconds: ./serial X \n");
		return 1;
	}<commit_msg>UserSpace: Serial Device<commit_after>#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

static struct termios oldterminfo;

void closeserial(int fd)
{
	tcsetattr(fd, TCSANOW, &oldterminfo);
	if (close(fd) < 0)
		perror("closeserial()");
}


int openserial(char *devicename, int seconds)
{
	int fd;
	struct termios attr;

	if ((fd = open(devicename, O_RDWR)) == -1) {
		perror("openserial(): open()");
		return 0;
	}

	if (tcgetattr(fd, &oldterminfo) == -1) {
		perror("openserial(): tcgetattr()");
		return 0;
	}
	attr = oldterminfo;
	attr.c_cflag |= CRTSCTS | CLOCAL;
	attr.c_oflag = 0;

	if (tcflush(fd, TCIOFLUSH) == -1) {
		perror("openserial(): tcflush()");
		return 0;
	}

	sleep(seconds);

	if (tcsetattr(fd, TCSANOW, &attr) == -1) {
		perror("initserial(): tcsetattr()");
		return 0;
	}
	return fd;
}

int main(int argc, char *argv[])
{
	int arg_seconds;
	int fd;
	char *serialdev = (argv[2]);

	if (argc > 1) {
		arg_seconds=atoi(argv[1]);
	}
	else {
		printf("Please introduce the sleep time in seconds: ./serial X \n");
		return 1;
	}

	if ((argv[2]==0))  {
		printf("Please add a /dev/ttyXX terminal to be used by serial. \n");
		return 1;

	}
{'fraction_non_alphanumeric': 0.18335393489905233, 'fraction_numerical': 0.01277297074577668, 'mean_word_length': 4.122362869198312, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '6674900', 'n_tokens_mistral': 1083, 'n_tokens_neox': 1020, 'n_words': 242}