<commit_before>﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.IO.Ports;

namespace arduinoCommunication
{
    public partial class Main : Form
    {

        SerialPort port;
        public void InitializeArduino(String listeningPort, int boundrate) 
        {
            try
            {
                port = new SerialPort(listeningPort, boundrate);
                port.BaudRate = 9600;
                port.Parity = Parity.None;
                port.StopBits = StopBits.One;
                port.DataBits = 8;
                port.Handshake = Handshake.None;
                port.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);

                port.Open();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

        }

        private void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)
        {
            SerialPort sp = (SerialPort)sender;
            string line = sp.ReadLine();
            this.BeginInvoke(new LineReceivedEvent(LineReceived), line);
        }

        private delegate void LineReceivedEvent(string line);

        private void LineReceived(string line)
        {
            txtLog.Text = txtLog.Text + line + "\n";
        }

        public Main()
        {
            InitializeComponent();
            
        }

        private void btnClear_Click(object sender, EventArgs e)
        {
            txtLog.Text = null;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            InitializeArduino("COM3", 9600);
            string[] ports = SerialPort.GetPortNames();

            foreach (string port in ports)
            {
                cmbPorts.Items.Add(port);
            }
        }

        private void btnConnect_Click(object sender, EventArgs e)
        {
            InitializeArduino(cmbPorts.Text, Convert.ToInt32(txtBoundRate.Text));
        }

        private void btnSend_Click(object sender, EventArgs e)
        {
            String s = txtSend.Text;
            port.Write(s);
        }

        private void Main_FormClosing(object sender, FormClosingEventArgs e)
        {
            port.Close();
        }

        private void txtLog_TextChanged(object sender, EventArgs e)
        {
            txtLog.SelectionStart = txtLog.Text.Length;
            txtLog.ScrollToCaret();
        }
    
    }
}
<commit_msg>Update Main.cs<commit_after>﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.IO.Ports;

namespace arduinoCommunication
{
    public partial class Main : Form
    {
        SerialPort port;
        public void InitializeArduino(String listeningPort, int boundrate) 
        {
            try
            {
                port = new SerialPort(listeningPort, boundrate);
                port.BaudRate = 9600;
                port.Parity = Parity.None;
                port.StopBits = StopBits.One;
                port.DataBits = 8;
                port.Handshake = Handshake.None;
                port.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);

                port.Open();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)
        {
            SerialPort sp = (SerialPort)sender;
            string line = sp.ReadLine();
            this.BeginInvoke(new LineReceivedEvent(LineReceived), line);
        }

        private delegate void LineReceivedEvent(string line);

        private void LineReceived(string line)
        {
            txtLog.Text = txtLog.Text + line + "\n";
        }

        public Main()
        {
            InitializeComponent();
        }

        private void btnClear_Click(object sender, EventArgs e)
        {
            txtLog.Text = null;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            InitializeArduino("COM3", 9600);
            string[] ports = SerialPort.GetPortNames();

            foreach (string port in ports)
            {
                cmbPorts.Items.Add(port);
            }
        }

        private void btnConnect_Click(object sender, EventArgs e)
        {
            InitializeArduino(cmbPorts.Text, Convert.ToInt32(txtBoundRate.Text));
        }

        private void btnSend_Click(object sender, EventArgs e)
        {
            String s = txtSend.Text;
            port.Write(s);
        }

        private void Main_FormClosing(object sender, FormClosingEventArgs e)
        {
            port.Close();
        }

        private void txtLog_TextChanged(object sender, EventArgs e)
        {
            txtLog.SelectionStart = txtLog.Text.Length;
            txtLog.ScrollToCaret();
        }
    }
}

{'fraction_non_alphanumeric': 0.08191449110858873, 'fraction_numerical': 0.004918653045781309, 'mean_word_length': 1.7168550873586845, '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': '3488548', 'n_tokens_mistral': 1411, 'n_tokens_neox': 1349, 'n_words': 303}