@@ -213,6 +213,34 @@ esp_err_t esp_isotp_send(esp_isotp_handle_t handle, const uint8_t *data, uint32_
213
213
}
214
214
}
215
215
216
+ esp_err_t esp_isotp_send_with_id (esp_isotp_handle_t handle , uint32_t id , const uint8_t * data , uint32_t size )
217
+ {
218
+ ESP_RETURN_ON_FALSE (handle && data && size , ESP_ERR_INVALID_ARG , TAG , "Invalid parameters" );
219
+
220
+ // Validate ID range based on configured format
221
+ uint32_t mask = handle -> use_extended_id ? TWAI_EXT_ID_MASK : TWAI_STD_ID_MASK ;
222
+ ESP_RETURN_ON_FALSE ((id & ~mask ) == 0 , ESP_ERR_INVALID_ARG , TAG , "ID exceeds mask for selected format" );
223
+
224
+ int ret = isotp_send_with_id (& handle -> link , id , data , size );
225
+ switch (ret ) {
226
+ case ISOTP_RET_OK :
227
+ return ESP_OK ;
228
+ case ISOTP_RET_INPROGRESS :
229
+ return ESP_ERR_NOT_FINISHED ;
230
+ case ISOTP_RET_OVERFLOW :
231
+ case ISOTP_RET_NOSPACE :
232
+ return ESP_ERR_NO_MEM ;
233
+ case ISOTP_RET_LENGTH :
234
+ return ESP_ERR_INVALID_SIZE ;
235
+ case ISOTP_RET_TIMEOUT :
236
+ return ESP_ERR_TIMEOUT ;
237
+ case ISOTP_RET_ERROR :
238
+ default :
239
+ ESP_LOGE (TAG , "ISO-TP send with ID failed with error code: %d" , ret );
240
+ return ESP_FAIL ;
241
+ }
242
+ }
243
+
216
244
esp_err_t esp_isotp_receive (esp_isotp_handle_t handle , uint8_t * data , uint32_t size , uint32_t * received_size )
217
245
{
218
246
ESP_RETURN_ON_FALSE (handle && data && size && received_size , ESP_ERR_INVALID_ARG , TAG , "Invalid parameters" );
0 commit comments