File isotp_user.c¶
File List > examples > python_api > src > isotp_user.c
Go to the documentation of this file
/*
*******************************************************************************
* ISO-TP-C: ISO 15765-2 Protocol Implementation
*
* Project: ISO-TP-C - Embedded-Grade Refactoring & Optimization
* Description: User hooks for the ISO-TP core used by the Python API example.
*
* Author: Anton Vynohradov
* Email: avynohradov@systemfromscratch.com
*
* License: MIT License
*
* Copyright (c) 2026 Anton Vynohradov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* SPDX-License-Identifier: MIT
******************************************************************************/
/* ============================================================================
* INCLUDES
* ==========================================================================*/
#include "isotp.h"
#include "can_driver.h"
#include "mock_time.h"
#include <stdarg.h>
#include <stdio.h>
/* ============================================================================
* PUBLIC FUNCTION IMPLEMENTATIONS
* ==========================================================================*/
void isotp_user_debug(const char* message, ...)
{
va_list args;
va_start(args, message);
vfprintf(stderr, message, args);
va_end(args);
}
int isotp_user_send_can(const uint32_t arbitration_id, const uint8_t* data, const uint8_t size
#ifdef ISO_TP_USER_SEND_CAN_ARG
,
void* arg
#endif
)
{
#ifdef ISO_TP_USER_SEND_CAN_ARG
(void) arg;
#endif
int ret = can_send(arbitration_id, data, size);
if (ret == 0)
{
return ISOTP_RET_OK;
}
return ISOTP_RET_NOSPACE;
}
uint32_t isotp_user_get_us(void)
{
return mock_time_now();
}