Coder Social home page Coder Social logo

nmodbus's People

Watchers

 avatar

nmodbus's Issues

Repost of Issue 22: ModbusDataCollection.cs ArgumentOutOfRangeException

(this is in reply to scott's message below) (sorry for not following the
format)

yes, i understand, but when you set the coil using the address of 1, it
sets the coil with address 2 (index 1 in the array)- so essentially, the
item with index 0 (which would be coil 1) in the array is stranded- you can
never set it.  the best way to reproduce this is to list all the registers
by address.  then try to set address 1, you will see that the value of
address 2 has changed. 

so you have to adjust for the base 1 numbering or something.  hopefully i
am not mistaken, i am pretty sure i am not since i am using the library to
build a full-featured slave and the coil (address 1) with index 0 in the
array is unreachable due to the check in the code.  i have 3000 coils
numbered 0 through 2999 in the array with the addresses of 1 through 3000.
 Once again if i try a coil using address 1, it sets the coil with the
address of 2...

 Issue 22: ModbusDataCollection.cs ArgumentOutOfRangeException
http://code.google.com/p/nmodbus/issues/detail?id=22

Comment #1 by sjalex:
Actually this is by design.

1) In a MODBUS PDU data is addressed from 0 to 65535 (0 origin)
2) In the MODBUS data Model each element within a data block is
numbered from 1 to n
(1 origin)
3) .NET collections are of 0 origin

In order to be true to the Modbus data model I created the
ModbusDataCollection, a 1
origin collection.

http://modbus.org/docs/Modbus_Application_Protocol_V1_1b.pdf for more details.

Scott

Original issue reported on code.google.com by [email protected] on 13 Dec 2007 at 3:17

RTU slave doesn't check received modbus command for CRC

What steps will reproduce the problem?
1. Setup a modbus master (RTU) which first sends a "bonus" character to 
the RTU slave. 
2. Wait a while, e.g. 10 sec.
3. From the modbus master send a proper modbus message to the slave

What is the expected output? What do you see instead?
I would expect to see the slave to ignor the "bonus" character or to 
discard the message due to an invalid CRC

What I see instead is that the slave will decode the message starting from 
the "bonus" character. From this point on the slave is not longer 
synchronized and all modbus messages sent to the slave will fail. After 
sending 7 "bonus" characters more the slave will respond again.

What version of the product are you using? On what operating system?
Windows XP

Please provide any additional information below.

Problem came to light due to ill behaving hardware. A rs-232 analyzer 
showed a "bonus" character was send.

Original issue reported on code.google.com by [email protected] on 30 Nov 2007 at 7:18

Slave implementation

I see the Master part of the Modbus is implemented.

I would like to know whether the slave implementation is in the pipeline 
in near future, if so, when?

Thanks a lot for your efforts.
-Ravi.

Original issue reported on code.google.com by [email protected] on 11 Sep 2006 at 6:34

WriteMultipleCoils notifies DataStoreWrittenTo even with invalid values count

What steps will reproduce the problem?
1. Subscribe to DataStore.DataStoreWrittenTo
2. WriteMultipleCoils 10 values

What is the expected output? What do you see instead?
DataStoreEventArgs.A.Count in DataStore.DataStoreWrittenTo should be 10.
Instead is 16. (Always multiple of 8)

What version of the product are you using? On what operating system?
Version 1.8.0.0. Vista 32bit.

Please provide any additional information below.
Can be easily fixed in WriteMultipleCoilsRequest.cs:73 
Method InitializeUnique(byte[] frame)
Data should be set like this:
Data = new DiscreteCollection((new BitArray(frame.Slice(7,
ByteCount).ToArray())).Cast<bool>().Take(NumberOfPoints).ToArray());

Original issue reported on code.google.com by [email protected] on 30 Oct 2008 at 11:41

ReadWriteMultipleRegisters has bad CRC calculation

What steps will reproduce the problem?
1. ReadWriteMultipleRegisters can't be processed by slave device, because
it generates bad CRC. CRC is the same no mather what data I've send.
2.
3.
-----------------------------------------------------
What is the expected output? What do you see instead?

Example of ReadWriteMultipleRegisters:
I want to read from 6000h 2 registers and write 2 registers to 6000h
Message should be (calculated in test programme):
01,17,60,00,00,02,60,00,00,02,04,8B,BE,F2,00,E0,42
and is (captured on slave)
01,17,60,00,00,02,60,01,00,02,04,12,34,56,78,40,2E

-----------------------------------------------------
What version of the product are you using? On what operating system?

1.11.0.0 .NET 3.5
VB.NET Express Edition on Windows XP SP3 (both with most recent security
updates)

-----------------------------------------------------
Please provide any additional information below.

When you calculate CRC just from this 01,17 you also get 40,2E.
It looks like, that in function ReadWriteMultipleRegisters CRC is
calculated just from device address and function number.

Original issue reported on code.google.com by [email protected] on 27 Oct 2009 at 7:17

Timeout behavior changed between version 1.10 and 1.11

Transport.ReadTimeout and Transport.WriteTimeout changed between version
1.10 and 1.11 from  1000 msec to -1 (I assume this is Infinite).  The
effect is that a call to write or read never fails by default.  Manually
changing read and write timeouts resolves the issue.

Original issue reported on code.google.com by [email protected] on 12 May 2009 at 10:56

Enhancement for multithreading

I would like to discuss the possibility of adding lock(SerialPort) to the
Write function of ModbusSerialTransport, and to lock the streamreader somehow.

Original issue reported on code.google.com by [email protected] on 22 Nov 2006 at 7:51

ReadHoldingRegisters problem

What steps will reproduce the problem?

I'm trying to read registers from a device using serial RTU.
I can write register fine, but am having trouble reading them.

my read code is:

ushort[] ReadValueTmp = _ModbusMaster.ReadHoldingRegisters(0x02, 0x0003, 
0x0001);

What is the expected output? What do you see instead?
I get the exception:
"Function code 116 not supported."

What version of the product are you using? On what operating system?
I've been using 1.1.0.0
I also just tried it with 1.2 beta and got the same result.
XP SP2


Please provide any additional information below.

I don't know if it is something that I am doing wrong or if it is a 
problem with the device I am communicating with.  I am trying to read 
registers on an Automation Direct GS2 Frequency Motor Drive.

Thank you.  nmodbus like an awfully good component.  I'm just excited to 
get it up and running.

Ryan

Original issue reported on code.google.com by [email protected] on 14 Jun 2007 at 5:53

ReadWriteMultipleRegisters - The write operation is not performed before the read.

What steps will reproduce the problem?
1. If you are reading register value at the same register address as you
are writting, then you obtain old data before write part of the function is
applied. 
2. But if you are reading and writing at different register addresses, then
everything seems OK.
3.

What is the expected output? What do you see instead?

Value of the registers before 0x17 Read/Write Multiple registers:
Register : 20 -> 1
Register : 21 -> 2
Register : 22 -> 3
Register : 23 -> 4
Register : 24 -> 5

0x17 Read/Write is used to read at address 20 5 registers and write at
address 20 5 registers {1,0,3,0,5} at the same time.

Value of the registers after 0x17 Read/Write Multiple registers:
Register : 20 -> 1
Register : 21 -> 0
Register : 22 -> 3
Register : 23 -> 0
Register : 24 -> 5

Value of the registers after 0x17 Read/Write Multiple registers returned by
the 0x17 Read/Write function:
Register : 20 -> 1
Register : 21 -> 2
Register : 22 -> 3
Register : 23 -> 4
Register : 24 -> 5


What version of the product are you using? On what operating system?
Assembly: Modbus (Module: Modbus) Version: 1.9.0.0 (1.9.0.0) 
Assembly: Modbus (Module: Modbus) Version: 1.11.0.0 (1.11.0.0)
Windows XP SP3 Eng ver.

Please provide any additional information below.
From Modbus_Application_Protocol_V1_1b specification:

This function code performs a combination of one read operation and one
write operation in a single MODBUS transaction. The write operation is
performed before the read.


Thank you very much :)

Original issue reported on code.google.com by [email protected] on 10 May 2009 at 4:13

Addresses are short

What steps will reproduce the problem?

1.Try to use an address that is not a short value

What is the expected output? What do you see instead?

I have no expected output, I more cannot access many of the parameters in
my device because the Addresses don't start until 0x9100 or 37127. 

What version of the product are you using? On what operating system?

NModbus 1.4.0.2 windows XP professional SP2

Please provide any additional information below.

The code is very complicated and I wanted to just modify it myself but I am
afraid that if I boil it down to the ModbusMessageImpl class and change the
variable type then I will break compatibility everywhere else in the library.

I am not really asking for a fix it just seems strange that the library
would limit you to reading registers below 32767. I know that is a large
number but I have encountered more than one instance of a device with
register addresses above this number.

I would gladly change it myself to an integer but I was hoping that someone
could outline   briefly how the startAddress variable interacts with the
actual construction of the message. I was afraid that if I were to just
change it that it would no longer encode properly because I would be
changing to a 32 bit value. 

I could change it to a uShort that would give me a true 16 bit value
without affecting message packaging, I think but I was hoping someone could
confirm this for me.

Any attention to this would be greatly appreciated.

and thank you for creating such a nice library, and allowing the community
as a whole to use it. 

Original issue reported on code.google.com by [email protected] on 2 Nov 2007 at 5:06

Add support for custom messages when using the RTU protocol

When you use the ExecuteCustomMessage method on ModbusMaster the RTU
protocol needs special handling since it the library can not know anything
about the length of the data to receive as response.

This patch adds support for registering the custom messages types by their
function code with a delegate for determining the length of data to receive
for any particular modbus message.

Original issue reported on code.google.com by rasmus.toftdahl.olesen on 19 May 2009 at 1:56

Attachments:

Strongkey

My software uses strong name keys.  When I try to reference the Modbus dll 
I get the error - Assembly generation failed - referenced 
assembly 'Modbus' does not have a strong name.  How would you recommend 
that I resolve this?  Thank you!


Original issue reported on code.google.com by [email protected] on 19 Mar 2008 at 6:17

SlaveException class is inaccessible

In the design that we are using we have a Proxy class to hide the
implementation of the Modbus interface incase we decide to change
libraries.   When writing/reading we need to determine whether a Exception
is due to a network failure or whether it was due to a PLC error.  We would
like to capture the 'SlaveException' that is being generated but because
the class is not declared with the 'Public' keyword it is not accessible in
the calling class.


Original issue reported on code.google.com by [email protected] on 26 Apr 2007 at 3:26

ModbusDataCollection.cs ArgumentOutOfRangeException

What steps will reproduce the problem?
1. Try to set input coil 0 to true on a modbus slave instance.
2.
3.

What is the expected output? What do you see instead?
The coil should be set to true.  Instead an out of range exception is thrown.
the code should be changed to as follows in file 
ModbusDataCollection.cs line 64
"if(index == 0)" should be "if(index < 0)"

What version of the product are you using? On what operating system?


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 12 Dec 2007 at 10:23

Consistent checksum error when requesting read multiple registers

What steps will reproduce the problem?
1. Send read multiple register request
2.
3.

What is the expected output? What do you see instead?
Checksum in read multiple register request should be dependent upon the 
data being sent.  The checksum is consistently 0x0C10 regardless of the 
data being sent.

What version of the product are you using? On what operating system?
v1.8.0.0 (was also seen in 1.6.0.0).

Please provide any additional information below.
Please see attached Wireshark screenshot.

Original issue reported on code.google.com by [email protected] on 29 Sep 2008 at 7:18

Attachments:

ModbusTcpMasterReadInputs example

What steps will reproduce the problem?

1. I'm test ModbusTcpMasterReadInputs example.


What is the expected output? What do you see instead?

Console was output right results. But when program closed program fallen at
function TcpStreamAdapter.EndWrite with message 
Cannot access a disposed object.
Object name: 'System.Net.Sockets.NetworkStream'.

If I'm run debug mode, program execute without problem.


What version of the product are you using? On what operating system?
I'm used last version 1.3.0.2. WinXP.

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 28 Aug 2007 at 9:35

Enter one-line summary

What steps will reproduce the problem?
1. trying to open com port i get:   Request for the permission of 
type 'System.Security.Permissions.SecurityPermission, mscorlib, 
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
2.
3.

What is the expected output? What do you see instead?
it should open com port and connect

What version of the product are you using? On what operating system?
2 on xp

Please provide any additional information below.
Public Class Form1
    Dim mm As Modbus.Device.ModbusSerialMaster
    Dim port As New System.IO.Ports.SerialPort
    Private Sub Search_Click(ByVal sender As System.Object, ByVal e As 
System.EventArgs) Handles Search.Click
        Dim tt() As UShort
        Dim port As New System.IO.Ports.SerialPort("COM1", 9600, 
IO.Ports.Parity.None, 8, IO.Ports.StopBits.One)
        port.Open()
        mm.CreateRtu(port)
        tt = mm.ReadHoldingRegisters(Me.Address.Text, 1, 1)
        Me.TextBox1.AppendText(Chr(13) & Chr(10) & tt(0))
        port.Close()
    End Sub
End Class

Original issue reported on code.google.com by [email protected] on 2 Nov 2006 at 6:19

Wrong Transaction Id returned by ModbusTcpSlave

What steps will reproduce the problem?
1. Create a ModbusTcpSlave
2. With a Modbus Master send a ReadHoldingRegister Request to the Slave
with TransactionId = 0

What is the expected output? What do you see instead?
The ModbusTcpSlave should return a response with transactionId=0 but 
returns transactionId=1 this produces an error on the ModbusMaster.

What version of the product are you using? On what operating system?
NModbus 1.8.0.0, VS2008 C# WinXP

Please provide any additional information below.
See the Wireshark Dump in the Attachment.

Original issue reported on code.google.com by [email protected] on 9 Oct 2008 at 10:28

Attachments:

Master and Slave

What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?


Please provide any additional information below.

I would like to produce a C# application that acts as both a Master and a
Slave.  Each component would use its own Serial Port.  Would this be
possible with the NModBUS driver?

Original issue reported on code.google.com by [email protected] on 5 Sep 2006 at 11:57

nmodbus reading 32bit Holding registers

Can nmodbus read a 32bit integer or float from a holding register? my 
microcontroller supports it on all registers and it would be to expensive 
a task to change the code on the microcontroller to write longs to 
separate registers allowing me to read an upper and lower ushort and 
combine them to be a 32bit variable.

is there a way to read 32bit direct from a holding register?

Regards Clinton Storer.

Original issue reported on code.google.com by [email protected] on 19 Jul 2007 at 6:05

Exception after n ReadInputs

What steps will reproduce the problem?
1. call every 100ms master.ReadInputs(1, 99, 16);
2.
3.

What is the expected output? What do you see instead?
I expect this loop to last forever, instead after around 2000 polls I got
an exception

What version of the product are you using? On what operating system?
VC# in VS2005

Please provide any additional information below.
I see many "Thread exited" messages in console window...?
This is my output:


The thread 0xa64 has exited with code 0 (0x0).
The thread 0x16f8 has exited with code 0 (0x0).
The thread 0x7c4 has exited with code 0 (0x0).
The thread 0x1690 has exited with code 0 (0x0).
The thread 0x13d0 has exited with code 0 (0x0).
The thread 0x10d8 has exited with code 0 (0x0).
The thread 0x14e0 has exited with code 0 (0x0).
The thread 0x14dc has exited with code 0 (0x0).
The thread 0x9f0 has exited with code 0 (0x0).
The thread 0xbf8 has exited with code 0 (0x0).
The thread 0x4ac has exited with code 0 (0x0).
The thread 0xa64 has exited with code 0 (0x0).
The thread 0x1784 has exited with code 0 (0x0).
The thread 0x1618 has exited with code 0 (0x0).
The thread 0x4e0 has exited with code 0 (0x0).
The thread 0x11ec has exited with code 0 (0x0).
The thread 0x86c has exited with code 0 (0x0).
The thread 0x12e0 has exited with code 0 (0x0).
A first chance exception of type 'System.IO.IOException' occurred in Modbus.dll
   at System.IO.Ports.InternalResources.WinIOError(Int32 errorCode, String str)
   at System.IO.Ports.SerialStream.DiscardInBuffer()
   at System.IO.Ports.SerialPort.DiscardInBuffer()
   at Modbus.IO.CommPortAdapter.DiscardInBuffer()
   at Modbus.IO.ModbusSerialTransport.DiscardInBuffer()
   at Modbus.IO.ModbusSerialTransport.Write(IModbusMessage message)
   at Modbus.IO.ModbusTransport.UnicastMessage[T](IModbusMessage message)
   at Modbus.Device.ModbusMaster.ReadDiscretes(Byte functionCode, Byte
slaveAddress, UInt16 startAddress, UInt16 numberOfPoints)
   at Modbus.Device.ModbusMaster.ReadInputs(Byte slaveAddress, UInt16
startAddress, UInt16 numberOfPoints)
   at NModbusTest.Form1.timer1_Tick(Object sender, EventArgs e) in
D:\Documenti\Visual Studio
2005\Projects\NModbusTest\NModbusTest\Form1.cs:line 64
The thread 0x340 has exited with code 0 (0x0).
The thread 0x15b4 has exited with code 0 (0x0).
The thread 0xe00 has exited with code 0 (0x0).

Original issue reported on code.google.com by [email protected] on 6 Mar 2008 at 1:45

Why in the hell is everything private/internal? Legalize it, make it public!

What steps will reproduce the problem?
1. Try to write add-ons in a separate lib (ex a custom Transport that 
connects to a proprietary system for sending/receiving NModbus formatted 
data over an RS232 that is managed by another app) without touching the 
NModbus files.
2.
3.

What is the expected output? What do you see instead?
I would excpect this open source thing to be open sourced, instead most of 
the classes seem to be private? :P

What version of the product are you using? On what operating system?
The latest on WIN32

Please provide any additional information below.
No comment.

Original issue reported on code.google.com by [email protected] on 14 Jun 2007 at 3:21

InvalidOperationException on network failure

What steps will reproduce the problem?
1. All working fine --> data is retrieved from deivce, then...
2. The netowrk is disconnected (Unplug the network cable...)
3. A read attempt to the device fails --> As expected
4. The network is reconnected
5. A read attempt throughs the following exception:  
   InvalidOperationException - The operation is not allowed on non-
connected sockets.

Running Windows XP, VS2008, NModbus_net-3[1].5_1.11.0.0.

I am using ModbusIpMaster to connect and retrieve data from an modbus 
(TCP) enabled device.
This works fine, until the a network clitch ouccurs (Net work cable is 
unplugged).
The next call after the netork has been re-established throughs the 
following exception:
InvalidOperationException - The operation is not allowed on non-connected 
sockets.

Although I can catch the exception I cannot get "reconnected".

Any ideas on how to re-establish the connection?

Ocle

Original issue reported on code.google.com by [email protected] on 29 Oct 2009 at 8:58

UnicastMessage patch

Attached is a patch for the ModbusTransport UnicastMessage method.

The patch provides the following:

 * lock added to solve multi-threading issues.
 * Only retries for SlaveException when it receives SLAVE BUSY exception codes.
 * Now retries due to FormatException.

Original issue reported on code.google.com by [email protected] on 12 Jun 2008 at 11:22

Attachments:

FtdAdapter read and write timeouts are cast to byte

There is a problem with the FtdAdapter in NModbus 1.8.0 on Windows XP SP2
(.Net framework 3.5). The connection would fail if large blocks of data
were being transferred even though we had set the timeout to a large value.

We have traced this to ReadTimeout and WriteTimeout properties in
FtdUsbPort.cs.

The timeouts (_readTimeout and _writeTimeout) are defined as UINT, however
when setting the timeout via the above properties, the timeouts are cast to
(byte) so the maximum timeout was 256 milliseconds. The Get is fine.







Original issue reported on code.google.com by [email protected] on 7 Oct 2008 at 1:23

log4net logger name missleading

Suggest 

private readonly ILog _log = LogManager.GetLogger(String.Concat(typeof
(ModbusMasterTcpConnection), ".Instance" + Interlocked.Add(ref 
instanceCounter, 1)));

In ModbusMasterTcpConnection instead of old version. Not the same 
convention as the other classes.


Original issue reported on code.google.com by [email protected] on 2 Jun 2008 at 8:36

Enter one-line summary

Hello,

I would like to knows :
why object "NetworkByte" must be a length always even ?
why in MODBUS PROJECT subfunction is defined like a ushort instead of a 
byte ?

I realized a little developpement to send a query ReadDeviceIdentification 
(Function Code=Ox2B SubFunction Code=0x0E).
I had to modify the project Modbus (about subfunction and 
NetWorkBytes ) to perform the query and accept the response from MODBUS 
SERVER like (TSX ETY 5103 "ETHERNET Communication module for Schneider 
PLC").



Original issue reported on code.google.com by [email protected] on 30 Mar 2007 at 7:29

Lock required in ModbusTransport UnicastMessage<T>(IModbusMessage message)

What steps will reproduce the problem?
1. A multi-threaded application sharing a single ModbusMaster object.
2.
3.

What is the expected output? What do you see instead?
It is possible that the command requests and responses get mixed up when
multiple threads are sending messages at the same time.

What version of the product are you using? On what operating system?
Latest trunk revision 231, Visual Studio 2008, Windows XP

Please provide any additional information below.
A simple lock around the body of the UnicastMessage method is sufficient to
ensure that the ModbusTransport is locked until an entire message (request
and response) is complete.

Original issue reported on code.google.com by [email protected] on 11 Jun 2008 at 1:45

short and ushort with Modbus RTU

I am using a Trio Motion controller, connected via USB for programing and 
with serial / Modbus for data transfer to run a custom application. 

What steps will reproduce the problem?
1. try to write 38000 in a register "master.WriteSingleRegister(slaveID, 
vrID, value);"

What is the expected output? What do you see instead?
In the controller, the written value is -27536.0, it should be 38000. 

What version of the product are you using? On what operating system?
 - Windows XP SP3, with version 3.5 installed
 - My program in in C# in Visual Studio 2005
 - Modbus.dll 1.11.0.0
 - log4net.dll v1.2.10.0

Please provide any additional information below
On the trace I am doing, up to the "master.WriteSingleRegister(slaveID, 
vrID, value);", the value is in a ushort variable. I will have to install 
Visual Studio 2008 to try debugging in the Modbus.dll.

Cheers !!!


Original issue reported on code.google.com by [email protected] on 18 Jun 2009 at 8:03

TCP Serial Patch

Attached is a patch which modifies the TcpStreamAdapter to implement the
ISerialResource interface as discussed at
http://groups.google.com/group/NModbus-discuss/browse_thread/thread/4850e0db3b99
dad4

This provides the following features:
 * Ability to use RTU or ASCII over a TCP socket via the now public
TcpStreamAdapter.
 * RTU, ASCII and TCP masters now all support ISerialInterface, meaning
that the physical interface and protocol can be chosen independently
without a series of if/else checks with is or as operators.

Further suggestions:
 * Rename ISerialResource to IStreamResource
 * Remove NewLine and ReadLine() from the ISerialResource interface, and
instead implement the required functionality in the AsciiTransport class,
since this the only place where it is actually required.

Original issue reported on code.google.com by [email protected] on 12 Jun 2008 at 10:54

Attachments:

WriteCompleted function on ModbusTcpSlave.cs

What steps will reproduce the problem?
1. Close a ModbusTCPSlave after the master has ended the connection.
2.
3.

What is the expected output? What do you see instead?
ModbusTCPSlave should close gracefully.  An IOException is thrown.  The
call to _stream.EndWrite(ar) will generate an IOException if the server had
already forcibly closed the connection.  The line should probably handle
the IOException.  In any event, the code looks like this:

File: ModbusTcpSlave.cs
Lines: 179 to 193
Function: WriteCompleted
internal void WriteCompleted(IAsyncResult ar)
{
    _log.Debug("End write.");
    _stream.EndWrite(ar);

    try
    {
        _stream.BeginRead(_mbapHeader, 0, 6, ReadHeaderCompleted, null);
    }
    catch (IOException)
    {
        _log.Debug("Master has closed Socket connection.");
        RemoveMaster(_endPoint);
    }
}




What version of the product are you using? On what operating system?


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 13 Dec 2007 at 3:07

Modbus TCP seems to disregard multiple unit id's.

What steps will reproduce the problem?
1. Used latest version of .Net 2.0.  May be fixed in 3.0 version, but did 
not see an indication that it was.
2. In MySample\Driver.cs main call StartModbusTcpSlave only.
3. StartModbusTcpSlave modified in Driver.cs and DataStoreFactory.cs 
modified as in the attached files:


What is the expected output? What do you see instead?
Expect when I query holding registers of unit 2, get multiples of 7.  Get 
multiples of 3 instead.  It appears that somewhere in the request it is 
using a static definition of the slave rather than the slave specific to 
the unit.

What version of the product are you using? On what operating system?
1.4.0.3, XP/SP2

Please provide any additional information below.

Please inform me by email if I just coded this in error.  Thanks!


Original issue reported on code.google.com by [email protected] on 5 Sep 2008 at 12:33

Attachments:

Strong name dlls

I am getting the following errors.  I am running with the new strong name 
versions of the dlls.  What am I doing wrong?

log4net:ERROR DefaultRepositorySelector: Failed to configure repository 
[log4net-default-repository] from assembly attributes.
System.IO.FileNotFoundException: Could not load file or 
assembly 'System.Core, Version=3.5.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system 
cannot find the file specified.
File name: 'System.Core, Version=3.5.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089'
   at System.ModuleHandle.ResolveType(Int32 typeToken, RuntimeTypeHandle* 
typeInstArgs, Int32 typeInstCount, RuntimeTypeHandle* methodInstArgs, 
Int32 methodInstCount)
   at System.ModuleHandle.ResolveTypeHandle(Int32 typeToken, 
RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] 
methodInstantiationContext)
   at System.Reflection.Module.ResolveType(Int32 metadataToken, Type[] 
genericTypeArguments, Type[] genericMethodArguments)
   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord
(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& 
lastAptcaOkAssembly, Module decoratedModule, MetadataToken decoratedToken, 
RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] 
attributes, IList derivedAttributes, RuntimeType& attributeType, 
RuntimeMethodHandle& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
   at System.Reflection.CustomAttribute.GetCustomAttributes(Module 
decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType 
attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes)
   at System.Reflection.CustomAttribute.GetCustomAttributes(Assembly 
assembly, RuntimeType caType)
   at System.Reflection.Assembly.GetCustomAttributes(Type attributeType, 
Boolean inherit)
   at System.Attribute.GetCustomAttributes(Assembly element, Type 
attributeType, Boolean inherit)
   at log4net.Core.DefaultRepositorySelector.LoadAliases(Assembly 
assembly, ILoggerRepository repository)
   at log4net.Core.DefaultRepositorySelector.CreateRepository(Assembly 
repositoryAssembly, Type repositoryType, String repositoryName, Boolean 
readAssemblyAttributes)

Original issue reported on code.google.com by [email protected] on 25 Mar 2008 at 10:15

Error in ReadInputRegisters (SerialRTU)

During reads to the input registers when using the ModbusSerialMaster in
RTU mode, the values that come back are from the Holding registers instead.
 I have looked through the source and noticed that the ReadHoldingRegisters
is missing from the overrides in the RTU module.  However, when I attempted
to implement them, the changes didn't fix the problem.  I am too busy to
look into the solution now, but will when I have a chance.

Original issue reported on code.google.com by [email protected] on 22 Nov 2006 at 2:09

Problem performing first readings...

What steps will reproduce the problem?
1. Configure serial port
2. Try any of the reading examples from your page.

What is the expected output? What do you see instead?
I expect something into the buffer, but I get an exception:
"Array networkBytes must contain an even number of bytes."

What version of the product are you using? On what operating system?
Working on Visual Studio 2005 under Win2k


Please provide any additional information below.
Nice work! Go ahead!



Original issue reported on code.google.com by [email protected] on 5 Oct 2006 at 1:46

Unhandeled Exception

What steps will reproduce the problem?
1. just disconnecting other party


What version of the product are you using? On what operating system?
1.7 any os

Please provide any additional information below.

New suggestion to avoid unhandeled error (whitch is the whole idea of the 
method.


        internal void CatchExceptionAndRemoveMasterEndPoint(Action 
action, string endPoint)
        {
            if (action == null)
                throw new ArgumentNullException("action");
            if (endPoint == null)
                throw new ArgumentNullException
("endPoint");

            try
            {
                action.Invoke();
            }
            catch (IOException ioe)
            {
                _log.DebugFormat("IOException encountered 
in ReadHeaderCompleted - {0}", ioe.Message);
                ModbusMasterTcpConnectionClosed.IfNotNull
(e => e(EndPoint));

                SocketException socketException = 
ioe.InnerException as SocketException;
                if (socketException != null && 
socketException.ErrorCode == Modbus.ConnectionResetByPeer)
                {
                    _log.Debug("Socket Exception 
ConnectionResetByPeer, Master closed connection.");
                    return;
                }

                //throw;
            }
            catch (Exception e)
            {
                _log.Error("Unexpected exception 
encountered", e);
                //throw;
            }
        }


Original issue reported on code.google.com by [email protected] on 29 May 2008 at 9:34

FxCop

I am suggesting that the NModbus project be run through FxCop to weed out
some issues that could cause problems in an asynchronous environment.

Specific examples of problems I'm running into include:
* Types that own disposable fields should be disposable (ModbusSerialTransport)
* Rethrow to preserve stack details
(ModbusTransport.UnicastMessage<T>(IModbusMessage))
"Use the IL rethrow instruction to preserve original stack details when
re-raising a caught exception."

Original issue reported on code.google.com by [email protected] on 14 Apr 2008 at 6:09

Can't open com port

What steps will reproduce the problem?
1. trying to open com port i get:   Request for the permission of 
type 'System.Security.Permissions.SecurityPermission, mscorlib, 
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
2.
3.

What is the expected output? What do you see instead?
it should open com port and connect

What version of the product are you using? On what operating system?
2 on xp

Please provide any additional information below.
Public Class Form1
    Dim mm As Modbus.Device.ModbusSerialMaster
    Dim port As New System.IO.Ports.SerialPort
    Private Sub Search_Click(ByVal sender As System.Object, ByVal e As 
System.EventArgs) Handles Search.Click
        Dim tt() As UShort
        Dim port As New System.IO.Ports.SerialPort("COM1", 9600, 
IO.Ports.Parity.None, 8, IO.Ports.StopBits.One)
        port.Open()
        mm.CreateRtu(port)
        tt = mm.ReadHoldingRegisters(Me.Address.Text, 1, 1)
        Me.TextBox1.AppendText(Chr(13) & Chr(10) & tt(0))
        port.Close()
    End Sub
End Class

Original issue reported on code.google.com by [email protected] on 2 Nov 2006 at 6:23

User Manual

What about a user manual describing the methods one can use?

Original issue reported on code.google.com by [email protected] on 18 Mar 2009 at 9:33

Impossible to return error status response

What steps will reproduce the problem?
1. Write a DataStoreWrittenToEventHandler that throws an exception on 
erroneous input values
2. Register the event handler
3. Write erroneous input data via modbus


What is the expected output? What do you see instead?
Expected: A Response with the highest bit of the function code set

Instead the unhandled exception propagates all the way out of 
ModbusTcpSlave.

What version of the product are you using? On what operating system?
NModbus 1.8 on Windows XP professional.

Please provide any additional information below.
Exceptions from the event handlers (also ModbusSlaveRequestEventHandler 
and DataStoreReadFromEventHandler) should be caught, and the response 
function code should have the high order bit set.

Alternatively (or also), it should be possible from the event handlers to 
raise an error flag, that will cause the response to reflect that an error 
was detected, by setting the high order bit of the function code.

By the way,
thanks for NModbus, it is really easy to create the functionality we need!

Best regards,
Henrik R. Scheel
Siemens Wind Power

Original issue reported on code.google.com by [email protected] on 17 Dec 2008 at 1:46

ModbusTcpMaster ReadInputRegisters

What steps will reproduce the problem?
1. Download from HEAD
2.
3.

What is the expected output? What do you see instead?

Expected:
return base.ReadInputRegisters(Modbus.DefaultTcpSlaveUnitId, startAddress, 
numberOfPoints);

In HEAD:
return base.ReadHoldingRegisters(Modbus.DefaultTcpSlaveUnitId, 
startAddress, numberOfPoints);

What version of the product are you using? On what operating system?
HEAD

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 28 Apr 2007 at 7:26

FormatException not caught by ModbusTransport UnicastMessage

What steps will reproduce the problem?
Various methods within NModbus can throw a FormatException, most likely due
to corrupt data.

What is the expected output? What do you see instead?
The FormatException should be caught in the UnicastMessage method along
with the other exceptions: IOException, etc.

What version of the product are you using? On what operating system?
Latest trunk revision 231, Visual Studio 2008, Windows XP



Original issue reported on code.google.com by [email protected] on 11 Jun 2008 at 1:57

Linux Version

I'm using your driver on Windows and I love it. 

Could you port it to Linux/Mono?

Original issue reported on code.google.com by [email protected] on 31 Mar 2009 at 10:34

Spontaneus Exception

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 [email protected] on 6 May 2008 at 7:52

Modbus RTU slave exceptions not being correctly handled by NModbus

What steps will reproduce the problem?

1. Attempt to Read RTU from an unsupported slave address. (Or any read 
which causes a slave exception response).

2. NMOdbus will throw an exception "Function code 131 not supported".

What is the expected output? What do you see instead?

NModbus should throw a ModbusSlaveException : "Funcion code 3 Error code 2"

What version of the product are you using? On what operating system?

1.2 Beta on XP.

Please provide any additional information below.

I've tried to report this a couple of times and not been sucessful. I'm 
pretty sure it's a bug.

The problem is caused because the function ResponseBytesToRead(byte[] 
frameStart) in the class ModbusRTUTransport is throwing an exception on an 
slave error flagged response (i.e. + 0X80 higher than a normal response).

This is a valid response and would be correctly handled when passed to 
CreateResponse() in the ModbusTransport class, but the thrown exception 
means that function is never called.

Quick fix:

default:
  if (functionCode > 128)
  {
    numBytes = 1;
    break;
  }
  string errorMessage = String.Format("Function code {0} not 
supported.",   functionCode);
throw new NotImplementedException(errorMessage);

Original issue reported on code.google.com by [email protected] on 19 Jun 2007 at 10:51

Problem reading holding registers on TCP slave

<What steps will reproduce the problem?>
1. Create a test program using the "Simple Modbus TCP slave example" code
from NModbus site. Then add some test data for holding registers reading
simulation.
The resulting code is in the attached file "Main.cs".
2. After running the test program, start FieldTalk modpoll 2.4.0 utility to
read 5 holding registers starting from the first one, with the following
command line:
    modpoll -m tcp -t4 -r 1 -c 5 127.0.0.1
The project should crash.
So try to start reading from second holding register:
    modpoll -m tcp -t4 -r 2 -c 5 127.0.0.1
The result should be that test data appears shifted 1 place.

<What is the expected output? What do you see instead?>
Expected output is shown in attached file "Clipboard2.jpg".
Real output is shown in attached file "Clipboard1.jpg"

<What version of the product are you using? On what operating system?>
I used NModbus 1.1.0.1 on Windows 2k.

<Please provide any additional information below.>
The expected output has been obtained modifying lines 60 and 84 of
"DataStore.cs" from
    int startIndex = startAddress - 1;
to
    int startIndex = startAddress;
to fit the 1 place shifting when data has to be read.
I've also attached the modified "DataStore.cs" source file.

Original issue reported on code.google.com by [email protected] on 24 Jul 2007 at 4:00

Attachments:

Errors

I am getting this error: "The I/O operation has been aborted because of
either a thread exit or an application request"

What can be the issue?

http://code.google.com/images/star_on.gif
http://code.google.com/images/star_on.gif

Original issue reported on code.google.com by [email protected] on 5 Mar 2007 at 12:10

If remote TCP connection is dropped the thread reading/writing blocks causing the CPU usuage to peg at 100%

What steps will reproduce the problem?
1. Start a PLC simulator on a remote PC.
2. Start the test program locally.
3. Kill the simulator.
4. Observe the CPU usage on the PC.

What is the expected output? What do you see instead?
Read/Write function should return with an error.

What version of the product are you using? On what operating system?
WinXP / Win2000 NModBus V1.0

Please provide any additional information below.
Basically in the ReadRequestResponse() method in ModbusTcpTransport.cs the
code is not looking for '0' bytes during the return.  So it keeps in the
tight loop while not reading anything.  The '0' bytes indicates that the
pipe is closed.  Attached is our solution to fix the issue.  You will
notice that we also added several more constructors.

Original issue reported on code.google.com by [email protected] on 25 Apr 2007 at 7:37

Attachments:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.