1/** 2* @file hi_diag.h 3* 4* Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 5* Licensed under the Apache License, Version 2.0 (the "License"); 6* you may not use this file except in compliance with the License. 7* You may obtain a copy of the License at 8* 9* http://www.apache.org/licenses/LICENSE-2.0 10* 11* Unless required by applicable law or agreed to in writing, software 12* distributed under the License is distributed on an "AS IS" BASIS, 13* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14* See the License for the specific language governing permissions and 15* limitations under the License. 16*/ 17 18/** @defgroup iot_diag Diagnostic 19 * @ingroup dfx 20 */ 21 22#ifndef __HI_DIAG_H__ 23#define __HI_DIAG_H__ 24 25#include <hi_types.h> 26#include <hi_uart.h> 27 28/** 29* @ingroup iot_diag 30* @brief Registers the callback function for DIAG channel status changes. 31CNcomment:注册DIAG通道状态变更回调函数。CNend 32* 33* @par 描述: 34* Registers the callback function for DIAG channel status changes. That is, when the DIAG channel is 35* connected or disconnected, the function registered by this API is called back. 36CNcomment:注册DIAG通道变更回调函数(即:当DIAG通道连接或断开时,会回调本接口注册的函数)。CNend 37* 38* @attention None 39* @param connect_notify_func [IN] type #hi_diag_connect_f,User function. CNcomment:用户函数。CNend 40* 41* @retval #0 Success. 42* @retval #Other Failure. For details, see hi_errno.h. 43* @par 依赖: 44* @li hi_diag.h:Describes DIAG APIs. 45CNcomment:文件用于描述DIAG相关接口。CNend 46* @see None 47*/ 48HI_EXTERN hi_u32 hi_diag_register_connect_notify(hi_diag_connect_f connect_notify_func); 49 50/** 51* @ingroup iot_diag 52* @brief Checks the connection status of the DIAG channel. CNcomment:检测DIAG通道连接状态的函数。CNend 53* 54* @par 描述: 55* Checks the connection status of the DIAG channel. CNcomment:检测DIAG通道是否处于连接状态的函数 。CNend 56* 57* @attention None 58* @param None 59* 60* @retval HI_FALSE disconnected. CNcomment:处于非连接状态。CNend 61* @retval HI_TRUE connected. CNcomment:处于连接状态。CNend 62* @par 依赖: 63* @li hi_diag.h:Describes DIAG APIs. 64CNcomment:文件用于描述DIAG相关接口。CNend 65* @see None 66*/ 67HI_EXTERN hi_bool hi_diag_is_connect(hi_void); 68 69/** 70* @ingroup iot_diag 71* @brief Registers the command handling function. CNcomment:注册命令处理函数。CNend 72* 73* @par 描述: 74* @li Called at initialize stage, does NOT support multiable task calls. 75CNcomment:在初始化阶段调用, 不支持多任务调用。CNend 76* @li The DIAG subsystem supports a maximum of 10 different command tables. 77CNcomment:最多能注册10个不同的命令表。CNend 78* 79* @attention None 80* @param p_cmd_tbl [IN] type #const hi_diag_cmd_reg_obj*,Command table, which must be declared as a constant array 81* and transmitted to this parameter. 82CNcomment:命令表,必须申明为常量数组传给该参数。CNend 83* @param cmd_num [IN] type #hi_u16,Number of commands. The value cannot be 0. CNcomment:命令个数, 84如果usCmdNum为0而pstCmdTbl不为0,则取消注册。CNend 85* 86* @retval #0 Success. 87* @retval #Other Failure. For details, see hi_errno.h. 88* @par 依赖: 89* @li hi_diag.h:Describes DIAG APIs. 90CNcomment:文件用于描述DIAG相关接口。CNend 91* @see None 92*/ 93HI_EXTERN hi_u32 hi_diag_register_cmd(const hi_diag_cmd_reg_obj* cmd_tbl, hi_u16 cmd_num); 94 95/** 96* @ingroup iot_diag 97* @brief Reports DIAG packets. CNcomment:DIAG包上报。CNend 98* 99* @par 描述: 100* Reports DIAG channel packets to the DIAG client. 101CNcomment:该函数用于将DIAG通道报文上报给DIAG客户端。CNend 102* 103* @attention 104* This API can not be used in interrupt when report data synchronously. 105CNcomment:当同步上报数据时,该接口不支持在中断中调用。CNend 106* @param cmd_id [IN] type #hi_u16,DIAG data packet ID. CNcomment:DIAG应答包ID。CNend 107* @param instance_id [IN] type #hi_u8,Command type.This parameter is used to obtain the command type in the 108* option parameter of the command callback function hi_diag_cmd_f.currently only support 109* HI_DIAG_CMD_INSTANCE_LOCAL. 110CNcomment:命令类型。在命令回调函数hi_diag_cmd_f的option参数中获取命令类型,在函数中使用 111此接口回复报文时,通过本参数传递。当前仅支持HI_DIAG_CMD_INSTANCE_LOCAL。CNend 112* @param buffer [IN] type #hi_pbyte,Buffer address of the data packet. This function does not release the 113* pointer. CNcomment:数据包的buffer地址,该函数不会释放该指针。CNend 114* @param buffer_size [IN] type #hi_u16,Data packet size (unit: byte), range[0, 65507] 115CNcomment:数据包大小(单位:byte),取值范围[0, 65507]。CNend 116* @param sync [IN] type #hi_bool,Synchronous or asynchronous DIAG packet pushing. TRUE indicates that the 117* packets are pushed synchronously and the operation is blocked. FALSE indicates the packets 118* are pushed asynchronously (with the memory allocated, the packet is cashed by the OS queue 119* before being pushed), and the operation is not blocked. 120CNcomment:DIAG包同步/异步上报设置。TRUE表示同步上报, 阻塞操作; FALSE表示异步 121(通过分配内存后, 由OS队列缓存再上报), 非阻塞操作。CNend 122* 123* 124* @retval #0 Success. 125* @retval #Other Failure. For details, see hi_errno.h. 126* @par 依赖: 127* @li hi_diag.h:Describes DIAG APIs. 128CNcomment:文件用于描述DIAG相关接口。CNend 129* @see None 130*/ 131HI_EXTERN hi_u32 hi_diag_report_packet(hi_u16 cmd_id, hi_u8 instance_id, hi_pbyte buffer, 132 hi_u16 buffer_size, hi_bool sync); 133 134/** 135* @ingroup iot_diag 136* @brief Sends ACK packets to the DIAG client. CNcomment:应答回复。CNend 137* 138* @par 描述: 139* Sends ACK packets to the DIAG client. CNcomment:该函数用于回复报文或ACK给DIAG客户端。CNend 140* 141* @attention 142* This API can not be used in interrupt.CNcomment:该接口不支持在中断中调用。CNend 143* @param cmd_id [IN] type #hi_u16,DIAG ACK packet ID. CNcomment:DIAG包ID。CNend 144* @param instance_id [IN] type #hi_u8,Command type.This parameter is used to obtain the command type in the 145* option parameter of the command callback function hi_diag_cmd_f.currently only support 146* HI_DIAG_CMD_INSTANCE_LOCAL. 147CNcoment:在命令回调函数HI_DIAG_CMD_F的option参数中获取命令类型,在函数中使用此接口回复 148报文时,通过本参数传递。当前仅支持HI_DIAG_CMD_INSTANCE_LOCAL。CNend 149* @param buffer [IN] type #hi_pbyte,Buffer address of the data packet. This function does not release the 150* pointer. CNcomment:数据包的buffer地址,该函数不会释放该指针。CNend 151* @param buffer_size [IN] type #hi_u16,Data packet size(unit: byte), range[0, 1024] 152CNcomment:数据包大小(单位:byte),取值范围[0, 1024]。CNend 153* 154* @retval #HI_ERR_CONSUMED Success. 155* @retval #Other Failure. For details, see hi_errno.h. 156* @par 依赖: 157* @li hi_diag.h:Describes DIAG APIs. 158CNcomment:文件用于描述DIAG相关接口。CNend 159* @see None 160*/ 161HI_EXTERN hi_u32 hi_diag_send_ack_packet(hi_u16 cmd_id, hi_u8 instance_id, hi_pvoid buffer, hi_u16 buffer_size); 162 163/** 164* @ingroup iot_diag 165* @brief Registers the callback function for notifying DIAG operations. 166CNcomment:注册DIAG操作通知回调函数。CNend 167* 168* @par 描述: 169* Carbon copies data to the app layer by using a callback function in the case of data interaction between 170* the host and the board.CNcommand:该函数用于当上位机与单板有数据交互发生时, 171将数据通过回调函数抄送给应用层。CNend 172* 173* @attention None 174* @param cmd_notify_func [IN] type #hi_diag_cmd_notify_f*,When data interaction occurs between the HSO and the board, 175* this API is used to notify the app layer. 176CNcomment:当HSO与单板有数据交互发生时,通过该接口通知应用层。CNend 177* 178* 179* @retval #0 Success. 180* @retval #Other Failure. For details, see hi_errno.h. 181* @par 依赖: 182* @li hi_diag.h:Describes DIAG APIs. 183CNcomment:文件用于描述DIAG相关接口。CNend 184* @see None 185*/ 186HI_EXTERN hi_u32 hi_diag_register_cmd_notify(hi_diag_cmd_notify_f cmd_notify_func); 187 188/** 189* @ingroup iot_diag 190* @brief Sets the UART parameters of the DIAG channel. CNcomment:设置诊断通道UART参数。CNend 191* 192* @par 描述: 193* Sets the UART parameters of the used by the DIAG subsystem before the DIAG subsystem is initialized. 194CNcomment:该函数用于在诊断子系统初始化之前,设置诊断子系统使用的UART的相关参数。CNend 195* 196* @attention The parameters must be set before the initialization of the DIAG subsystem. 197CNcomment:必须在诊断子系统初始化之前设置才可生效。CNend 198* @param uart_port [IN] type #hi_uart_idx,UART port number used by the DIAG subsystem. 199CNcomment:诊断子系统使用的UART端口号。CNend 200* @param uart_cfg [IN] type #hi_uart_attribute,UART configuration used by the DIAG subsystem. 201CNcomment:诊断子系统使用的UART配置。CNend 202* 203* @retval #0 Success. 204* @retval #Other Failure. For details, see hi_errno.h. 205* @par 依赖: 206* @li hi_diag.h:Describes DIAG APIs. 207CNcomment:文件用于描述DIAG相关接口。CNend 208* @see None 209*/ 210HI_EXTERN hi_u32 hi_diag_set_uart_param(hi_uart_idx uart_port, hi_uart_attribute uart_cfg); 211 212/** 213* @ingroup iot_diag 214* @brief Initializes the DIAG subsystem. CNcomment:诊断子系统初始化。CNend 215* 216* @par 描述: 217* Initializes the DIAG subsystem. CNcomment:该函数用于初始化诊断子系统。CNend 218* 219* @attention The initialization of the DIAG subsystem needs to be performed only once. Repeated initialization is 220* invalid. CNcomment:诊断子系统初始化只需执行一次,多次初始化无效。CNend 221* @param None 222* 223* @retval #0 Success. 224* @retval #Other Failure. For details, see hi_errno.h. 225* @par 依赖: 226* @li hi_diag.h:Describes DIAG APIs. 227CNcomment:文件用于描述DIAG相关接口。CNend 228* @see None 229*/ 230HI_EXTERN hi_u32 hi_diag_init(hi_void); 231 232/** 233* @ingroup iot_diag 234* 235* Structure for querying the number of command tables and statistic object tables. 236CNcomment:命令注册列表和统计量对象注册列表个数查询结构体。CNend 237*/ 238typedef struct { 239 hi_u8 cmd_list_total_cnt; /**< Number of command registration tables can be registered. 240 CNcomment:总共支持注册的命令列表个数 CNend */ 241 hi_u8 cmd_list_used_cnt; /**< Number of registered command tables. 242 CNcomment:已经注册的命令列表个数 CNend */ 243 hi_u8 stat_list_total_cnt; /**< Number of statistic object tables can be registered. Currently not support. 244 CNcomment:总共支持注册的统计量对象列表个数。当前暂不支持。 CNend */ 245 hi_u8 stat_list_used_cnt; /**< Number of registered statistic object tables. Currently not support. 246 CNcomment:已经注册的统计量对象列表个数。当前暂不支持。 CNend */ 247} hi_diag_cmd_stat_reg_info; 248 249/** 250* @ingroup iot_diag 251* @brief Queries the registration status of the command tables and statistic tables of the DIAG subsystem. 252CNcomment:查询诊断子系统命令列表和统计量列表注册情况。CNend 253* 254* @par 描述: 255* Queries the registration status of the command tables and statistic tables of the DIAG subsystem. 256* Number of registered command tables and number of command tables can be registered/ Number of registered 257* statistic object tables 258CNcomment:查询总共支持注册/已经注册的命令列表个数、总共支持注册/已经注册的统计量对象列表个数。CNend 259* 260* @attention None 261* @param None 262* 263* @retval #hi_diag_cmd_stat_reg_info Structure of the number of registered command tables and statistic tables. 264CNcomment:命令列表和统计量列表注册个数信息结构体。CNend 265* @par 依赖: 266* @li hi_diag.h:Describes DIAG APIs. 267CNcomment:文件用于描述DIAG相关接口。CNend 268* @see None 269*/ 270HI_EXTERN hi_diag_cmd_stat_reg_info hi_diag_get_cmd_stat_reg_info(hi_void); 271 272typedef struct { 273 hi_u32 data0; 274 hi_u32 data1; 275 hi_u32 data2; 276 hi_u32 data3; 277}diag_log_msg; 278 279/** 280* @ingroup iot_diag 281* @brief Reports usr packets. CNcomment:上报用户日志。CNend 282* 283* @par 描述: 284* Reports usr packets. CNcomment:上报用户日志消息。CNend 285* 286* @attention None 287* @param diag_usr_msg [IN] type #hi_diag_layer_msg,log message. CNcomment:日志消息。CNend 288* @param msg_level [IN] type #hi_u16,level of log message, [HI_MSG_USR_L0, HI_MSG_USR_L4]. 289CNcomment:日志消息级别,取值从:HI_MSG_USR_L0- HI_MSG_USR_L4。CNend 290* 291* @retval #0 Success. 292* @retval #Other Failure. For details, see hi_errno.h. 293* @par 依赖: 294* @li hi_diag.h:Describes DIAG APIs. 295CNcomment:文件用于描述DIAG相关接口。CNend 296* @see None 297*/ 298hi_u32 hi_diag_report_usr_msg(const hi_diag_layer_msg* diag_usr_msg, hi_u16 msg_level); 299 300/** 301* @ingroup iot_diag 302* @brief Reports simple packet that without data. CNcomment:上报简单日志,不携带数据内容。CNend 303* 304* @par 描述: 305* Reports simple packets, fixed module ID. CNcomment:上报简单日志消息,固定模块ID。 306* 307* @attention None 308* @param msg_id [IN] type #hi_u32,log message ID. CNcomment:日志消息ID。CNend 309* @param msg_level [IN] type #hi_u16,log message level, [HI_MSG_SYS_L0, HI_MSG_SYS_L2] 310CNcomment:日志消息级别,取值从:HI_MSG_SYS_L0- HI_MSG_SYS_L2。CNend 311* 312* @retval #0 Success. 313* @retval #Other Failure. For details, see hi_errno.h. 314* @par 依赖: 315* @li hi_diag.h:Describes DIAG APIs. 316CNcomment:文件用于描述DIAG相关接口。CNend 317* @see None 318*/ 319hi_u32 hi_diag_log_msg0(hi_u32 msg_id, hi_u16 msg_level); 320 321/** 322* @ingroup iot_diag 323* @brief Reports simple packet that with one word data. CNcomment:上报简单日志,携带1个数据。CNend 324* 325* @par 描述: 326* Reports simple packets, fixed module ID. CNcomment:上报简单日志消息,固定模块ID。CNend 327* 328* @attention None 329* @param msg_id [IN] type #hi_u32,log message ID. CNcomment:日志消息ID。CNend 330* @param d0 [IN] type #hi_u32,first data. CNcomment:携带的第1个数据。Cnend 331* @param msg_level [IN] type #hi_u16,log message level, [HI_MSG_SYS_L0, HI_MSG_SYS_L2] 332CNcomment:日志消息级别,取值从:HI_MSG_SYS_L0- HI_MSG_SYS_L2。CNend 333* 334* @retval #0 Success. 335* @retval #Other Failure. For details, see hi_errno.h. 336* @par 依赖: 337* @li hi_diag.h:Describes DIAG APIs. 338CNcomment:文件用于描述DIAG相关接口。CNend 339* @see None 340*/ 341hi_u32 hi_diag_log_msg1(hi_u32 msg_id, hi_u32 d0, hi_u16 msg_level); 342 343/** 344* @ingroup iot_diag 345* @brief Reports simple packet that with 2 words data. CNcomment:上报简单日志,携带2个数据。CNend 346* 347* @par 描述: 348* Reports simple packets, fixed module ID. CNcomment:上报简单日志消息,固定模块ID。CNend 349* 350* @attention None 351* @param msg_id [IN] type #hi_u32,log message ID. CNcomment:日志消息ID。CNend 352* @param d0 [IN] type #hi_u32,first data. CNcomment:携带的第1个数据。CNend 353* @param d1 [IN] type #hi_u32,second data. CNcomment:携带的第2个数据。CNend 354* @param msg_level [IN] type #hi_u16,log message level, [HI_MSG_SYS_L0, HI_MSG_SYS_L2] 355CNcomment:日志消息级别,取值从:HI_MSG_SYS_L0- HI_MSG_SYS_L2。CNend 356* 357* @retval #0 Success. 358* @retval #Other Failure. For details, see hi_errno.h. 359* @par 依赖: 360* @li hi_diag.h:Describes DIAG APIs. 361CNcomment:文件用于描述DIAG相关接口。CNend 362* @see None 363*/ 364hi_u32 hi_diag_log_msg2(hi_u32 msg_id, hi_u32 d0, hi_u32 d1, hi_u16 msg_level); 365 366/** 367* @ingroup iot_diag 368* @brief Reports simple packet that with three words data. CNcomment:上报简单日志,携带3个数据。CNend 369* 370* @par 描述: 371* Reports simple packets, fixed module ID. CNcomment:上报简单日志消息,固定模块ID。CNend 372* 373* @attention None 374* @param msg_id [IN] type #hi_u32,log message ID. CNcomment:日志消息ID。CNend 375* @param d0 [IN] type #hi_u32,first data. CNcomment:携带的第1个数据。Cnend 376* @param d1 [IN] type #hi_u32,second data. CNcomment:携带的第2个数据。CNend 377* @param d2 [IN] type #hi_u32,third data. CNcomment:携带的第3个数据。CNend 378* @param msg_level [IN] type #hi_u16,log message level, [HI_MSG_SYS_L0, HI_MSG_SYS_L2] 379CNcomment:日志消息级别,取值从:HI_MSG_SYS_L0- HI_MSG_SYS_L2。CNend 380* 381* @retval #0 Success. 382* @retval #Other Failure. For details, see hi_errno.h. 383* @par 依赖: 384* @li hi_diag.h:Describes DIAG APIs. 385CNcomment:文件用于描述DIAG相关接口。CNend 386* @see None 387*/ 388hi_u32 hi_diag_log_msg3(hi_u32 msg_id, hi_u32 d0, hi_u32 d1, hi_u32 d2, hi_u16 msg_level); 389 390/** 391* @ingroup iot_diag 392* @brief Reports simple packet that with four words data. CNcomment:上报简单日志,携带4个数据。CNend 393* 394* @par 描述: 395* Reports simple packets, fixed module ID. CNcomment:上报简单日志消息,固定模块ID。CNend 396* 397* @attention None 398* @param msg_id [IN] type #hi_u32,log message ID. CNcomment:日志消息ID。CNend 399* @param log_msg [IN] type #diag_log_msg,four words. CNcomment:携带4个数据。CNend 400* @param msg_level [IN] type #hi_u16,log message level, [HI_MSG_SYS_L0, HI_MSG_SYS_L2] 401CNcomment:日志消息级别,取值从:HI_MSG_SYS_L0- HI_MSG_SYS_L2。CNend 402* 403* @retval #0 Success. 404* @retval #Other Failure. For details, see hi_errno.h. 405* @par 依赖: 406* @li hi_diag.h:Describes DIAG APIs. 407CNcomment:文件用于描述DIAG相关接口。CNend 408* @see None 409*/ 410hi_u32 hi_diag_log_msg4(hi_u32 msg_id, diag_log_msg log_msg, hi_u16 msg_level); 411 412/** 413* @ingroup iot_diag 414* @brief Reports simple packet that with one buffer data. CNcomment:上报简单日志,携带数据buffer。CNend 415* 416* @par 描述: 417* Reports simple packets, fixed module ID. CNcomment:上报简单日志消息,固定模块ID。CNend 418* 419* @attention A maximum of 99 bytes can be send in one diag packet, so param size cannot be greater than 99. 420CNcomment:diag单包最多能发99字节数据,参数size不能大于99。CNend 421* @param msg_id [IN] type #hi_u32,log message ID. CNcomment:日志消息ID。CNend 422* @param buffer [IN] type #hi_pvoid,address of the data. CNcomment:携带的数据buffer首地址。CNend 423* @param size [IN] type #hi_16,buffer size (unit byte). 424CNcomment:携带的数据buffer长度(单位byte)。CNend 425* @param msg_level [IN] type #hi_u16,log message level, [HI_MSG_SYS_L0, HI_MSG_SYS_L2] 426CNcomment:日志消息级别,取值从:HI_MSG_SYS_L0- HI_MSG_SYS_L2。CNend 427* 428* @retval #0 Success. 429* @retval #Other Failure. For details, see hi_errno.h. 430* @par 依赖: 431* @li hi_diag.h:Describes DIAG APIs. 432CNcomment:文件用于描述DIAG相关接口。CNend 433* @see None 434*/ 435hi_u32 hi_diag_log_msg_buffer(hi_u32 msg_id, hi_pvoid buffer, hi_u16 size, hi_u16 msg_level); 436 437/** 438* @ingroup iot_diag 439* @brief Reports layer log that without data. CNcomment:上报层间简单日志,不携带数据内容。CNend 440* 441* @par 描述: 442* Reports layer log that without data. CNcomment:上报层间简单日志,不携带数据内容。CNend 443* 444* @attention None 445* @param msg_id [IN] type #hi_u32,log message ID. CNcomment:日志消息ID。CNend 446* @param module_id [IN] type #hi_u16,message module ID,describe which module the log belongs to. 447CNcomment:消息模块ID,描述日志属于哪个模块。CNend 448* 449* @retval #0 Success. 450* @retval #Other Failure. For details, see hi_errno.h. 451* @par 依赖: 452* @li hi_diag.h:Describes DIAG APIs. 453CNcomment:文件用于描述DIAG相关接口。CNend 454* @see None 455*/ 456hi_u32 hi_diag_layer_msg0(hi_u32 msg_id, hi_u16 module_id); 457 458/** 459* @ingroup iot_diag 460* @brief Reports layer log that with one word data. CNcoment:上报层间简单日志,携带1个数据。CNend 461* 462* @par 描述: 463* Reports layer log that with one word data. CNcoment:上报层间简单日志,携带1个数据。CNend 464* 465* @attention None 466* @param msg_id [IN] type #hi_u32,log message ID. CNcomment:日志消息ID。CNend 467* @param module_id [IN] type #hi_u16,message module ID,describe which module the log belongs to. 468CNcomment:消息模块ID,描述日志属于哪个模块。CNend 469* @param d0 [IN] type #hi_u32,first data. CNcomment:携带的第1个数据。CNend 470* 471* @retval #0 Success. 472* @retval #Other Failure. For details, see hi_errno.h. 473* @par 依赖: 474* @li hi_diag.h:Describes DIAG APIs. 475CNcomment:文件用于描述DIAG相关接口。CNend 476* @see None 477*/ 478hi_u32 hi_diag_layer_msg1(hi_u32 msg_id, hi_u16 module_id, hi_u32 d0); 479 480/** 481* @ingroup iot_diag 482* @brief Reports layer log that with two words data. CNcoment:上报层间简单日志,携带2个数据。CNend 483* 484* @par 描述: 485* Reports layer log that with two words data. CNcoment:上报层间简单日志,携带2个数据。CNend 486* 487* @attention None 488* @param msg_id [IN] type #hi_u32,log message ID. CNcomment:日志消息ID。CNend 489* @param module_id [IN] type #hi_u16,message module ID,describe which module the log belongs to. 490CNcomment:消息模块ID,描述日志属于哪个模块。CNend 491* @param d0 [IN] type #hi_u32,first data. CNcomment:携带的第1个数据。CNend 492* @param d1 [IN] type #hi_u32,second data. CNcomment:携带的第2个数据。CNend 493* 494* @retval #0 Success. 495* @retval #Other Failure. For details, see hi_errno.h. 496* @par 依赖: 497* @li hi_diag.h:Describes DIAG APIs. 498CNcomment:文件用于描述DIAG相关接口。CNend 499* @see None 500*/ 501hi_u32 hi_diag_layer_msg2(hi_u32 msg_id, hi_u16 module_id, hi_u32 d0, hi_u32 d1); 502 503/** 504* @ingroup iot_diag 505* @brief Reports layer log that with 3 words data. CNcoment:上报层间简单日志,携带3个数据。CNend 506* 507* @par 描述: 508* Reports layer log that with 3 words data. CNcoment:上报层间简单日志,携带3个数据。CNend 509* 510* @attention None 511* @param msg_id [IN] type #hi_u32,log message ID. CNcomment:日志消息ID。CNend 512* @param module_id [IN] type #hi_u16,message module ID,describe which module the log belongs to. 513CNcomment:消息模块ID,描述日志属于哪个模块。CNend 514* @param d0 [IN] type #hi_u32,first data. CNcomment:携带的第1个数据。CNend 515* @param d1 [IN] type #hi_u32,second data. CNcomment:携带的第2个数据。CNend 516* @param d2 [IN] type #hi_u32,third data. CNcomment:携带的第3个数据。CNend 517* 518* @retval #0 Success. 519* @retval #Other Failure. For details, see hi_errno.h. 520* @par 依赖: 521* @li hi_diag.h:Describes DIAG APIs. 522CNcomment:文件用于描述DIAG相关接口。CNend 523* @see None 524*/ 525hi_u32 hi_diag_layer_msg3(hi_u32 msg_id, hi_u16 module_id, hi_u32 d0, hi_u32 d1, hi_u32 d2); 526 527/** 528* @ingroup iot_diag 529* @brief Reports layer log that with 4 words data. CNcoment:上报层间简单日志,携带4个数据。CNend 530* 531* @par 描述: 532* Reports layer log that with 4 words data. CNcoment:上报层间简单日志,携带4个数据。CNend 533* 534* @attention None 535* @param msg_id [IN] type #hi_u32,log message ID. CNcomment:日志消息ID。CNend 536* @param module_id [IN] type #hi_u16,message module ID,describe which module the log belongs to. 537CNcomment:消息模块ID,描述日志属于哪个模块。CNend 538* @param log_msg [IN] type #diag_log_msg,four data to report. CNcomment:携带4个数据。CNend 539* 540* @retval #0 Success. 541* @retval #Other Failure. For details, see hi_errno.h. 542* @par 依赖: 543* @li hi_diag.h:Describes DIAG APIs. 544*/ 545hi_u32 hi_diag_layer_msg4(hi_u32 msg_id, hi_u16 module_id, diag_log_msg log_msg); 546 547/** 548* @ingroup iot_diag 549* @brief Reports layer log that with one buffer data. CNcomment:上报层间简单日志,携带数据buffer。CNend 550* 551* @par 描述: 552* Reports layer log that with one buffer data. CNcomment:上报层间简单日志,携带数据buffer。CNend 553* 554* @attention A maximum of 99 bytes can be send in one diag packet, so param size cannot be greater than 99. 555CNcomment:diag单包最多能发99字节数据,参数size不能大于99。CNend 556* @param msg_id [IN] type #hi_u32,log message ID. CNcomment:日志消息ID。CNend 557* @param module_id [IN] type #hi_u16,message module ID,describe which module the log belongs to. 558CNcomment:消息模块ID,描述日志属于哪个模块。CNend 559* @param buffer [IN] type #const hi_pvoid,address of the data. CNcomment:携带的数据buffer首地址。CNend 560* @param size [IN] type #hi_16,buffer size (unit byte). 561CNcomment:携带的数据buffer长度(单位byte)。CNend 562* 563* @retval #0 Success. 564* @retval #Other Failure. For details, see hi_errno.h. 565* @par 依赖: 566* @li hi_diag.h:Describes DIAG APIs. 567CNcomment:文件用于描述DIAG相关接口。CNend 568* @see None 569*/ 570hi_u32 hi_diag_layer_msg_buffer(hi_u32 msg_id, hi_u16 module_id, const hi_void *buffer, hi_u16 size); 571 572typedef struct { 573 hi_u16 size1; 574 hi_u16 size2; 575} diag_buffer_size; 576 577/** 578* @ingroup iot_diag 579* @brief Reports layer log that with two buffer data. CNcomment:上报层间简单日志,支持携带两个数据buffer。CNend 580* 581* @par 描述: 582* Reports layer log that with two buffer data. CNcomment:上报层间简单日志,支持携带两个数据buffer。CNend 583* 584* @attention A maximum of 99 bytes can be send in one diag packet.A space is reserved between two buffers. 585 Therefore, the sum of buffer_size.size1 and buffer_size.size2 cannot be greater than 98. 586CNcomment:diag单包最多能发99字节数据,两个buffer之间会预留一个空格,所以参数buffer_size.size1与buffer_size.size2的和不能大于98。CNend 587* @param msg_id [IN] type #hi_u32,log message ID. CNcomment:日志消息ID。CNend 588* @param module_id [IN] type #hi_u16,message module ID,describe which module the log belongs to. 589CNcomment:消息模块ID,描述日志属于哪个模块。CNend 590* @param buf1 [IN] type #const hi_void *,address of the first buffer. 591CNcomment:携带的数据buffer1首地址。CNend 592* @param buf1 [IN] type #const hi_void *,address of the second buffer. 593CNcomment:携带的数据buffer2首地址。CNend 594* @param buffer_size [IN] type #diag_buffer_size,two buffer size (unit byte). 595CNcomment:携带的数据buffer长度(单位byte)。CNend 596* 597* @retval #0 Success. 598* @retval #Other Failure. For details, see hi_errno.h. 599* @par 依赖: 600* @li hi_diag.h:Describes DIAG APIs. 601*/ 602hi_u32 hi_diag_layer_two_buffer(hi_u32 msg_id, hi_u16 module_id, const hi_void *buf1, 603 const hi_void *buf2, diag_buffer_size buffer_size); 604 605/** 606* @ingroup iot_diag 607* @brief Set whether to check the UART busy status when low power vote. 608CNcomment:设置低功耗投票时是否检查UART busy状态。CNend 609* 610* @par 描述: 611* Set whether to check the UART busy status when low power vote. 612CNcomment:设置低功耗投票时是否检查UART busy状态。CNend 613* 614* @attention UART busy status is not checked by default. 615CNcomment:默认低功耗睡眠投票时不检查UART busy状态。CNend 616* @param enable [IN] type #hi_bool,enable status. CNcomment:设置是否检查UART busy状态。CNend 617* 618* @retval None 619* @par 依赖: 620* @li hi_diag.h:Describes DIAG APIs. 621CNcomment:文件用于描述DIAG相关接口。CNend 622*/ 623hi_void hi_diag_set_check_uart_busy(hi_bool enable); 624 625typedef hi_s32 (*hi_diag_input_func)(hi_u8 *data, hi_u32 data_len); 626typedef hi_s32 (*hi_diag_output_func)(const hi_u8 *data, hi_u32 data_len); 627 628/** 629* @ingroup iot_diag 630* @brief Register diag input function to replace uart input. 631CNcomment:注册DIAG输入函数,代替默认从UART读取DIAG输入数据。CNend 632* 633* @par 描述: 634* Register diag input function to replace uart input. 635CNcomment:注册DIAG输入函数,代替默认从UART读取DIAG输入数据。CNend 636* 637* @attention Should set suitable task size; input func should not continuous read data without break. otherwise, 638a watchdog may happen.not support register HI_NULL when diag channel is already uart. 639CNcomment:根据输入函数实现,设置合适的栈大小;输入函数不能持续 640返回有效数据避免触发看门狗。当DIAG 通道已经是UART时,不支持注 641册DIAG 输入函数为HI_NULL。CNend 642* @param diag_input_func [IN] type #hi_diag_input_func,diag input function. 643CNcomment:DIAG输入函数。CNend 644* 645* @retval #0 Success. 646* @retval #Other Failure. For details, see hi_errno.h. 647* @par 依赖: 648* @li hi_diag.h:Describes DIAG APIs. 649CNcomment:文件用于描述DIAG相关接口。CNend 650*/ 651hi_u32 hi_diag_register_input_func(hi_diag_input_func diag_input_func); 652 653/** 654* @ingroup iot_diag 655* @brief Register diag output function to replace uart output. 656CNcomment:注册DIAG输出函数,代替默认从UART输出DIAG相关数据。CNend 657* 658* @par 描述: 659* Register diag output function to replace uart output. 660CNcomment:注册DIAG输出函数,代替默认从UART输出DIAG相关数据。CNend 661* 662* @attention Should set suitable task size according to implementation of output func. 663CNcomment:根据输出函数实现,设置合适的栈大小。CNend 664* @param diag_output_func [IN] type #hi_diag_output_func,diag output function. 665CNcomment:DIAG输出函数。CNend 666* 667* @retval None 668* @par 依赖: 669* @li hi_diag.h:Describes DIAG APIs. 670CNcomment:文件用于描述DIAG相关接口。CNend 671*/ 672hi_void hi_diag_register_output_func(hi_diag_output_func diag_output_func); 673 674/** 675* @ingroup iot_diag 676* @brief Set taks size of DIAG. CNcomment:设置DIAG相关任务栈大小。CNend 677* 678* @par 描述: 679* Set taks size of DIAG. CNcomment:设置DIAG相关任务栈大小。CNend 680* 681* @attention diag task stack size needs to be set before diag initialization. 682CNcomment:diag任务栈大小需要在diag初始化之前设置。CNend 683* @param channel_task_size [IN] type #hi_u16 channel task size,task size should not smaller than 0x600. 684CNcomment:通道任务栈大小,任务栈大小不低于0x600。CNend 685* @param process_task_size [IN] type #hi_u16 process task size,task size should not smaller than 0x800. 686CNcomment:处理任务栈大小,任务栈大小不低于0x800。CNend 687* 688* @retval None 689* @par 依赖: 690* @li hi_diag.h:Describes DIAG APIs. 691CNcomment:文件用于描述DIAG相关接口。CNend 692*/ 693hi_void hi_diag_set_task_size(hi_u16 channel_task_size, hi_u16 process_task_size); 694 695 696typedef hi_u32 (*hi_diag_sys_msg_forward_func)(const hi_diag_layer_msg *diag_sys_msg, hi_u16 msg_level); 697typedef hi_u32 (*hi_diag_layer_msg_forward_func)(hi_u32 msg_id, hi_u16 src_module_id, hi_u16 dst_module_id, 698 const hi_void *packet, hi_u16 packet_size); 699typedef hi_u32 (*hi_diag_usr_msg_forward_func)(const hi_diag_layer_msg* diag_usr_msg, hi_u16 msg_level); 700 701/** 702* @ingroup iot_diag 703* @brief Register msg forward func. CNcomment:设置消息转发函数,替代默认从HSO输出。CNend 704* 705* @par 描述: 706* Register msg forward func. CNcomment:设置消息转发函数,替代默认从HSO输出。CNend 707* 708* @attention None. 709* @param diag_sys_msg_func [IN] type #hi_diag_sys_msg_forward_func forward function of sys_msg. 710CNcomment:sys_msg的转发函数。CNend 711* @param diag_layer_msg_func [IN] type #hi_diag_layer_msg_forward_func forward function of layer_msg. 712CNcomment:layder_msg的转发函数。CNend 713* @param diag_usr_msg_func [IN] type #hi_diag_usr_msg_forward_func forward function of usr_msg. 714CNcomment:usr_msg的转发函数。CNend 715* 716* @retval None 717* @par 依赖: 718* @li hi_diag.h:Describes DIAG APIs. 719CNcomment:文件用于描述DIAG相关接口。CNend 720*/ 721hi_void hi_diag_register_msg_forward_func(hi_diag_sys_msg_forward_func diag_sys_msg_func, 722 hi_diag_layer_msg_forward_func diag_layer_msg_func, hi_diag_usr_msg_forward_func diag_usr_msg_func); 723 724 725#endif 726