Hi,
if you mean slave-id, you need to use
modbus_set_slave(ctx, <ID>);
on an open context before reading or writing.
--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "libmodbus".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse libmodbus+...@googlegroups.com.
Cette discussion peut être lue sur le Web à l'adresse https://groups.google.com/d/msgid/libmodbus/e8ce183a-dd52-47a3-8d8a-595d67776666%40googlegroups.com.
I don't know if I understand well your question but I will explain the two possible scenarios:1. you want to read three input registers of a device with slave id = SLAVE_ID.
- set the slave id of your context by using modbus_set_slave(ctx, <SLAVE_ID>) just once
- Use modbus_read_input_registers to read the three input registers you want to read
2. you want to read an input register called slave_id, actualy containing the id of the device, for three different devices.
- set the slave id of your context by using modbus_set_slave(ctx, <SLAVE_ID_first_device>)
- Use modbus_read_input_registers to read the input register you want to read
- Repeat both steps above for the rest of the devices
cheers,
UT_REGISTERS_ADDRESS
On Wed, Jun 3, 2020 at 1:03 PM Linux programmer <jupit...@gmail.com> wrote:
--
On Wednesday, June 3, 2020 at 5:42:30 PM UTC+10, Patrick Boettcher wrote:Hi,
if you mean slave-id, you need to use
modbus_set_slave(ctx, <ID>);
on an open context before reading or writing.Correct, slave-id, so if I need to read 3 slave_id input registers, I need to call modbus_set_slave(ctx, <ID>) three times before calling modbus_read_input_registers, right?Thank you.
HTH,
--
Patrick.
On Tue, 2 Jun 2020 17:36:27 -0700 (PDT)
Linux programmer <jupit...@gmail.com> wrote:
> Hi,
>
> None of read register functions have an argument for RS485 ID for
> Daisy-Chain topology communication, how can I read / request
> registers from one particular RS485 ID?
>
> Thank you.
>
> Kind regards,
>
> - j
>
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "libmodbus".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse libm...@googlegroups.com.
Cette discussion peut être lue sur le Web à l'adresse https://groups.google.com/d/msgid/libmodbus/e8ce183a-dd52-47a3-8d8a-595d67776666%40googlegroups.com.
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse libmodbus+...@googlegroups.com.
Cette discussion peut être lue sur le Web à l'adresse https://groups.google.com/d/msgid/libmodbus/11d73d34-5db5-4f0a-978d-fbb523ea71f5o%40googlegroups.com.
If you think about it, the slaves can’t reply to a broadcast. The MODBUS protocol is master-slave only.
How do all the slaves reply to the broadcast at the same time? They would need much more smarts than the protocol provides. They would need some kind of collision avoidance.
Furthermore, the master would need to know where these unsolicited replies are coming from.
What I have seen a broadcast used for is to tell all slaves to capture a reading value, or multiple values, at the same point in time and save the captured values to a register. Then the master requests the captured value from the register at a later time using the standard master-slave protocol.
Cette discussion peut être lue sur le Web à l'adresse https://groups.google.com/d/msgid/libmodbus/CANQtGUarYYK_2Da46Pfu%3DsvbphBXTgYB%3DUJJC9j5hSbp0msijA%40mail.gmail.com.
If you think about it, the slaves can’t reply to a broadcast. The MODBUS protocol is master-slave only.
Cette discussion peut être lue sur le Web à l'adresse https://groups.google.com/d/msgid/libmodbus/11d73d34-5db5-4f0a-978d-fbb523ea71f5o%40googlegroups.com.
--Andrés Felipe Villamil
Ingénieur Institut Mines Nantes Atlantique
(Ex. Écoles des Mines de Nantes)
--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "libmodbus".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse libm...@googlegroups.com.
Cette discussion peut être lue sur le Web à l'adresse https://groups.google.com/d/msgid/libmodbus/CANQtGUarYYK_2Da46Pfu%3DsvbphBXTgYB%3DUJJC9j5hSbp0msijA%40mail.gmail.com.
The master needs to know the address’ for all the slaves. Normally this is configured into the master at commissioning time by the technician.
The other way is you can run a routine to check each MODBUS address (1-255) for an active slave device. You can reduce this number by restricting the slave address range.
Frequently though this is not a preferred method though because it takes time. You need to send a poll out and wait for the slave to respond, or not, before moving on to the next possible device address. The other issue is how do you know who is responding to address 23 for example? And if you know who is at address 23, you are back to the master knowing all devices on the network.
Somebody has to configure all the slaves with a unique address. It does not do much good to put the address into a MODBUS register on the slave because you cant read the address unless you know the address!!
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse libmodbus+...@googlegroups.com.
Cette discussion peut être lue sur le Web à l'adresse https://groups.google.com/d/msgid/libmodbus/7d94d763-aad1-4910-b81d-98c23b4fd375o%40googlegroups.com.
The master needs to know the address’ for all the slaves. Normally this is configured into the master at commissioning time by the technician.
The other way is you can run a routine to check each MODBUS address (1-255) for an active slave device. You can reduce this number by restricting the slave address range.
Frequently though this is not a preferred method though because it takes time. You need to send a poll out and wait for the slave to respond, or not, before moving on to the next possible device address. The other issue is how do you know who is responding to address 23 for example? And if you know who is at address 23, you are back to the master knowing all devices on the network.
Somebody has to configure all the slaves with a unique address. It does not do much good to put the address into a MODBUS register on the slave because you cant read the address unless you know the address!!