|
@@ -31,13 +31,17 @@ namespace Basic_Terminal
|
31
|
31
|
}
|
32
|
32
|
cb_port.EndUpdate();
|
33
|
33
|
//SerialPort 초기 설정.
|
34
|
|
- serialPort.Encoding = Encoding.GetEncoding("Windows-1252");
|
|
34
|
+ // serialPort.Encoding = Encoding.GetEncoding("Windows-1252");
|
35
|
35
|
cb_port.DataSource = SerialPort.GetPortNames();
|
36
|
|
- serialPort.PortName = Serial_Name = cb_port.SelectedItem.ToString();
|
37
|
|
- serialPort.BaudRate = (int)115200;
|
38
|
|
- serialPort.DataBits = (int)8;
|
39
|
|
- serialPort.Parity = System.IO.Ports.Parity.None;
|
40
|
|
- serialPort.StopBits = StopBits.One;
|
|
36
|
+ try
|
|
37
|
+ {
|
|
38
|
+ serialPort.PortName = Serial_Name = cb_port.SelectedItem.ToString();
|
|
39
|
+ serialPort.BaudRate = (int)115200;
|
|
40
|
+ serialPort.DataBits = (int)8;
|
|
41
|
+ serialPort.Parity = System.IO.Ports.Parity.None;
|
|
42
|
+ serialPort.StopBits = StopBits.One;
|
|
43
|
+ }
|
|
44
|
+ catch { }
|
41
|
45
|
|
42
|
46
|
}
|
43
|
47
|
private delegate void StringSend(string Text);
|
|
@@ -109,7 +113,7 @@ namespace Basic_Terminal
|
109
|
113
|
System.GC.Collect(0, GCCollectionMode.Forced);
|
110
|
114
|
System.GC.WaitForFullGCComplete();
|
111
|
115
|
}
|
112
|
|
- public Boolean Serial_PortOpen(ref Button Btn_Portonoff)
|
|
116
|
+ public Boolean Serial_PortOpen(ref Button Btn_Portonoff,ref ComboBox cb)
|
113
|
117
|
{
|
114
|
118
|
Boolean ret = false;
|
115
|
119
|
try
|
|
@@ -121,8 +125,16 @@ namespace Basic_Terminal
|
121
|
125
|
}
|
122
|
126
|
else//When the port is close
|
123
|
127
|
{
|
124
|
|
- serialPort.Open();
|
125
|
|
- Btn_Portonoff.Text = "Port Close";
|
|
128
|
+ if (cb.Text != "")
|
|
129
|
+ {
|
|
130
|
+ serialPort.Open();
|
|
131
|
+ Btn_Portonoff.Text = "Port Close";
|
|
132
|
+ }
|
|
133
|
+ else
|
|
134
|
+ {
|
|
135
|
+ MessageBox.Show("Port is not set");
|
|
136
|
+ ret = true;
|
|
137
|
+ }
|
126
|
138
|
}
|
127
|
139
|
}
|
128
|
140
|
catch
|