You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Checked the issue tracker for similar issues to ensure this is not a duplicate.
Described the feature in detail and justified the reason for the request.
Provided specific use cases and examples.
Feature description
Add a way to write data to modbus slaves using arbitrary function codes. It could have an interface similar to eMBMasterReqWriteMultipleHoldingRegister but without the hardcoded function code.
Use cases
I need to upgrade the firmware of a modbus device and it uses function codes 0x13 and 0x14 to download and upgrade firmware respectively. These function codes are not supported today and i cannot find a way to send in custom function codes.
Alternatives
No response
Additional context
I dont know if these function codes are established function codes for this purpose or if it is specific to the device im working with.
The text was updated successfully, but these errors were encountered:
Thanks you for the issue. Unfortunately, I can not add support of huge list of all Modbus commands into this stack.
Add a way to write data to modbus slaves using arbitrary function codes. It could have an interface similar to eMBMasterReqWriteMultipleHoldingRegister but without the hardcoded function code.
The functions 0x13 and 0x14 included in the Modbus specification but are in the reserved list of commands (not standard). The support of custom commands and its handlers is not provided for now but this request is already added into feature list to implement. However, it is possible to do workaround in your application code to support your new commands without any changes in the stack code: There is the function mbc_master_send_request(), the api description which allows to send custom request to any slave. However, it requires to have also the specific function handler. There is a way to handle response from slave to your custom command using the [custom user handler function] (https://docs.espressif.com/projects/esp-modbus/en/latest/esp32/master_api_overview.html#id5) in your application. This function is executed by stack right before return from mbc_master_set_parameter() or mbc_master_get_parameter() functions. This user handler can allow you to get the command send/receive buffer for each transaction. For your new functions the parameter (err_type = EV_ERROR_EXECUTE_FUNCTION) because the handler will not be found in the standard function table. So, it is possible to implement your own custom function handler for the functionality to support the functions 0x13, 0x14. Note: the custom handler should not blocked for a long time, so it is better to send the required buffers to the file handling task using the queues, then return from the handler function ASAP. It is responsibility of your application to handle the command properly.
I think this approach could work for you.
~~Please investigate the above and let me know if this can work for you. ~~
UPDATE: I think the above will not be possible due to limitation of mbc_master_send_request() function and the mb_param_request_t. This can not be used to make the custom request for 0x13, 0x14. So, the possible way is to add the support for these custom commands. the way to override sources of the component
Checklist
Feature description
Add a way to write data to modbus slaves using arbitrary function codes. It could have an interface similar to eMBMasterReqWriteMultipleHoldingRegister but without the hardcoded function code.
Use cases
I need to upgrade the firmware of a modbus device and it uses function codes 0x13 and 0x14 to download and upgrade firmware respectively. These function codes are not supported today and i cannot find a way to send in custom function codes.
Alternatives
No response
Additional context
I dont know if these function codes are established function codes for this purpose or if it is specific to the device im working with.
The text was updated successfully, but these errors were encountered: