diff --git a/5E9030.29/BR_RFID/BR_RFID/BR_RFID.cs b/5E9030.29/BR_RFID/BR_RFID/BR_RFID.cs index f813622..46519f3 100644 --- a/5E9030.29/BR_RFID/BR_RFID/BR_RFID.cs +++ b/5E9030.29/BR_RFID/BR_RFID/BR_RFID.cs @@ -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 @@ -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 { @@ -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) @@ -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); } } } diff --git a/5E9030.29/BR_RFID/BR_RFID/Properties/AssemblyInfo.cs b/5E9030.29/BR_RFID/BR_RFID/Properties/AssemblyInfo.cs index d71d675..b3c64e4 100644 --- a/5E9030.29/BR_RFID/BR_RFID/Properties/AssemblyInfo.cs +++ b/5E9030.29/BR_RFID/BR_RFID/Properties/AssemblyInfo.cs @@ -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")] diff --git a/5E9030.29/BR_RFID/BR_RFID/Revision.txt b/5E9030.29/BR_RFID/BR_RFID/Revision.txt index 5699c66..e7c5050 100644 --- a/5E9030.29/BR_RFID/BR_RFID/Revision.txt +++ b/5E9030.29/BR_RFID/BR_RFID/Revision.txt @@ -1,3 +1,5 @@ -Version 1.0 +Version 1.1 +- Fixed null reference exception on timeout handler +Version 1.0 - First release \ No newline at end of file