Hi, I've new but been listening to this conversation, this issue always pops up when setting up Modbus communications.
I would vote for the API using the modbus register 400001, 000001, etc.. The translation between modbus registers and the address in the PLC/simulator is handled within the device. if ModbusPal maps modbus registers to the address below it so be it (Although this should be consistent when reading/writing Modbus registers). Schnieder maps Modbus registers to internal registers 400001 -> %MW1 (I think schneider M340 and M580 PLCs have an option to map Modbus registers to PLC addresses starting at 0), Rockwell maps them to data files 400001 - > N1:1. Kind Regards, Ben On Wed, Jul 15, 2020 at 6:11 AM Christofer Dutz <christofer.d...@c-ware.de> wrote: > Hmmm ... > > Regarding: 10012 being a coil and 4xxxx a register. > > Well the coils and registers are completely different things ... They are > accessed via completely different requests. > That might be some sort of convenience convention, but I wouldn't call > that a standard (I've actually never seen it before) > Would you then just subtract 40000 from every register or would you just > configure registers starting with numbers 40000? > > What do the others think? The address format does reference registers ... > should we be doing the translation? > > I guess that the general use-case would be that someone has a look at his > Modbus config and says that he wants "Register X" > and not "The Register Y references" (which seems to be one less) ... I > might even swing my vote in favor to using register numbers instead of > addresses. > > But then I ask myself: How can I address register 0 in ModbusPal ... that > would require an address that's impossible to send. > > Chris > > > Am 15.07.20, 11:51 schrieb "Niclas Hedhman" <nic...@hedhman.org>: > > Personall, I prefer that Register Numbers are used in APIs and that the > address is only seen if you analyze the over-the-wire format, but maybe > that is just me. A big reason for this is that any interface presented > to > an operator would need to use RegNumbers, as most (possibly all) > documentation of equipment has RegNumbers and some are lacking the > addresses. It is also common that the register type is part of the > Register > Number, such as 10012, where the first 1 indicates "coil" (IIRC). and > holding registers are in 4xxxx. Ideally(!), this is also handled by the > register/address parser. > > Niclas > > On Wed, Jul 15, 2020 at 5:43 PM Christofer Dutz < > christofer.d...@c-ware.de> > wrote: > > > Hmm .. so are we doing it correctly? > > > > I mean Wireshark isn't the ideal reference here as I have several > valid > > packets in the KNX space, where WireShark just says "corrupt > package". > > > > So if you enter an "holding-register:42" address it tries to read the > > register number 43 in ModbusPAL. > > > > I guess as we are reading an "address" we are correct and probably as > > ModusPAL says register number, that might be correct too? > > > > Chris > > > > > > Am 15.07.20, 10:54 schrieb "Niclas Hedhman" <nic...@hedhman.org>: > > > > The issue with 1-offset is that the "Register Number" found in > > documentation is at an "Address" one position less. So Reg 41 has > > Address > > 40. Som libraries expect Register Numbers and some expect > Register > > Address. > > And every so often, one mixes that up. > > > > On Wed, Jul 15, 2020 at 2:53 PM Christofer Dutz < > > christofer.d...@c-ware.de> > > wrote: > > > > > .... > > > > > > While looking for more Infos I found out I once wrote a > tutorial > > page for > > > PLC4X __ > > > > > > https://plc4x.apache.org/users/plc4j/virtual-modbus.html > > > > > > I so totally hate searching the web and getting my answers > answered > > by > > > myself. > > > > > > Chris > > > > > > Am 15.07.20, 08:31 schrieb "Christofer Dutz" < > > christofer.d...@c-ware.de>: > > > > > > Hi Niclas, > > > > > > when preparing a workshop for the Building IoT we were > looking > > for > > > something where you could simulate a Modbus Slave. > > > Most of these were Windows only solutions, so ModbusPAL > was one > > of the > > > very few solutions that were pure-java. > > > > > > Don't quite understand what the thing with the offset is > however > > ... > > > should be easy to fix ... I mean if I say address 42 in PLC4X, > > Wireshark > > > says 42, but in Modbus Pal I think it has to be 43 ... don't > quite > > get it. > > > > > > Chris > > > > > > > > > > > > Am 15.07.20, 03:54 schrieb "Niclas Hedhman" < > nic...@hedhman.org > > >: > > > > > > What is ModbusPAL? > > > > > > The 1-offset in Modbus has caused a lot of confusion > over the > > > years. > > > > > > On Tue, Jul 14, 2020 at 11:03 PM Christofer Dutz < > > > christofer.d...@c-ware.de> > > > wrote: > > > > > > > Sorry for the noise ... > > > > > > > > this was a false positive ... the driver was doing > things > > > correctly. > > > > It seems the ModbusPAL was just off by one ;-) > > > > > > > > Chris > > > > > > > > > > > > > > > > Am 14.07.20, 15:51 schrieb "Christofer Dutz (Jira)" < > > > j...@apache.org>: > > > > > > > > Christofer Dutz created PLC4X-214: > > > > ------------------------------------- > > > > > > > > Summary: [Modbus] Holding register > > addresses > > > have an > > > > offset of 1 (Not reading the correct address) > > > > Key: PLC4X-214 > > > > URL: > > > https://issues.apache.org/jira/browse/PLC4X-214 > > > > Project: Apache PLC4X > > > > Issue Type: Bug > > > > Components: Driver-Modbus > > > > Affects Versions: 0.7.0 > > > > Reporter: Christofer Dutz > > > > Assignee: Christofer Dutz > > > > Fix For: 0.8.0 > > > > > > > > > > > > If I set holding the following holding registers > to: > > > > > > > > 1000: 41 > > > > 1001: 42 > > > > 1002: 43 > > > > > > > > And then read: holding-register:1001 ... I get > the > > value 43 > > > returned. > > > > > > > > > > > > > > > > -- > > > > This message was sent by Atlassian Jira > > > > (v8.3.4#803005) > > > > > > > > > > > > > > > > > > > > > > >