Skip to content

Conversation

@demiurg-spb
Copy link

@demiurg-spb demiurg-spb commented Feb 25, 2020

Add new API function
int modbus_send_generic_request(modbus_t *ctx, const uint8_t *raw_req, int raw_req_length, int wanted_resp_data_length);
to enable the implementation of user-defined modbus functions (by standard in the range 65...72 and 100...110) with a predetermined number of requested bytes.
wanted_resp_data_length is number of data bytes between the function code and the checksum
(address, function, data[wanted_resp_data_length], crc).

@karlp
Copy link
Contributor

karlp commented Feb 25, 2020

I believe #140 would be a better solution to this problem, (and also solves many more)

@demiurg-spb
Copy link
Author

demiurg-spb commented Feb 25, 2020

Maybe so, but one does not interfere with the other. And it can be implemented in the code base at the same time.
If you look carefully, this commit does not change the initial behavior of the library, making only an additional wrapper over the function
int modbus_send_raw_request (modbus_t * ctx, const uint8_t * raw_req, int raw_req_length);

@demiurg-spb
Copy link
Author

demiurg-spb commented Feb 26, 2020

PS: Callbacks are convenient to use when you need to do something non-trivial. In your link #140 I see an implicit link to the size of the data. In my opinion, my solution is simple, convenient to use and very intelligible (solving a specific problem).
Custom user's functions are a typical part of the modbus protocol, which should be easily and intelligibly implemented. Which I suggest.
Callbacks are also a useful feature, but absolutely not related to the implementation of simple user-defined functions indicated by the STANDARD in the SPECIFIC range.

@demiurg-spb
Copy link
Author

mazi thanx!
I fixed typos and comment style

@gbetous-swir
Copy link

I would need this improvement to implement user defined functions. What is missing for merging it ?

@demiurg-spb
Copy link
Author

I've been asking the same question for a few years now.... (

@stephane stephane self-assigned this Dec 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants