tiagocoutinho / modbus-proxy

Connect multiple clients to modbus devices
Other
71 stars 13 forks source link

Question: Forwarding slave to another with different indices #25

Closed Gert-dev closed 5 months ago

Gert-dev commented 1 year ago

Hi

I'm wondering if it is possible to forward one slave index to another, or - in other words - to change its index? For example: ModBus server foo.com:502 has a slave on index 0, and I would like to proxy it, but forward slave 1 to foo.com:502 slave 0 instead of 0 to 0 or 1 to 1.

The reason I'm asking this is because some MODBUS/TCP servers, such as the Huawei SUN-2000L, have their slave on index 0, which - if I understood correctly - is not meant to be used as actual slave index. As a result, some software (e.g. Loxone's MODBUS support) refuses to read from it and requires a minimum slave index of 1. Meanwhile, tools such as qModMaster work fine with slave index 0 to read the necessary data. Having this support would allow me to work around this problem with quirky MODBUS implementations, and link both.

Thanks!

tiagocoutinho commented 1 year ago

Hi, So far we only support modbus TCP protocol. So when you say "slave index" are you talking about the "Unit identifier" ?

Assuming you are the answer is no. We do not tampering with any part of the Modbus TCP frame.

I do think it is an interesting feature so if anyone is willing it I would be honored to code review a PR.

Gert-dev commented 1 year ago

So far we only support modbus TCP protocol. So when you say "slave index" are you talking about the "Unit identifier" ?

Yes, I think that is indeed it, e.g. what is 253 here:

image

(I got confused because there seems to be a bug on qModMaster where if you had it on "TCP" before, on startup it will still say "Slave Address" as is the case for RTU; it fixes itself when you go back and forth.)

I do think it is an interesting feature so if anyone is willing it I would be honored to code review a PR.

:+1: I can't make any promises, but I might take a whack at this at some point. I'm also investigating alternative solutions simultaneously (i.e. getting Loxone/Huawei to fix their stuff in my case), but I'm pessimistic either will do so.