Skip to content

Commit

Permalink
Fixed null reference exception on timeout handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Stricker committed Dec 7, 2020
1 parent 4e3a443 commit fc12e46
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
15 changes: 8 additions & 7 deletions 5E9030.29/BR_RFID/BR_RFID/BR_RFID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void connect()
serRFID.WriteTimeout = _timeout;
_port_cur = 1;

// Serach for RFID reader
// Search for RFID reader
while (_port_cur < _port_max)
{
// Find open COM port
Expand Down Expand Up @@ -200,14 +200,14 @@ private int findCOMport(int cur_port)
// Return data from RFID reader
void serRFID_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
// Append data until end is reached
// Append data until end is reached, reset timer
_data_ser = _data_ser + serRFID.ReadExisting();
Debug.WriteLine(DateTime.Now + " " + DateTime.Now.Millisecond + " Read response:" + _data_ser);
TimeoutTimer.Change(-1, 0);
_retrys = 0;

if (_data_ser.Contains("Command") || _data_ser.Contains("PiccSelect"))
{
TimeoutTimer.Change(-1, 0);
_retrys = 0;

// Split data and send respond
try
{
Expand Down Expand Up @@ -275,7 +275,7 @@ internal void RefreshTimer_Elapsed(object state)
// Response timeout timer
internal void TimeoutTimer_Elapsed(object state)
{
Debug.WriteLine(DateTime.Now + " " + DateTime.Now.Millisecond + " Timeout timer");
Debug.WriteLine(DateTime.Now + " " + DateTime.Now.Millisecond + " Timeout timer, retry " + _retrys.ToString());

_retrys++;
if (_retrys > 10)
Expand All @@ -289,8 +289,9 @@ internal void TimeoutTimer_Elapsed(object state)
{
}
if (OnException != null) OnException(excResponseTimeout);
return;
}
TimeoutTimer.Change(-1, 0);
if(TimeoutTimer != null) TimeoutTimer.Change(-1, 0);
}
}
}
4 changes: 2 additions & 2 deletions 5E9030.29/BR_RFID/BR_RFID/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyVersion("1.1.1.0")]
[assembly: AssemblyFileVersion("1.1.1.0")]
4 changes: 3 additions & 1 deletion 5E9030.29/BR_RFID/BR_RFID/Revision.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Version 1.0
Version 1.1
- Fixed null reference exception on timeout handler

Version 1.0
- First release

1 comment on commit fc12e46

@stephan1827
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit fixes #1

Please sign in to comment.