-
-
Notifications
You must be signed in to change notification settings - Fork 32
Suggestion on how to read from two Slaves at the same time #8
Comments
ModbusTCP is TCP based. It creates a separate connection to each slave. So yes, you'll need to have 2 class instances. (contrary to ModbusRTU where all slaves share the same bus). Progress on this lib has stalled as I don't have any live modbus equipment anymore. I'm very busy the coming weeks but I can take a deeper look into the problem in 2 weeks or so. |
While i agree with what you have written, in my case the smart meter is RTU to the inverter which then converts the information on TCP with a different ID. This means that potentially only one TCP might be enough (to the inverter) as long as the payload of a given message carries the wanted ID. Am i wrong? |
I want to also add that maybe in the code below
we might have a race condition with the variabile _lastPacketId since it is a static class variable. |
In order to have a single class/queue i've added the following method
then i use something like
where _serverID_Meter is passed in the constructor in the same way as _server_ID. |
I see, your TCP meter acts as a modbus gateway. Maybe create an overloaded method with the extra argument? The race condition is real, so has to be fixed. |
Hello,
i have an inverter (fronius) and a smart meter.
The smart meter itself is read through the inverter with no problem.
Sometimes, though, i have a AsyncTCP kernel panic fault (i assume it is from Async lib)
My "read" function is the following
the onData() and onError() definition are inside the class init and are something like this
Do you believe that calling them sequentially like that can be the reason i have these crashes?
I will soon provide you an example of a crash
Moreover in the initialization list of my main class i have the following
is there a simpler way in order to avoid declaring two "esp32ModbusTCP" and only using one that can access two slave ids?
Can i extend the API of
to take in also the different _serverID ? But how do i change the callback in order to understand which ID the information is from?
The text was updated successfully, but these errors were encountered: