tborad / nmodbus

Automatically exported from code.google.com/p/nmodbus
0 stars 0 forks source link

Spontaneus Exception #29

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Just reading and writing to the TCP Slave

What is the expected output? What do you see instead?
Get an exception (see below)

What version of the product are you using? On what operating system?
1.6 on vista business

Please provide any additional information below.
System.InvalidOperationException was unhandled
  Message="Collection was modified; enumeration operation may not execute."
  Source="mscorlib"
  StackTrace:
       at System.ThrowHelper.ThrowInvalidOperationException
(ExceptionResource resource)
       at System.Collections.Generic.List`1.Enumerator.MoveNext()
       at System.Linq.Enumerable.<SkipIterator>d__53`1.MoveNext()
       at System.Linq.Enumerable.<TakeIterator>d__40`1.MoveNext()
       at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
       at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
       at Modbus.Data.DataStore.ReadData[T,U](DataStore dataStore, 
ModbusDataCollection`1 dataSource, UInt16 startAddress, UInt16 count)
       at Modbus.Device.ModbusSlave.ReadRegisters
(ReadHoldingInputRegistersRequest request, DataStore dataStore, 
ModbusDataCollection`1 dataSource)
       at Modbus.Device.ModbusSlave.ApplyRequest(IModbusMessage request)
       at Modbus.Device.ModbusTcpSlave.MasterConnection.ReadFrameCompleted
(IAsyncResult ar)
       at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
       at System.Net.ContextAwareResult.CompleteCallback(Object state)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at 
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCle
anup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext 
executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext 
executionContext, ContextCallback callback, Object state)
       at System.Net.ContextAwareResult.Complete(IntPtr userToken)
       at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object 
result, IntPtr userToken)
       at 
System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 
errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
       at 
System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 
errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

Original issue reported on code.google.com by fredrik....@isg.se on 6 May 2008 at 7:52

GoogleCodeExporter commented 8 years ago
Currently the NModbus slave is not thread safe, therefore if you're writing to 
the
slave on ThreadA and reading from ThreadB you could encounter this exception. I 
am
just beginning some work on a GUI which will require thread safety... it will be
added soon.

Original comment by sja...@gmail.com on 6 May 2008 at 8:56

GoogleCodeExporter commented 8 years ago
I'm just wondering what you actually meant with the last part.

Will you add thread safety to the slave or will you add an example gui that 
will 
enforce thread safety?

Regards,

        / Fredrik

Original comment by fredrik....@isg.se on 6 May 2008 at 9:19

GoogleCodeExporter commented 8 years ago
I will modify the DataStore class to be thread safe. As a result using the 
NModbus
master API to read/write an NModbus slave's data will be thread safe.

Original comment by sja...@gmail.com on 6 May 2008 at 9:48

GoogleCodeExporter commented 8 years ago
Fixed with version 1.7

Original comment by sja...@gmail.com on 19 May 2008 at 2:00