Modbus TCP Slave ID/Unit ID

B.Botond
Posts: 6
Joined: Sun Dec 19, 2021 3:41 pm

Modbus TCP Slave ID/Unit ID

Postby B.Botond » Sun Jan 02, 2022 1:52 pm

Hi,

I am using the modbus master TCP, and I have a device which have an UintID.
I can not find any setup in the IDF library where I can configure this number.
I have a Slave ID 1 on the device, but i can not setup 0.

Can anyone help me where to configure this value? :roll:

Thank you in advance.

Best regards,
Botond

ESP_alisitsyn
Posts: 211
Joined: Fri Feb 01, 2019 4:02 pm
Contact:

Re: Modbus TCP Slave ID/Unit ID

Postby ESP_alisitsyn » Mon Jan 03, 2022 4:51 pm

Hi Botond ,

The Modbus Master TCP branch does not support RTU over TCP and sends the UID = 0 in the MBAP as per spec.
In order to address the slave with custom UID, you need to use the updated code of the Modbus library posted here (self-contained project):
https://github.com/alisitsyn/modbus_sup ... cp_support

The UID of the slave to be addressed is defined in the data dictionary (the field mb_parameter_descriptor_t::mb_slave_addr (SLAVE_UID_1, SLAVE_UID_2).

Code: Select all

const mb_parameter_descriptor_t device_parameters[] = {
    // { CID, Param Name, Units, Modbus Slave Addr (UID), Modbus Reg Type, Reg Start, Reg Size, Instance Offset, Data Type, Data Size, Parameter Options, Access Mode}
    { CID_INP_DATA_0, STR("Data_channel_0"), STR("Volts"), SLAVE_UID_1, MB_PARAM_INPUT, 0, 2,
                    INPUT_OFFSET(input_data0), PARAM_TYPE_FLOAT, 4, OPTS( -10, 10, 1 ), PAR_PERMS_READ_WRITE_TRIGGER },
    { CID_HOLD_DATA_0, STR("Humidity_1"), STR("%rH"), SLAVE_UID_2, MB_PARAM_HOLDING, 0, 2,
            HOLD_OFFSET(holding_data0), PARAM_TYPE_FLOAT, 4, OPTS( 0, 100, 1 ), PAR_PERMS_READ_WRITE_TRIGGER }
 }

The official update will be merged later.

B.Botond
Posts: 6
Joined: Sun Dec 19, 2021 3:41 pm

Re: Modbus TCP Slave ID/Unit ID

Postby B.Botond » Tue Jan 04, 2022 6:06 pm

Hi ESP_alisitsyn,

Thank you very much your answer again.I hope this will be added soon in the officially IDF release.

Best regards,
Botond

B.Botond
Posts: 6
Joined: Sun Dec 19, 2021 3:41 pm

Re: Modbus TCP Slave ID/Unit ID

Postby B.Botond » Wed Jan 05, 2022 12:14 pm

Hi ESP_alisitsyn,

I just checked the git issues, and the slave address was not listed there.

You wrote that it would be merged later, can you tell me when will go this change in the release?

Should we add to the git issue this request?
I think this is a very important feature if there is any modbus gateway, than its will be not work without slave id.

Thank you in advance.
Best regards,
Botond

ESP_alisitsyn
Posts: 211
Joined: Fri Feb 01, 2019 4:02 pm
Contact:

Re: Modbus TCP Slave ID/Unit ID

Postby ESP_alisitsyn » Tue Jan 18, 2022 11:25 am

HI Botond,

There is an issue in the ESP-IDF github project related to UID: https://github.com/espressif/esp-idf/issues/6450

The MR passed the review and final checks and ready for merge. I expect it will be possible to merge it as soon as all the CI tests are passed in the internal system. I will try to merge it ASAP! It needs some time to be automatically replicated to github then.

UPDATE:
The MR to fix setting UID in the MBAP correctly as per data dictionary has been merged into master with commit ID 2cad565781eb95ffbbe0840f801016acaca82e86 . It needs some time to sync with github.

Alexfox1103
Posts: 4
Joined: Wed Oct 25, 2023 6:31 pm

Re: Modbus TCP Slave ID/Unit ID

Postby Alexfox1103 » Wed Oct 25, 2023 6:47 pm

ESP_alisitsyn wrote:
Tue Jan 18, 2022 11:25 am
HI Botond,

There is an issue in the ESP-IDF github project related to UID: https://github.com/espressif/esp-idf/issues/6450

The MR passed the review and final checks and ready for merge. I expect it will be possible to merge it as soon as all the CI tests are passed in the internal system. I will try to merge it ASAP! It needs some time to be automatically replicated to github then.

UPDATE:
The MR to fix setting UID in the MBAP correctly as per data dictionary has been merged into master with commit ID 2cad565781eb95ffbbe0840f801016acaca82e86 . It needs some time to sync with github.
Can I do in one application create several modbus tcp slave ( for example used UID = 1, UID = 2.) How I can to do it? (I have 1 esp32, but I need have two modbus tcp slave in the esp32 ) .

ESP_alisitsyn
Posts: 211
Joined: Fri Feb 01, 2019 4:02 pm
Contact:

Re: Modbus TCP Slave ID/Unit ID

Postby ESP_alisitsyn » Thu Oct 26, 2023 6:58 am

Can I do in one application create several modbus tcp slave ( for example used UID = 1, UID = 2.) How I can to do it? (I have 1 esp32, but I need have two modbus tcp slave in the esp32 ) .
The current version of stack esp-modbus v1.0.x does not support this. It is possible to create one instance of each type (master, slave) in one application. The stack v2.0.x is in development and will support creation of multiple instances in one application. Once completed the stack will be published and described on public channels.

Alexfox1103
Posts: 4
Joined: Wed Oct 25, 2023 6:31 pm

Re: Modbus TCP Slave ID/Unit ID

Postby Alexfox1103 » Mon Nov 13, 2023 12:28 pm

ESP_alisitsyn wrote:
Thu Oct 26, 2023 6:58 am
Can I do in one application create several modbus tcp slave ( for example used UID = 1, UID = 2.) How I can to do it? (I have 1 esp32, but I need have two modbus tcp slave in the esp32 ) .
The current version of stack esp-modbus v1.0.x does not support this. It is possible to create one instance of each type (master, slave) in one application. The stack v2.0.x is in development and will support creation of multiple instances in one application. Once completed the stack will be published and described on public channels.
Thanks for the reply. And when is the release of version 2 expected?

ESP_alisitsyn
Posts: 211
Joined: Fri Feb 01, 2019 4:02 pm
Contact:

Re: Modbus TCP Slave ID/Unit ID

Postby ESP_alisitsyn » Mon Nov 13, 2023 2:05 pm

The first release is expected right after completion of testing stage. Some date after start of new year.

Alexfox1103
Posts: 4
Joined: Wed Oct 25, 2023 6:31 pm

Re: Modbus TCP Slave ID/Unit ID

Postby Alexfox1103 » Sat Feb 24, 2024 8:10 pm

ESP_alisitsyn wrote:
Mon Nov 13, 2023 2:05 pm
The first release is expected right after completion of testing stage. Some date after start of new year.
Hi, what about release 2.0? Can I take for used?

Who is online

Users browsing this forum: No registered users and 70 guests