Hello,
i would like to use OpenHistorian to get e.g. current and voltage values from a device using a serial modbus connection.
The device is connected to serial port COM1 of the computer where OpenHistorian is installed.
If i try to setup the connection to read the holding register 10000, i get the error message: “Exception while reading holding registers starting @ 10000: The port is closed.”
The connection string “portName=COM1; baudRate=19200; dataBits=8; parity=Even; stopBits=One; frameFormat=RTU; transport=SERIAL; unitID=55” was used.
(The unitID is the modbus adress of the device.)
There is no communication on COM1, observed by oscilloscope measurements.
The Log file viewer shows the entries:
Time: 27.03.2023 09:38:34 - Framework - Error - None - None
Event Name: Error Message
Exception:
System.InvalidOperationException: Exception while reading holding registers starting @ 10000: The port is closed. ---> System.InvalidOperationException: The port is closed.
at System.IO.Ports.SerialPort.DiscardInBuffer()
at Modbus.IO.ModbusSerialTransport.Write(IModbusMessage message)
at Modbus.IO.ModbusTransport.UnicastMessage[T](IModbusMessage message)
at Modbus.Device.ModbusMaster.PerformReadRegisters(ReadHoldingInputRegistersRequest request)
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at ModbusAdapters.ModbusHubClient.<ReadHoldingRegisters>d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at openHistorian.DataHub.<ReadHoldingRegisters>d__94.MoveNext()
--- End of inner exception stack trace ---
Message Type: GSF.ServiceProcess.ServiceHelper
Message Assembly: GSF.ServiceProcess.dll (2.4.24.0)
Managed Thread Id: 13
Current Stack Trace:
at openHistorian.ServiceHost.LogException(Exception ex) IL offset: 23
at openHistorian.DataHub+<ReadHoldingRegisters>d__94.MoveNext() IL offset: 245
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) IL offset: 370
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) IL offset: 21
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run() IL offset: 111
at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(Action action, Boolean allowInlining, Task& currentTask) IL offset: 99
at System.Threading.Tasks.Task.FinishContinuations() IL offset: 1024
at System.Threading.Tasks.Task.Finish(Boolean bUserDelegateExecuted) IL offset: 82
at System.Threading.Tasks.Task`1.TrySetException(Object exceptionObject) IL offset: 118
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.SetException(Exception exception) IL offset: 75
Time: 27.03.2023 09:38:34 - Framework - Error - None - None
Event Name: Status Message Alarm
Message: Exception while reading holding registers starting @ 10000: The port is closed.
Details: 00000000-0000-0000-0000-000000000000
Message Type: GSF.ServiceProcess.ServiceHelper
Message Assembly: GSF.ServiceProcess.dll (2.4.24.0)
Managed Thread Id: 13
Current Stack Trace:
at GSF.ServiceProcess.ServiceHelper.UpdateStatus(UpdateType type, Boolean publishToLog, String message, Object[] args) IL offset: 95
at GSF.TimeSeries.ServiceHostBase.DisplayStatusMessage(String status, UpdateType type, Boolean publishToLog) IL offset: 179
at openHistorian.DataHub+<ReadHoldingRegisters>d__94.MoveNext() IL offset: 245
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) IL offset: 370
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) IL offset: 21
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run() IL offset: 111
at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(Action action, Boolean allowInlining, Task& currentTask) IL offset: 99
at System.Threading.Tasks.Task.FinishContinuations() IL offset: 1024
at System.Threading.Tasks.Task.Finish(Boolean bUserDelegateExecuted) IL offset: 82
at System.Threading.Tasks.Task`1.TrySetException(Object exceptionObject) IL offset: 118
What am I doing wrong ?