Modbus TCP Slave ID/Unit ID
Modbus TCP Slave ID/Unit ID
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?
Thank you in advance.
Best regards,
Botond
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?
Thank you in advance.
Best regards,
Botond
-
- Posts: 211
- Joined: Fri Feb 01, 2019 4:02 pm
- Contact:
Re: Modbus TCP Slave ID/Unit ID
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).
The official update will be merged later.
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 }
}
Re: Modbus TCP Slave ID/Unit ID
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
Thank you very much your answer again.I hope this will be added soon in the officially IDF release.
Best regards,
Botond
Re: Modbus TCP Slave ID/Unit ID
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
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
-
- Posts: 211
- Joined: Fri Feb 01, 2019 4:02 pm
- Contact:
Re: Modbus TCP Slave ID/Unit ID
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.
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.
-
- Posts: 4
- Joined: Wed Oct 25, 2023 6:31 pm
Re: Modbus TCP Slave ID/Unit ID
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 wrote: ↑Tue Jan 18, 2022 11:25 amHI 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.
-
- Posts: 211
- Joined: Fri Feb 01, 2019 4:02 pm
- Contact:
Re: Modbus TCP Slave ID/Unit ID
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.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 ) .
-
- Posts: 4
- Joined: Wed Oct 25, 2023 6:31 pm
Re: Modbus TCP Slave ID/Unit ID
Thanks for the reply. And when is the release of version 2 expected?ESP_alisitsyn wrote: ↑Thu Oct 26, 2023 6:58 amThe 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.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 ) .
-
- Posts: 211
- Joined: Fri Feb 01, 2019 4:02 pm
- Contact:
Re: Modbus TCP Slave ID/Unit ID
The first release is expected right after completion of testing stage. Some date after start of new year.
-
- Posts: 4
- Joined: Wed Oct 25, 2023 6:31 pm
Re: Modbus TCP Slave ID/Unit ID
Hi, what about release 2.0? Can I take for used?ESP_alisitsyn wrote: ↑Mon Nov 13, 2023 2:05 pmThe first release is expected right after completion of testing stage. Some date after start of new year.
Who is online
Users browsing this forum: No registered users and 120 guests