Skip to content

Commit

Permalink
v1.0
Browse files Browse the repository at this point in the history
Release version.
Fixed exceeding line size error.
  • Loading branch information
Ryan Hall authored and Ryan Hall committed Oct 10, 2019
1 parent 7df3daa commit f213bf2
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 13 deletions.
59 changes: 56 additions & 3 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
using System.Diagnostics;
using System.IO.Ports;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel;
using System.Text;
using Excel = Microsoft.Office.Interop.Excel;
using System.Collections.Generic;

namespace SerialSuite
{
Expand Down Expand Up @@ -207,6 +208,54 @@ private void UpdateHexText(string rawData)
{
try
{
if (this.serialDataGridView.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(UpdateHexText);
this.Invoke(d, new object[] { rawData });
}
else
{
while(rawData.Length > 0)
{
List<char> ch = new List<char>();

if (rawData.Length > 15)
{
for (int i = 0; i < 16; i++)
{
ch.Add(rawData[i]);
}
rawData = rawData.Remove(0, 16);
}
else
{
for (int i = 0; i < rawData.Length; i++)
{
ch.Add(rawData[i]);
}
rawData = rawData.Remove(0);
}

char[] charValues = ch.ToArray();
string hexOutput = "";
foreach (char _eachChar in charValues)
{
int value = Convert.ToInt32(_eachChar);
hexOutput += String.Format("{0:X} ", value);
}

currentRow++;
string dat = new string(ch.ToArray());
DataGridViewRow row = (DataGridViewRow)serialDataGridView.Rows[0].Clone();
row.Cells[0].Value = currentRow;
row.Cells[1].Value = serialPort.PortName;
row.Cells[2].Value = hexOutput;
row.Cells[3].Value = dat;
serialDataGridView.Rows.Add(row);
}
}
#region Legacy
/*
if (this.serialDataGridView.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(UpdateHexText);
Expand All @@ -216,12 +265,14 @@ private void UpdateHexText(string rawData)
{
char[] charValues = rawData.ToCharArray();
string hexOutput = "";
int i = 0;
foreach (char _eachChar in charValues)
{
++i;
int value = Convert.ToInt32(_eachChar);
hexOutput += String.Format("{0:X} ", value);
}
DataGridViewRow row = (DataGridViewRow)serialDataGridView.Rows[0].Clone();
row.Cells[0].Value = currentRow;
row.Cells[1].Value = serialPort.PortName;
Expand All @@ -230,8 +281,10 @@ private void UpdateHexText(string rawData)
serialDataGridView.Rows.Add(row);
currentRow++;
}
*/
#endregion
}
catch(Exception ex)
catch (Exception ex)
{
Debug.WriteLine(ex);
}
Expand Down
6 changes: 3 additions & 3 deletions Form2.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions Form2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private void ComboBoxStopBits_SelectedIndexChanged(object sender, EventArgs e)
/// <param name="e"></param>
private void ComboBoxDataBits_SelectedIndexChanged(object sender, EventArgs e)
{
switch (comboBoxStopBits.SelectedIndex)
switch (comboBoxDataBits.SelectedIndex)
{
case 0:
sPort.DataBits = 8;
Expand Down Expand Up @@ -182,7 +182,7 @@ private void ComboBoxHandshake_SelectedIndexChanged(object sender, EventArgs e)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void comboBoxEncoding_SelectedIndexChanged(object sender, EventArgs e)
private void ComboBoxEncoding_SelectedIndexChanged(object sender, EventArgs e)
{
string currentEncoding = comboBoxEncoding.Text;
sPort.Encoding = Encoding.GetEncoding(currentEncoding);
Expand All @@ -193,7 +193,7 @@ private void comboBoxEncoding_SelectedIndexChanged(object sender, EventArgs e)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void radioButtonRTStrue_CheckedChanged(object sender, EventArgs e)
private void RadioButtonRTStrue_CheckedChanged(object sender, EventArgs e)
{
sPort.RtsEnable = true;
Debug.WriteLine("RTS changed to " + sPort.RtsEnable.ToString());
Expand All @@ -204,7 +204,7 @@ private void radioButtonRTStrue_CheckedChanged(object sender, EventArgs e)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void radioButtonRTSfalse_CheckedChanged(object sender, EventArgs e)
private void RadioButtonRTSfalse_CheckedChanged(object sender, EventArgs e)
{
sPort.RtsEnable = false;
Debug.WriteLine("RTS changed to " + sPort.RtsEnable.ToString());
Expand Down Expand Up @@ -277,9 +277,11 @@ public static void WriteConfig(UserSettings port)
}

/// <summary>
/// Reads stored peristance on disk and returns the object
/// Reads stored peristance on disk
/// </summary>
/// <returns></returns>
/// <returns>
/// Returns a UserSettings class object from the serialised data
/// </returns>
public UserSettings ReadConfig()
{
string dir = @".\";
Expand Down Expand Up @@ -383,4 +385,4 @@ public void UpdateTextBoxes()
}
}
}
}
}
Binary file modified bin/Debug/SerialSuite.exe
Binary file not shown.
Binary file modified bin/Debug/SerialSuite.pdb
Binary file not shown.
Binary file modified bin/Debug/sps.bin
Binary file not shown.
Binary file modified obj/Debug/SerialSuite.exe
Binary file not shown.
Binary file modified obj/Debug/SerialSuite.pdb
Binary file not shown.

0 comments on commit f213bf2

Please sign in to comment.