|
@@ -38,12 +38,27 @@ static void on_error(n_rslt err_type)
|
|
|
|
|
|
|
|
static uint8_t send_frame_via_can(cbus_id_type id_type, uint32_t id, cbus_fr_format fr_fmt, uint8_t dlc, uint8_t *dt)
|
|
static uint8_t send_frame_via_can(cbus_id_type id_type, uint32_t id, cbus_fr_format fr_fmt, uint8_t dlc, uint8_t *dt)
|
|
|
{
|
|
{
|
|
|
- //暂时没看到啥用处.
|
|
|
|
|
|
|
+ //将数据通过can发送至对端设备.
|
|
|
|
|
+ uint8_t can_id_type = 0;
|
|
|
|
|
+ uint32_t can_id = 0;
|
|
|
|
|
+ uint8_t payload_len = 0;
|
|
|
|
|
+ uint8_t payload[8] = {0};
|
|
|
|
|
+ uint8_t ret = 0;
|
|
|
|
|
+
|
|
|
|
|
+ can_id_type = id_type;
|
|
|
|
|
+ can_id = id;
|
|
|
|
|
+ payload_len = dlc>8?8:dlc;
|
|
|
|
|
+ memset(payload, 0, 8);
|
|
|
|
|
+ memcpy(payload, dt, payload_len);
|
|
|
|
|
+ DLOG_I("send can data:%d,data:%d", payload_len, SYS_Hex2str(payload, payload_len));
|
|
|
|
|
+
|
|
|
|
|
+ ret = HAL_CanTxData(can_id_type, can_id, payload, payload_len);
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void parse_finish_callback(n_indn_t *info)
|
|
static void parse_finish_callback(n_indn_t *info)
|
|
|
{
|
|
{
|
|
|
|
|
+ DLOG_I("parse finish");
|
|
|
if(0 == info->rslt)
|
|
if(0 == info->rslt)
|
|
|
{
|
|
{
|
|
|
DLOG_I("parse success.rslt:0x%x,frame_id:0x%x,msg_sz:0x%x,data:",
|
|
DLOG_I("parse success.rslt:0x%x,frame_id:0x%x,msg_sz:0x%x,data:",
|
|
@@ -65,6 +80,18 @@ static void parse_finish_callback(n_indn_t *info)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+static n_req_t g_s_can_frame =
|
|
|
|
|
+{
|
|
|
|
|
+ .n_ai.n_pr = 0x06,
|
|
|
|
|
+ .n_ai.n_sa = 0x12,
|
|
|
|
|
+ .n_ai.n_ta = 0xdf,
|
|
|
|
|
+ .n_ai.n_ae = 0x00,
|
|
|
|
|
+ .n_ai.n_tt = N_TA_T_PHY,
|
|
|
|
|
+ .fr_fmt = CBUS_FR_FRM_STD,
|
|
|
|
|
+ .msg = {0x22, 0xf1, 0x01, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09},
|
|
|
|
|
+ .msg_sz = 0x0d,
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
static iso15765_t handler0 =
|
|
static iso15765_t handler0 =
|
|
|
{
|
|
{
|
|
|
.addr_md = N_ADM_BMW,
|
|
.addr_md = N_ADM_BMW,
|
|
@@ -185,6 +212,33 @@ void MOD_CanPutDataToIso15765Parse(uint8_t* can_data, uint8_t data_len)
|
|
|
can_frame.dlc ,
|
|
can_frame.dlc ,
|
|
|
SYS_Hex2str(can_frame.dt, can_frame.dlc));
|
|
SYS_Hex2str(can_frame.dt, can_frame.dlc));
|
|
|
|
|
|
|
|
|
|
+ // //开始往队列中放入.
|
|
|
|
|
+ // uint8_t find_frame_id_flag = 0;
|
|
|
|
|
+ // for(int i=0; i<sizeof(data_process_handler_list)/sizeof(HANDLER_T); i++)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // //先找下这个id有没有在这个列表里面.如果在的话就放进去,如果不在的话,就重新找新的放入.
|
|
|
|
|
+ // if(data_process_handler_list[i].frame_id == can_frame.id)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // LOG_D("find frame_id");
|
|
|
|
|
+ // find_frame_id_flag = 1;
|
|
|
|
|
+ // iso15765_enqueue(data_process_handler_list[i].process_handler, &can_frame);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // if(0 == find_frame_id_flag)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // //这个frame_id不在之前发过的历史列表里面,那找个新的放进去.
|
|
|
|
|
+ // for(int j=0; j<sizeof(data_process_handler_list)/sizeof(HANDLER_T); j++)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // if(UINT32_DEFAULT_VAL == data_process_handler_list[j].frame_id)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // LOG_D("not find frame_id, now set %d", j);
|
|
|
|
|
+ // data_process_handler_list[j].frame_id = can_frame.id;
|
|
|
|
|
+ // iso15765_enqueue(data_process_handler_list[j].process_handler, &can_frame);
|
|
|
|
|
+ // break;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
/******************ISO15765**********************************/
|
|
/******************ISO15765**********************************/
|
|
|
|
|
|
|
@@ -199,23 +253,30 @@ void MOD_CanPutDataToIso15765Parse(uint8_t* can_data, uint8_t data_len)
|
|
|
**********************************************/
|
|
**********************************************/
|
|
|
int MOD_CanTransferData(uint8_t* data, uint8_t len)
|
|
int MOD_CanTransferData(uint8_t* data, uint8_t len)
|
|
|
{
|
|
{
|
|
|
- uint8_t can_id_type = 0;
|
|
|
|
|
- uint32_t can_id = 0;
|
|
|
|
|
- uint8_t payload_len = 0;
|
|
|
|
|
- uint8_t payload[8] = {0};
|
|
|
|
|
-
|
|
|
|
|
- memset(payload, 0, 8);
|
|
|
|
|
- g_s_can_index = data[0];
|
|
|
|
|
- can_id_type = data[1];
|
|
|
|
|
- memcpy(&can_id, &data[2], 4);
|
|
|
|
|
- small_big_transfer32(&can_id);
|
|
|
|
|
- payload_len = data[6];
|
|
|
|
|
- memcpy(payload, &data[7], payload_len);
|
|
|
|
|
-
|
|
|
|
|
- DLOG_I("tx_can_data,index:%d,type:%d,can_id:0x%x,payload_len:%d,payload:%s", g_s_can_index, can_id_type, can_id, payload_len,
|
|
|
|
|
- SYS_Hex2str(payload, payload_len));
|
|
|
|
|
-
|
|
|
|
|
- return HAL_CanTxData(can_id_type, can_id, payload, payload_len);
|
|
|
|
|
|
|
+ // uint8_t can_id_type = 0;
|
|
|
|
|
+ // uint32_t can_id = 0;
|
|
|
|
|
+ // uint8_t payload_len = 0;
|
|
|
|
|
+ // uint8_t payload[8] = {0};
|
|
|
|
|
+
|
|
|
|
|
+ // memset(payload, 0, 8);
|
|
|
|
|
+ // g_s_can_index = data[0];
|
|
|
|
|
+ // can_id_type = data[1];
|
|
|
|
|
+ // memcpy(&can_id, &data[2], 4);
|
|
|
|
|
+ // small_big_transfer32(&can_id);
|
|
|
|
|
+ // payload_len = data[6];
|
|
|
|
|
+ // memcpy(payload, &data[7], payload_len);
|
|
|
|
|
+
|
|
|
|
|
+ // DLOG_I("tx_can_data,index:%d,type:%d,can_id:0x%x,payload_len:%d,payload:%s", g_s_can_index, can_id_type, can_id, payload_len,
|
|
|
|
|
+ // SYS_Hex2str(payload, payload_len));
|
|
|
|
|
+ // return HAL_CanTxData(can_id_type, can_id, payload, payload_len);
|
|
|
|
|
+
|
|
|
|
|
+ //iso15765库
|
|
|
|
|
+ uint8_t tx_len = len>I15765_MSG_SIZE?I15765_MSG_SIZE:len;
|
|
|
|
|
+ memset(&g_s_can_frame.msg, 0, I15765_MSG_SIZE);
|
|
|
|
|
+ memcpy(&g_s_can_frame.msg, data, tx_len);
|
|
|
|
|
+ DLOG_I("send can data to iso15765,size:%d,data:%d", tx_len, SYS_Hex2str(g_s_can_frame.msg, tx_len));
|
|
|
|
|
+
|
|
|
|
|
+ iso15765_send(&handler1, &g_s_can_frame); //使用这个接口将数据发送给协议库
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**********************************************
|
|
/**********************************************
|