Skip to content

Commit 7dd2dbb

Browse files
author
SG
committed
add: ASCII support
1 parent 8e63361 commit 7dd2dbb

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

EasyModbusAdvancedClient/MainForm.Designer.cs

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

EasyModbusAdvancedClient/MainForm.cs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,27 @@ private void UpdateDataGridView(object sender)
146146
dataGridView1[4,i].Value=((bool[]) functionProperty.values)[j].ToString();
147147
else
148148
{
149-
if (dataGridView1[3,i].Value != null)
150-
if (dataGridView1[3,i].Value.Equals("UINT16 (0...65535)"))
151-
if (((int[]) functionProperty.values)[j] < 0)
152-
dataGridView1[4,i].Value=(65536+((int[]) functionProperty.values)[j]).ToString();
153-
else
154-
dataGridView1[4,i].Value=((int[]) functionProperty.values)[j].ToString();
155-
else
156-
dataGridView1[4,i].Value=((int[]) functionProperty.values)[j].ToString();
157-
else
158-
dataGridView1[4,i].Value=((int[]) functionProperty.values)[j].ToString();
149+
if (dataGridView1[3, i].Value != null)
150+
if (dataGridView1[3, i].Value.Equals("UINT16 (0...65535)"))
151+
if (((int[])functionProperty.values)[j] < 0)
152+
dataGridView1[4, i].Value = (65536 + ((int[])functionProperty.values)[j]).ToString();
153+
else
154+
dataGridView1[4, i].Value = ((int[])functionProperty.values)[j].ToString();
155+
else if (dataGridView1[3, i].Value.Equals("ASCII"))
156+
{
157+
158+
string str = "";
159+
for (int tt = 0; tt < ((int[])functionProperty.values).Length; tt++)
160+
{
161+
int value = ((int[])functionProperty.values)[tt];
162+
str += "" + (char)((value & 0xff00) >> 8) + (char)((value & 0x00ff));
163+
}
164+
dataGridView1[4, i].Value = "" + str;
165+
}
166+
else
167+
dataGridView1[4, i].Value = ((int[])functionProperty.values)[j].ToString();
168+
else
169+
dataGridView1[4, i].Value = ((int[])functionProperty.values)[j].ToString();
159170
}
160171
}
161172
}
@@ -475,6 +486,7 @@ void DataGridView1CellClick(object sender, DataGridViewCellEventArgs e)
475486
{
476487
cbCell.Items.Add("INT16 (-32768...32767)");
477488
cbCell.Items.Add("UINT16 (0...65535)");
489+
cbCell.Items.Add("ASCII");
478490
}
479491
if (selectedCell != null)
480492
{

0 commit comments

Comments
 (0)