Open GoogleCodeExporter opened 9 years ago
I have coded the necessary changes for a modbus TCP slave to catch exceptions
caused
by simple errors in the modbus request package, and consequently return a
modbus
exception message (as opposed to terminating the app, as it does now). I also
wrapped the event rasing code raising the events my app use, so exception
thrown
from an eventhandler will cause a modbus exception reply. I even included an
(untested) event that will be raised when a modbus exception reply is returned,
it
might even allowing user code to control the contents of the reply (that was
the
original idea, but I never wrote an eventhandler utilizing it, so it may go
horribly
wrong if someone tries).
List of changes compared to the install package
(http://nmodbus.googlecode.com/files/NModbus_net-3.5_1.11.0.0-source.zip):
New files:
src\modbus\Message\ModbusErrorResponse.cs
src\modbus\ModbusException.cs
src\modbus\Device\ModbusExceptionEventArgs.cs
Changed files:
src\modbus\Device\ModbusSlave.cs
src\modbus\Device\ModbusMasterTcpConnection.cs
src\modbus\Message\ModbusMessageImpl.cs
src\modbus\Data\DataStore.cs
src\modbus\modbus.csproj: NOTE: This file is not suitable for use as-is, it has
been
modified to suit the needs of my solution. I include it for completeness only.
Just
add the 3 new files in the original modbus.csproj, it should work fine.
The files are in the attached zip-file.
I believe similar tweaks can be made to the parts of the code implementing
other
types of modbus slaves, but I do not use these myself, so I haven't ventured to
do
so. Feel free to take it further :-)
Original comment by hrsch...@gmail.com
on 20 Nov 2009 at 3:45
Attachments:
Original issue reported on code.google.com by
langeman...@gmail.com
on 17 Dec 2008 at 1:46