<commit_before>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.crocs.EduHoc.Serial;

import gnu.io.*;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Embedded Freaks
 * https://embeddedfreak.wordpress.com/2008/08/08/how-to-open-serial-port-using-rxtx/
 */
public class SerialPortHandler {

    private SerialPort serialPort;
    private OutputStream outStream;
    private InputStream inStream;

    private boolean silent = false;
    private boolean verbose = false;

    public void setVerbose() {
        verbose = true;
    }

    public void setSilent() {
        silent = true;
    }

    public void connect(String portName) throws IOException {
        try {
            // Obtain a CommPortIdentifier object for the port you want to open
            System.setProperty("gnu.io.rxtx.SerialPorts", portName);
            CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName);

            // Get the port's ownership
            serialPort = (SerialPort) portId.open("JeeTool", 5000);

            // Set the parameters of the connection.
            setSerialPortParameters();

            // Open the input and output streams for the connection. If they won't
            // open, close the port before throwing an exception.
            outStream = serialPort.getOutputStream();
            inStream = serialPort.getInputStream();<commit_msg>port symlink resolved<commit_after>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.crocs.EduHoc.Serial;

import gnu.io.*;
import java.io.File;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author <NAME>
 * https://embeddedfreak.wordpress.com/2008/08/08/how-to-open-serial-port-using-rxtx/
 */
public class SerialPortHandler {

    private SerialPort serialPort;
    private OutputStream outStream;
    private InputStream inStream;

    private boolean silent = false;
    private boolean verbose = false;

    public void setVerbose() {
        verbose = true;
    }

    public void setSilent() {
        silent = true;
    }

    public void connect(String portName) throws IOException {
        try {
            // Obtain a CommPortIdentifier object for the port you want to open
            File f = new File(portName);
            
            System.setProperty("gnu.io.rxtx.SerialPorts", f.getCanonicalPath());
            CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(f.getCanonicalPath());

            // Get the port's ownership
            serialPort = (SerialPort) portId.open("JeeTool", 5000);

            // Set the parameters of the connection.
            setSerialPortParameters();

            // Open the input and output streams for the connection. If they won't
            // open, close the port before throwing an exception.
            outStream = serialPort.getOutputStream();
            inStream = serialPort.getInputStream();
{'fraction_non_alphanumeric': 0.08965314520870077, 'fraction_numerical': 0.007054673721340388, 'mean_word_length': 2.690889370932755, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 2, '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': '3834648', 'n_tokens_mistral': 934, 'n_tokens_neox': 889, 'n_words': 280}