Commit c20edde7 authored by reza's avatar reza

v3.1

add error handling
parent fd11ed25
...@@ -586,6 +586,12 @@ namespace I8Devices ...@@ -586,6 +586,12 @@ namespace I8Devices
} }
} }
else else
{
//if (!_serialPort.IsOpen)
//{
// Console.WriteLine(_serialPort.IsOpen);
//}
try
{ {
if (device_name == "Fascin8" && _serialPort.IsOpen && _serialPort.BytesToRead > 73) if (device_name == "Fascin8" && _serialPort.IsOpen && _serialPort.BytesToRead > 73)
{ {
...@@ -615,6 +621,7 @@ namespace I8Devices ...@@ -615,6 +621,7 @@ namespace I8Devices
newData_count ++; newData_count ++;
// if (debug_mode) Console.WriteLine("DLL: Sample number " + sample_count + " has been received :)"); // if (debug_mode) Console.WriteLine("DLL: Sample number " + sample_count + " has been received :)");
*/ */
byte[] last_data_recieve = new byte[80]; byte[] last_data_recieve = new byte[80];
_serialPort.Read(last_data_recieve, 0, 80); _serialPort.Read(last_data_recieve, 0, 80);
...@@ -637,7 +644,9 @@ namespace I8Devices ...@@ -637,7 +644,9 @@ namespace I8Devices
receiveBuffer.Add(data_converted); receiveBuffer.Add(data_converted);
sample_count++; sample_count++;
newData_count++; newData_count++;
} }
else if (device_name == "Ultim8" && _serialPort.IsOpen && _serialPort.BytesToRead > 25) else if (device_name == "Ultim8" && _serialPort.IsOpen && _serialPort.BytesToRead > 25)
{ {
byte[] last_data_recieve = new byte[26]; byte[] last_data_recieve = new byte[26];
...@@ -670,6 +679,13 @@ namespace I8Devices ...@@ -670,6 +679,13 @@ namespace I8Devices
if (debug_mode) Console.WriteLine("DLL: Somthing is wrong!"); if (debug_mode) Console.WriteLine("DLL: Somthing is wrong!");
} }
} }
catch (Exception)
{
if (debug_mode)
Console.WriteLine("Port is not open?");
}
}
} }
public object getData(int val=0) public object getData(int val=0)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment