@@ -773,22 +773,21 @@ static int response_exception(modbus_t *ctx,
773
773
return rsp_length ;
774
774
}
775
775
776
- /* Send a response to the received request.
777
- Analyses the request and constructs a response.
776
+ /* Analyses the request and constructs a response.
778
777
779
- If an error occurs, this function construct the response
778
+ If an error occurs, this function constructs the response
780
779
accordingly.
781
780
*/
782
- int modbus_reply (modbus_t * ctx ,
783
- const uint8_t * req ,
784
- int req_length ,
785
- modbus_mapping_t * mb_mapping )
781
+ int modbus_reply_construct (modbus_t * ctx ,
782
+ const uint8_t * req ,
783
+ int req_length ,
784
+ modbus_mapping_t * mb_mapping ,
785
+ uint8_t * rsp )
786
786
{
787
787
unsigned int offset ;
788
788
int slave ;
789
789
int function ;
790
790
uint16_t address ;
791
- uint8_t rsp [MAX_MESSAGE_LENGTH ];
792
791
int rsp_length = 0 ;
793
792
sft_t sft ;
794
793
@@ -1189,6 +1188,29 @@ int modbus_reply(modbus_t *ctx,
1189
1188
!(ctx -> quirks & MODBUS_QUIRK_REPLY_TO_BROADCAST )) {
1190
1189
return 0 ;
1191
1190
}
1191
+ return rsp_length ;
1192
+ }
1193
+
1194
+ int modbus_reply_send (modbus_t * ctx , uint8_t * rsp , int rsp_length )
1195
+ {
1196
+ return send_msg (ctx , rsp , rsp_length );
1197
+ }
1198
+
1199
+ /* Send a response to the received request.
1200
+ Analyses the request and constructs a response.
1201
+
1202
+ If an error occurs, this function construct the response
1203
+ accordingly.
1204
+ */
1205
+ int modbus_reply (modbus_t * ctx ,
1206
+ const uint8_t * req ,
1207
+ int req_length ,
1208
+ modbus_mapping_t * mb_mapping )
1209
+ {
1210
+ uint8_t rsp [MAX_MESSAGE_LENGTH ];
1211
+ int rsp_length ;
1212
+
1213
+ rsp_length = modbus_reply_construct (ctx , req , req_length , mb_mapping , rsp );
1192
1214
return send_msg (ctx , rsp , rsp_length );
1193
1215
}
1194
1216
0 commit comments