• 大小: 88KB
    文件类型: .7z
    金币: 1
    下载: 0 次
    发布日期: 2021-06-06
  • 语言: 其他
  • 标签: can  uds  servier  

资源简介

can总线UDS非常棒的例子,希望对can 开发的有帮助,网络诊断学习神器.

资源截图

代码片段和文件信息

/***************************************************************************//**
    \file          uds-net.c
    \author        huanghai
    \mail          huanghai@auto-link.com
    \version       0.03 - CANoe Passed
    \date          2016-09-24
    \description   uds network code base on ISO 15765
*******************************************************************************/
#include “network_layer_private.h“
#include “network_layer.h“
#include “can.h“
/*******************************************************************************
    Type Definition
*******************************************************************************/

/*******************************************************************************
    Global Varaibles
*******************************************************************************/
static network_layer_st nwl_st = NWL_IDLE;

static bool_t g_wait_cf = FALSE;
static bool_t g_wait_fc = FALSE;

static uint32_t nt_timer[TIMER_CNT] = {0};

static uint8_t g_rfc_stmin = 0;    /* received flowcontrol SeparationTime */
static uint8_t g_rfc_bs = 0;       /* received flowcontrol block size */

static uint8_t g_xcf_bc = 0;       /* transmit consecutive frame block counter */
static uint8_t g_xcf_sn = 0;       /* transmit consecutive frame SequenceNumber */
static uint8_t g_rcf_bc = 0;       /* received frame block counter */
static uint8_t g_rcf_sn = 0;       /* received consecutive frame SequenceNumber */

/* transmit buffer */
static uint8_t remain_buf[UDS_FF_DL_MAX];
static uint16_t remain_len = 0;
static uint16_t remain_pos = 0;

/* recieve buffer */
static uint8_t recv_buf[UDS_FF_DL_MAX];
static uint16_t recv_len = 0;
static uint16_t recv_fdl = 0;  /* frame data len */


OS_EVENT *UdsMutex;
/*******************************************************************************
    external Varaibles
*******************************************************************************/
uint8_t g_tatype;
/*******************************************************************************
    Function  declaration
*******************************************************************************/
static void
send_flowcontrol (uint8_t flow_st);

typedef void
ffindication_default (uint16_t msg_dlc);
typedef void
indication_default (uint8_t msg_buf[] uint16_t msg_dlc n_result_t n_result);
typedef void
confirm_default (n_result_t n_result);
//static indication_func uds_indication = NULL;
//static confirm_func uds_confirm = NULL;

static nt_usdata_t N_USData = {ffindication_default ndication_default confirm_default};
/*******************************************************************************
    Function  Definition - common
*******************************************************************************/

/**
 * nt_timer_start - start network timer
 *
 * void :
 *
 * returns:
 *     void
 */
static void
nt_timer_start (uint8_t num)
{
if (num >= TIMER_CNT) r

评论

共有 条评论