blob: 60407c55b78f08cbf2ce4f4618cc8fc594c5d49d [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/**
2 *
3 * @file commgt_api.h
4 * @brief
5 * This file is part of tools.
6 * ¹¤¾ßCommAgt½Ó¿Ú¹«¹²ÉùÃ÷
7 *
8 * @details
9 * @author Tools Team.
10 * @email
11 * @copyright Copyright (C) 2013 Sanechips Technology Co., Ltd.
12 * @warning
13 * @date 2019/02/02
14 * @version 1.4
15 * @pre
16 * @post
17 *
18 * @par
19 * Change History :
20 * ---------------------------------------------------------------------------
21 * date version author description
22 * ---------------------------------------------------------------------------
23 * 2013/01/14 1.0 lu.xieji Create file
24 * 2018/09/24 1.1 jiang.fenglin ºË¼äͨÐŹ²ÏíÄÚ´æÓÉ1Mµ÷ÕûΪ512K
25 * 2018/09/25 1.2 dai.kang »·Ðλº³åÇøÄÚ´æÓÉ3.5Mµ÷ÕûΪ2M
26 * 2018/12/25 1.3 dai.kang »·Ðλº³åÇøÄÚ´æÓɾ²Ì¬·ÖÅäµ÷ÕûΪzOss_GetUB¶¯Ì¬·Ö±ð
27 * 2019/02/02 1.4 jiang.fenglin ÐÞ¸Ä×¢ÊÍ·½Ê½Îªdoxygen
28 * 2019/03/11 1.5 dai.kang Ö§³ÖÎïÀí²ãlog + ap<->cp logÇø¼ä¶¯Ì¬·ÖÅä
29 * 2019/05/13 1.6 dai.kang psÓëphy¼äµÄ»·ÐÎbufferÉÏÏÂÐзֿªÉêÇ룻ap²àbuffer¿Õ¼äλÖõ÷Õû
30 * ---------------------------------------------------------------------------
31 *
32 *
33 */
34
35#ifndef COMM_AGT_H_
36#define COMM_AGT_H_
37
38#include "ram_config.h"
39#include "ZspTrace.h"
40
41#define MAX_PACKET_LEN (0x10000)
42#define MAX_ENCODE_PACKET_LEN (MAX_PACKET_LEN * 2)
43
44// Buffer »ùµØÖ·
45extern UINT32 g_zToolAgtBaseDDR;
46
47#define COMM_SEND_BUFFER_BASE_ADDR (g_zToolAgtBaseDDR)
48#define COMM_SEND_BUFFER_SIZE (0x77000)
49
50#define COMM_RECV_BUFFER_BASE_ADDR (COMM_SEND_BUFFER_BASE_ADDR + COMM_SEND_BUFFER_SIZE)
51#define COMM_RECV_BUFFER_SIZE (0x0)
52
53#define COMM_READ_BUFFER_BASE_ADDR (COMM_RECV_BUFFER_BASE_ADDR + COMM_RECV_BUFFER_SIZE)
54#define COMM_READ_BUFFER_SIZE (0x0)
55
56#define COMM_ENCODE_BUFFER_BASE_ADDR (COMM_READ_BUFFER_BASE_ADDR + COMM_READ_BUFFER_SIZE)
57#define COMM_ENCODE_BUFFER_SIZE (0x0)
58
59#define COMM_DECODE_BUFFER_BASE_ADDR (COMM_ENCODE_BUFFER_BASE_ADDR + COMM_ENCODE_BUFFER_SIZE)
60#define COMM_DECODE_BUFFER_SIZE (0x0)
61
62// GSM buff
63#define ZCAT_GSM_BUFFER_BASE_ADDR (COMM_DECODE_BUFFER_BASE_ADDR + COMM_DECODE_BUFFER_SIZE)
64
65#ifdef _USE_L1G
66#define ZCAT_GSM_BUFFER_SIZE (0x8000)
67#else
68#define ZCAT_GSM_BUFFER_SIZE (0x0)
69#endif
70
71#define COMM_ARM1_ALL_ADDR (ZCAT_GSM_BUFFER_BASE_ADDR + ZCAT_GSM_BUFFER_SIZE)
72#define COMM_ARM1_ALL_SIZE (0x100)
73#define COMM_ARM1_TICK_ADDR (COMM_ARM1_ALL_ADDR)
74#define COMM_ARM1_TICK_SIZE (0x4)
75#define COMM_ARM1_ORITIME_ADDR (COMM_ARM1_TICK_ADDR + COMM_ARM1_TICK_SIZE)
76#define COMM_ARM1_ORITIME_SIZE (0x4)
77#define COMM_ARM1_ORITICK_ADDR (COMM_ARM1_ORITIME_ADDR + COMM_ARM1_ORITIME_SIZE)
78#define COMM_ARM1_ORITICK_SIZE (0x4)
79
80#if ((COMM_ARM1_TICK_SIZE + COMM_ARM1_ORITIME_SIZE + COMM_ARM1_ORITICK_SIZE) > COMM_ARM1_ALL_SIZE)
81#error "tool ram overflow!"
82#endif
83
84// PS CPU <-->PHY CPU
85#define COMM_PS_TO_PHY_BASE_ADDR (COMM_ARM1_ALL_ADDR + COMM_ARM1_ALL_SIZE)
86#define COMM_PS_TO_PHY_SIZE (0x100)
87
88#define COMM_PHY_TO_PS_BASE_ADDR (COMM_PS_TO_PHY_BASE_ADDR + COMM_PS_TO_PHY_SIZE)
89#define COMM_PHY_TO_PS_SIZE (0x100)
90
91#define ZCAT_KERNEL_TO_CP_BASE_ADDR (COMM_PHY_TO_PS_BASE_ADDR + COMM_PHY_TO_PS_SIZE)
92#define ZCAT_KERNEL_TO_CP_BUFFER_SIZE (0x4000)
93
94#define ZCAT_APP_TO_CP_BASE_ADDR (ZCAT_KERNEL_TO_CP_BASE_ADDR + ZCAT_KERNEL_TO_CP_BUFFER_SIZE)
95#define ZCAT_APP_TO_CP_BUFFER_SIZE (0x4000)
96
97#define COMM_CP_TO_AP_BASE_ADDR (ZCAT_APP_TO_CP_BASE_ADDR + ZCAT_APP_TO_CP_BUFFER_SIZE)
98#ifdef CONFIG_SINGLECORE
99#define COMM_CP_TO_AP_SIZE (0)
100#else
101#define COMM_CP_TO_AP_SIZE (0x20000)
102#endif
103
104#define COMM_AP_TO_CP_BASE_ADDR (COMM_CP_TO_AP_BASE_ADDR + COMM_CP_TO_AP_SIZE)
105#ifdef CONFIG_SINGLECORE
106#define COMM_AP_TO_CP_SIZE (0)
107#else
108#define COMM_AP_TO_CP_SIZE (0x8000)
109#endif
110
111#define TOOL_AGENT_RAM_SIZE (COMM_SEND_BUFFER_SIZE + COMM_RECV_BUFFER_SIZE + COMM_READ_BUFFER_SIZE + COMM_ENCODE_BUFFER_SIZE + \
112 COMM_DECODE_BUFFER_SIZE + ZCAT_GSM_BUFFER_SIZE + COMM_ARM1_ALL_SIZE + COMM_PS_TO_PHY_SIZE + \
113 COMM_PHY_TO_PS_SIZE + ZCAT_KERNEL_TO_CP_BUFFER_SIZE + ZCAT_APP_TO_CP_BUFFER_SIZE + COMM_CP_TO_AP_SIZE + \
114 COMM_AP_TO_CP_SIZE)
115
116/* MODEM PRINT Ä£¿é±àºÅ */
117#define SUBMDL_TOOLAGENT_SET (85)
118#define SUBMDL_ZCATAGT (SUBMDL_TOOLAGENT_SET + 0) /* ZCAT¹¤¾ß´úÀí */
119#define SUBMDL_TOOLCOMMON (SUBMDL_TOOLAGENT_SET + 1) /* TOOL COMMON */
120#define SUBMDL_COMM (SUBMDL_TOOLAGENT_SET + 2) /* ¹¤¾ßͨѶ¹ÜÀí */
121#define SUBMDL_NVAGT (SUBMDL_TOOLAGENT_SET + 3) /* NV¹¤¾ß´úÀí */
122
123/* ͨѶģ¿éºÅ */
124#define MDL_TOOLS_BASE (100)
125#define MDL_WINTRACE (MDL_TOOLS_BASE + 1) /* WinTrace */
126#define MDL_NVEDIT (MDL_TOOLS_BASE + 3) /* NvTool */
127#define MDL_VUART1 (MDL_TOOLS_BASE + 4) /* Virtual of Serial Comm1,used in SimEnv */
128#define MDL_EFSTOOL (MDL_TOOLS_BASE + 7) /* EfsTool */
129#define MDL_PTET (MDL_TOOLS_BASE + 10) /* ЭÒéÕ»²âÊÔ¹¤¾ß */
130#define MDL_ZCAT (MDL_TOOLS_BASE + 15) /* ZCAT¹¤¾ß */
131#define MDL_NVTOOL (MDL_TOOLS_BASE + 16) /* NvTool */
132#define MDL_AUDIO (MDL_TOOLS_BASE + 17) /* audio */
133
134#define MDL_SIMTH (MDL_TOOLS_BASE + 18) /* TH */
135
136/*ÓëwincommÎÕÊÖ: Ó¦´ðÊÇ·ñ¿ªÆôHDLC±àÂë*/
137#define COMM_HEADER_PAD_HDLC (0xAB)
138#define COMM_HEADER_MSG_TYPE_HDLC (0x4)
139#define COMM_HEADER_RESERVED_HDLC (0xBBBB)
140#define COMM_ACK_HDLC_READY (0x2)
141
142#ifdef _OS_WIN
143#define MDL_PHONE (MDL_VUART1) /* windows ·ÂÕæ»·¾³ */
144#else
145#define MDL_PHONE (1) /* ÊÖ»ú */
146#endif
147
148#define ZCAT_MODE_INVALID (UINT32)0
149
150typedef enum
151{
152 ZCAT_MODE_AP_USB = 0xC1,
153 ZCAT_MODE_AP_NET,
154 ZCAT_MODE_AP_TF,
155 ZCAT_MODE_AP_FS,
156 ZCAT_MODE_CP_USB,
157 ZCAT_MODE_CP_TF,
158 ZCAT_MODE_CP_NET,
159 ZCAT_MODE_CP_FS,
160#ifdef _USE_VEHICLE_DC
xf.libdd93d52023-05-12 07:10:14 -0700161 ZCAT_MODE_CAP_FS,
xf.li9d1a0e12023-09-20 01:43:20 -0700162 ZCAT_MODE_CAP_NET,
lh9ed821d2023-04-07 01:36:19 -0700163#endif
xf.liaa4d92f2023-09-13 00:18:58 -0700164 ZCAT_MODE_LOG_OFF
lh9ed821d2023-04-07 01:36:19 -0700165} E_ZCAT_MODE;
166
167typedef enum
168{
169 ZCAT_IPC_SYN = 0xA0,
170 ZCAT_IPC_ACK,
171 ZCAT_IPC_ESTABLISHED,
172 ZCAT_IPC_SET_TTY,
173 ZCAT_IPC_SET_PERIPHERAL_MODE,
174 ZCAT_IPC_STOP,
175 ZCAT_IPC_START,
176 ZCAT_IPC_EXIT,
177#ifdef _USE_VEHICLE_DC
178 ZCAT_IPC_ALLOC_CAP_SMLOGBUF,
179#endif
xf.li9d1a0e12023-09-20 01:43:20 -0700180 ZCAT_IPC_READ_IRAM_ZCAT_MODE,
181 ZCAT_IPC_SET_VEHICLE_WAKE_SIGN,
lh9ed821d2023-04-07 01:36:19 -0700182} E_ZCAT_IPC_HANDSHAKE;
183
184
185#define COMM_AP_FD 1001
186#define COMM_SINGLE_CORE_FD 1002
187#define COMM_CP_TF_FD 1234
188
189#define ZCAT_MEM_TYPE_KERNEL 0
190#define ZCAT_MEM_TYPE_USER 1
191
192#define HDLC_DECODE_CONTINUE (0x00)
193#define HDLC_DECODE_OK (0x01)
194#define HDLC_DECODE_FIRST_ESCAPE (0x02)
195#define HDLC_DECODE_DROP (0x03)
196
197
198/* zcatÈ«¾ÖÐÅÏ¢ */
199typedef struct
200{
201 int status;
202 int peripheral_mode;
203 char usblog_path[8];
204} T_ZCAT_CONFIG_INFO;
205
206
207// Ä£¿é»Øµ÷º¯Êý
208typedef VOID (*ModuleFunc)(UINT32 msgID/*ÎÞÓÃ*/, const UINT8 *buf, UINT32 msgLen);
209
210typedef enum
211{
212 LINK_CONNECT, /* Á´Â·½¨Á¢ÏûÏ¢ */
213 LINK_BREAK, /* Á´Â·¶Ï¿ªÏûÏ¢ */
214
215 MAX_LINK_INFO
216} LINK_INFO;
217
218typedef enum
219{
220 COMM_RET_SUCCESS, /* Êý¾Ý³É¹¦¼ÓÈë¶ÓÁÐ,µÈ´ý·¢ËÍ */
221 COMM_ERR_NOTINIT, /* ·¢ËÍʧ°Ü,ͨѶ´úÀíûÓгõʼ»¯ */
222 COMM_ERR_LINKBREAK, /* ·¢ËÍʧ°Ü,Á´Â·ÒѾ­¶Ï¿ª */
223 COMM_ERR_DATALEN, /* ·¢ËÍʧ°Ü,ÏûÏ¢ÄÚÈݳ¤¶È³¬¹ý×î´ó³¤¶È */
224 COMM_ERR_MEM, /* ·¢ËÍʧ°Ü,ÄÚ´æ²Ù×÷ʧ°Ü */
225 COMM_ERR_MUTEX, /* ·¢ËÍʧ°Ü,»¥³âÌå³öÏÖ´íÎó */
226
227 MAX_COMM_ERR
228} COMM_RET;
229
230typedef enum
231{
232 FUNC_RET_FAILURE,
233 FUNC_RET_SUCCESS,
234
235 MAX_FUNC_RET
236} FUNC_RET;
237
238// Comm½á¹¹¶¨Òå
239typedef struct
240{
241 UINT8 msg_type; /* ÏûÏ¢ÀàÐÍ */
242 UINT8 pad; /* Ìî³äλ */
243 UINT16 reserved; /* ±£Áô×ֶΣ¬ÌîΪ0xAAAA */
244 UINT8 tgt_mdl_no; /* Ä¿±ê(½ÓÊÕÏûÏ¢)Ä£¿éÄ£¿éºÅ */
245 UINT8 tgt_submdl_no; /* Ä¿±ê(½ÓÊÕÏûÏ¢)Ä£¿é×ÓÄ£¿éºÅ */
246 UINT8 src_mdl_no; /* Ô´(·¢ËÍÏûÏ¢)Ä£¿éÄ£¿éºÅ */
247 UINT8 src_submdl_no; /* Ô´(·¢ËÍÏûÏ¢)Ä£¿é×ÓÄ£¿éºÅ */
248 UINT32 buf_len; /* ÏûÏ¢Êý¾Ý³¤¶È(²»º¬ÏûϢͷ) */
249} T_COMM_TYPE;
250
251/* ´òÓ¡»º³åÇø */
252typedef struct
253{
254 UINT32 capacity; /* »º³åÇøÈÝÁ¿*/
255 volatile UINT32 readPoint; /* ¶ÁÖ¸Õë */
256 volatile UINT32 writePoint; /* дָÕë */
257 UINT32 symbol; /* ¿ØÖÆ¿é±êʶ·û */
258 UINT8 buf[1]; /* ´òÓ¡»º³åÇø */
259} T_RINGBUFFER;
260
261typedef struct
262{
263 UINT8 *buf;
264 UINT32 bufIndex; // Ö¸ÕëÆ«ÒÆ
265 UINT32 bufSize;
266} T_HDLC_BUFFER_TYPE;
267
268
269/**
270 * @brief ´Ócomm»·Ðλº³åÖÐÉêÇëÒ»¿éÄÚ´æ
271 * @param[in] size ÉêÇëµÄʵ¼ÊÓÐÓÃÊý¾ÝµÄ¿Õ¼ä´óС
272 * @return Èç¹û³É¹¦£¬·µ»ØÄÚ´æÖ¸Õ룬·ñÔò·µ»ØNULL
273 * @note ÉêÇëµÄÄÚ´æÖ»ÓÃÓÚcommµÄÊý¾Ý·¢ËÍ£¬É÷ÓÃ!!! \n
274 Èç¹û·¢Ëͳɹ¦Ôò²»ÐèÊÍ·Å£»\n
275 δ·¢ËÍ»ò·¢ËͲ»³É¹¦Ôò±ØÐëµ÷ÓÃComm_Free½øÐÐÊÍ·Å£¬·ñÔòËÀÇÌÇÌ
276 * @see
277 */
278VOID* Comm_Malloc(UINT32 size);
279
280/**
281 * @brief ÊÍ·ÅÓÉComm_MallocÉêÇëµÄÄÚ´æ
282 * @param[in] mem_ptr ´ýÊͷŵÄcomm»º³åÇøÖÐÄÚ´æ¿éµÄÖ¸Õë
283 * @return void
284 * @note
285 * @see
286 */
287VOID Comm_Free(VOID *mem_ptr);
288
289/**
290 * @brief ZCATͨѶ¹ÜÀíÄ£¿é³õʼ»¯
291 * @param[in] void
292 * @return ³É¹¦·µ»ØZOSS_SUCCESS£»Ê§°Ü·µ»ØZOSS_ERROR
293 * @note
294 * @see
295 */
296UINT32 Comm_Init(VOID);
297
298/**
299 * @brief ZCATͨѶ¹ÜÀíÄ£¿é×¢Ïú½Ó¿Ú,
300 * @param[in] void
301 * @return void
302 * @note
303 * @see
304 */
305void Comm_Release(void);
306
307
308/**
309 * @brief ZCAT×ÓÄ£¿é×¢²á½Ó¿Ú \n
310 * Ìṩ¸ø¸÷¸ö×ÓÄ£¿éµ÷Óã¬×¢²á×ÓÄ£¿éÐÅÏ¢
311 * @param[in] submdl_no ×¢²áµÄ×ÓÄ£¿éºÅ£¬ÒѾ­ÔÚpub_mdldef.hÖж¨ÒåºÃ
312 * @param[in] uart_name ÕâÀïÒòΪÐèÇó±ä¸ü£¬µ¼Ö²ÎÊýuart_nameÎÞЧ,ÇëÒ»ÂÉÌîuart/0
313 * @param[in] moduleFunc ¸÷¸ö×ÓÄ£¿é»Øµ÷º¯Êý
314 * @return ³É¹¦·µ»ØZOSS_SUCCESS, ʧ°Ü·µ»ØZOSS_ERROR
315 * @note
316 * @see
317 */
318UINT32 zTools_CommReg(UINT8 submdl_no, const CHAR *uart_name, ModuleFunc moduleFunc);
319
320/**
321 * @brief ZCAT×ÓÄ£¿é×¢Ïú½Ó¿Ú \n
322 * Ìṩ¸ø¸÷¸ö×ÓÄ£¿éµ÷Óã¬×¢Ïú×ÓÄ£¿éÐÅÏ¢
323 * @param[in] submdl_no ½«Òª×¢ÏúµÄ×ÓÄ£¿éºÅ
324 * @return ³É¹¦·µ»ØZOSS_SUCCESS, ʧ°Ü·µ»ØZOSS_ERROR
325 * @note
326 * @see
327 */
328UINT32 zTools_CommUnReg(UINT8 submdl_no);
329
330/**
331 * @brief Ìṩ¸ø²»Í¬×ÓÄ£¿éÏò"ÍâÉè"·¢ËÍÊý¾ÝµÄ¹¦ÄÜ \n
332 * ¸øTraceAgtÄ£¿éʹÓÃ,Õâ¸öÊÇÒì²½½Ó¿Ú£¬Ö»¹Ü·¢ËͶø²»¹ÜÊÇ·ñÄܹ»ÊÕµ½
333 * ·¢ËÍÊý¾ÝÒ»°ãÏȵ½"ͳһ»º´æ"ÖУ¬È»ºó֪ͨ·¢ËÍÏß³ÌÓÐÊý¾Ý´ý·¢ËÍ
334 * @param[in] buf ·¢ËÍÊý¾Ý(±ØÐëÊÇÓÉComm_MallocÉêÇëµÄÄÚ´æ!!!)
335 * @param[in] buf_len ·¢ËÍÊý¾ÝµÄ³¤¶È
336 * @param[in] tgt_mdl_no Ä¿±êÄ£¿éºÅ£¬ÊÖ»ú»òPCµÈ
337 * @param[in] tgt_submdl_no Ä¿±ê×ÓÄ£¿éºÅ
338 * @param[in] src_submdl_no Ô´×ÓÄ£¿éºÅ
339 * @return ³É¹¦·µ»ØZOSS_SUCCESS, ·ñÔò·µ»ØZOSS_ERROR
340 * @note
341 * @see
342 */
343UINT32 zTools_SendData(UINT8 *buf, UINT32 buf_len,
344 UINT8 tgt_mdl_no, UINT8 tgt_submdl_no, UINT8 src_submdl_no);
345
346/**
347 * @brief ´´½¨ÐèÒªµÄ»º³åÇø
348 * Èç¹ûbuf²»ÎªNULL£¬ÔòÔÚÖ¸¶¨µØÖ·´´½¨»º³åÇø£»·ñÔò£¬ÉêÇëÒ»¿éÄÚ´æ×÷Ϊ»º³åÇø
349 * @param[in] buf »º³åÇøµØÖ·
350 * @param[in] bufSize »º³åÇø´óС
351 * @return ³É¹¦·µ»ØÖ¸Ïò»º³åÇø½á¹¹ÌåµÄÖ¸Õ룬·ñÔò·µ»ØNULL
352 * @note
353 * @see
354 */
355T_RINGBUFFER* CreateRingBuffer(UINT8 *buf, UINT32 bufSize);
356
357/**
358 * @brief ´´½¨ÐèÒªµÄ»º³åÇø,²¢ÇÒÖ¸¶¨±ê¼ÇλµÄÖµ
359 * Èç¹ûbuf²»ÎªNULL£¬ÔòÔÚÖ¸¶¨µØÖ·´´½¨»º³åÇø£»·ñÔò£¬ÉêÇëÒ»¿éÄÚ´æ×÷Ϊ»º³åÇø
360 * @param[in] buf »º³åÇøµØÖ·
361 * @param[in] bufSize »º³åÇø´óС
362 * @param[in] bufSize ±ê¼Çλ
363 * @return ³É¹¦·µ»ØÖ¸Ïò»º³åÇø½á¹¹ÌåµÄÖ¸Õ룬·ñÔò·µ»ØNULL
364 * @note
365 * @see
366 */
367T_RINGBUFFER* CreateRingBufferWithSymbol(UINT8 *buf, UINT32 bufSize, UINT32 symbol);
368
369/**
370 * @brief Åжϻº³åÇøÊÇ·ñÓÐЧ
371 * @param[in] ringBuf »·Ðλº³å
372 * @return ÊÇ·µ»ØTRUE,·ñ·µ»ØFALSE
373 * @note
374 * @see
375 */
376BOOL IsRingBufferValid(T_RINGBUFFER *ringBuf);
377
378/**
379 * @brief ½«»º³åÇøÖÿÕ
380 * @param[in] ringBuf »·Ðλº³åÇøÖ¸Õë
381 * @return void
382 * @note
383 * @see
384 */
385VOID EmptyRingBuffer(T_RINGBUFFER *ringBuf);
386
387/**
388 * @brief ½«Êý¾ÝдÈë»·Ðλº³å
389 * @param[in] ringBuf »·Ðλº³åÖ¸Õë
390 * @param[in] buf Êý¾Ý»º´æÖ¸Õë
391 * @param[in] len Êý¾Ý³¤¶È
392 * @param[in] flags Êý¾Ý»º´æÄÚ´æÀàÐÍ£º0:ÄÚºË̬,1:Óû§Ì¬
393 * @return ·µ»ØÐ´ÈëµÄʵ¼Ê³¤¶È
394 * @note
395 * @see
396 */
397UINT32 WriteRingBuffer(T_RINGBUFFER *ringBuf, UINT8 *buf, UINT32 len, UINT32 flags);
398
399/**
400 * @brief ¶Áȡһ¶Î»·Ðλº³åÇøµÄÊý¾Ýµ½Ä¿±ê»º´æ
401 * @param[in] ringBuf »·Ðλº³åÇøÖ¸Õë
402 * @param[in] buf Ä¿±ê»º´æÖ¸Õë
403 * @param[in] len Ä¿±ê»º´æ³¤¶È
404 * @param[in] flags Ä¿±ê»º´æÄÚ´æÀàÐÍ£º0:ÄÚºË̬,1:Óû§Ì¬
405 * @return ·µ»Ø¶ÁÈ¡³¤¶È
406 * @note
407 * @see
408 */
409UINT32 ReadRingBuffer(T_RINGBUFFER *ringBuf, UINT8 *buf, UINT32 len, UINT32 flags);
410
411/**
412 * @brief »ñÈ¡µ±Ç°Ring BufferÖпÕÏÐÇøµÄ´óС
413 * @param[in] ringBuf »·Ðλº³åÇøÖ¸Õë
414 * @return ·µ»Ø×Ö½ÚÊý
415 * @note
416 * @see
417 */
418UINT32 GetRingBufferSize(T_RINGBUFFER *ringBuf);
419
420/**
421 * @brief HDLC±àÂë
422 * @param[out] dest Ä¿±êT_HDLC_BUFFER_TYPEÖ¸Õë
423 * @param[in] src Ô´T_HDLC_BUFFER_TYPEÖ¸Õë
424 * @return ³É¹¦·µ»ØTRUE£»Ê§°Ü·µ»ØFALSE
425 * @note
426 * @see
427 */
428BOOL hdlc_encode(T_HDLC_BUFFER_TYPE *dest, const T_HDLC_BUFFER_TYPE *src);
429
430/**
431 * @brief ½«Êý¾Ý½øÐÐHDLC½âÂëÖÁÖ¸¶¨µÄµ¥ÏòFIFOÖÐ
432 * FIFOÖ»ÄÜ´ÓÍ·(0λÖÃ)°´Õû°ü¶Á³öÊý¾Ý»ò¶ªÆú£¬½âÂëʱ°´Ë³ÐòдÈëµ½FIFO£¬
433 * ÿÕÒµ½Ò»´ÎÕû°ü£¬Í£Ö¹Ð´È룬Ȼºó¶Á³öÊý¾Ý»òÕß¶ªÆú
434 * ¹ý³ÌÖÐÓò»µ½readPoint£¬Ê¼ÖÕΪ0
435 * @param[out] dest ½âÂëºó´æ´¢µÄFIFOÖ¸Õë
436 * @param[in] src ´ý½âÂëµÄ»º´æÖ¸Õë
437 * @param[in] len ´ý½âÂëµÄ»º´æ³¤¶È
438 * @return ·µ»Ø½âÂëµÄʵ¼Ê³¤¶È
439 * @note
440 * @see
441 */
442UINT32 hdlc_decode(T_RINGBUFFER *dest, unsigned char *src, unsigned int len);
443
444/**************************************************************************
445 CommAgt¹«¹²½Ó¿ÚÉùÃ÷
446**************************************************************************/
447
448/**************************************************************************
449*Ä£¿é½ÓÊÕÏûÏ¢»Øµ÷º¯Êý
450*²ÎÊý˵Ã÷:
451* (IN)
452* ucLinkMsg Á´Â·×´Ì¬
453* LINK_CONNECT Á´Â·½¨Á¢
454* LINK_BREAK Á´Â·¶Ï¿ª
455**************************************************************************/
456typedef void (* LINKRPTFUNC)(LINK_INFO ucLinkMsg);
457
458/**************************************************************************
459*ÆÕͨ×ÓÄ£¿é(²»ÓùØÐÄÏûÏ¢ID)½ÓÊÕÊý¾Ý»Øµ÷º¯Êý
460*²ÎÊý˵Ã÷:
461* (IN)
462* ucSrcModNo Ô´Ä£¿éºÅ
463* ucSrcSubModNo Ô´×ÓÄ£¿éºÅ
464* pBuf ÏûÏ¢Êý¾ÝÖ¸Õë
465* wLen ÏûÏ¢Êý¾Ý³¤¶È
466**************************************************************************/
467typedef void (* RECVFUNC)(unsigned char ucSrcModNo, unsigned char ucSrcSubModNo, const char *pBuf, unsigned short wLen);
468
469/**************************************************************************
470*À©Õ¹×ÓÄ£¿é(ʹÓÃÏûÏ¢ID)½ÓÊÕÊý¾Ý»Øµ÷º¯Êý
471*²ÎÊý˵Ã÷:
472* (IN)
473* ucSrcModNo Ô´Ä£¿éºÅ
474* ucSrcSubModNo Ô´×ÓÄ£¿éºÅ
475* dwMsgID ÏûÏ¢±àºÅ
476* pBuf ÏûÏ¢Êý¾ÝÖ¸Õë
477* wLen ÏûÏ¢Êý¾Ý³¤¶È
478**************************************************************************/
479typedef void (* RECVFUNCEX)(unsigned char ucSrcModNo, unsigned char ucSrcSubModNo, unsigned int dwMsgID, const char *pBuf, unsigned short wLen);
480
481/**************************************************************************
482*ÐéÄâ´®¿ÚÄ£¿é½ÓÊÕÊý¾Ý»Øµ÷º¯Êý,ʹÓÃÏûÏ¢ID
483*²ÎÊý˵Ã÷:
484* (IN)
485* ucSrcModNo Ô´Ä£¿éºÅ
486* ucSrcSubModNo Ô´×ÓÄ£¿éºÅ
487* ucTarSubModNo Ä¿±ê×ÓÄ£¿éºÅ
488* dwMsgID ÏûÏ¢±àºÅ
489* pBuf ÏûÏ¢Êý¾ÝÖ¸Õë
490* wLen ÏûÏ¢Êý¾Ý³¤¶È
491**************************************************************************/
492typedef void (* RECVFUNCUART)(unsigned char ucSrcModNo, unsigned char ucSrcSubModNo, unsigned char ucTarModNo, unsigned char ucTarSubModNo, unsigned int dwMsgID, const char *pBuf, unsigned short wLen);
493
494/**************************************************************************
495* º¯ÊýÃû³Æ£º Comm_Register
496* ¹¦ÄÜÃèÊö£º ÆÕͨģ¿é(²»ÓùØÐÄÏûÏ¢ID)×¢²á½Ó¿Ú(97ÓÃ)
497* ²ÎÊý˵Ã÷£º (IN)
498* ucModNo Ä£¿éºÅ
499* linkRptFunc Ä£¿é½ÓÊÕÏûÏ¢»Øµ÷º¯Êý
500* (OUT)
501* ·µ »Ø Öµ£º VOID
502* ÆäËü˵Ã÷£º ûÓзµ»ØÖµ
503**************************************************************************/
504FUNC_RET Comm_Register(unsigned char ucModNo, LINKRPTFUNC linkRptFunc);
505
506/**************************************************************************
507* º¯ÊýÃû³Æ£º Comm_RegisterSub
508* ¹¦ÄÜÃèÊö£º ÆÕͨģ¿é(²»ÓùØÐÄÏûÏ¢ID)×ÓÄ£¿é×¢²á½Ó¿Ú(97ÓÃ)
509* ²ÎÊý˵Ã÷£º (IN)
510* ucModNo Ä£¿éºÅ
511* ucSubModNo ×ÓÄ£¿éºÅ
512* recvFunc ×ÓÄ£¿é½ÓÊÕÊý¾Ý»Øµ÷º¯Êý
513* (OUT)
514* ·µ »Ø Öµ£º
515* FUNC_RET_SUCCESS ×¢²á³É¹¦
516* FUNC_RET_FAILURE ×¢²áʧ°Ü,Á½ÖÖ¿ÉÄÜÇé¿ö,Ò»ÊÇ×ÓÄ£¿éºÅÖØ¸´ÁË,¶þÊÇ×¢²áµÄ×ÓÄ£¿éÊýÒѾ­µ½×î´óÏÞ¶È
517* ÆäËü˵Ã÷£º Ö»ÊÇ×¢²áÔÚͨѶ´úÀíÖÐ
518**************************************************************************/
519FUNC_RET Comm_RegisterSub(unsigned char ucModNo, unsigned char ucSubModNo, RECVFUNC recvFunc);
520
521/**************************************************************************
522* º¯ÊýÃû³Æ£º Comm_SendMsg
523* ¹¦ÄÜÃèÊö£º ÆÕͨģ¿é(²»ÓùØÐÄÏûÏ¢ID)·¢ËÍÏûÏ¢½Ó¿Ú(97ÓÃ)
524* ²ÎÊý˵Ã÷£º (IN)
525* ucTarModNo Ä¿±êÄ£¿éºÅ
526* ucTarSubModNo Ä¿±ê×ÓÄ£¿éºÅ
527* ucSrcModNo Ô´Ä£¿éºÅ
528* ucSrcSubModNo Ô´×ÓÄ£¿éºÅ
529* pBuf ÏûÏ¢Êý¾ÝÖ¸Õë
530* wLen ÏûÏ¢Êý¾Ý³¤¶È,²»ÄÜ´óÓÚMAX_COMM_LEN
531* (OUT)
532* ·µ »Ø Öµ£º
533* COMM_RET_SUCCESS ·¢Ëͳɹ¦
534* COMM_ERR_NOTINIT ·¢ËÍʧ°Ü,ͨѶ´úÀíÉÐδ³õʼ»¯
535* COMM_ERR_LINKBREAK ·¢ËÍʧ°Ü,ÒòΪÁ´Â·Î´Á¬½Ó(ÓÃÓÚPC²à)»ò¶Ë¿Úδ´ò¿ª(ÓÃÓÚÊÖ»ú²à)
536* COMM_ERR_DATALEN ·¢ËÍʧ°Ü,ÏûÏ¢ÄÚÈݳ¬¹ý×î´ó³¤¶È
537* COMM_ERR_MEM ·¢ËÍʧ°Ü,ÄÚ´æ²Ù×÷ʧ°Ü
538* COMM_ERR_MUTEX ·¢ËÍʧ°Ü,»¥³âÌå³öÏÖ´íÎó
539* ÆäËü˵Ã÷£º
540**************************************************************************/
541COMM_RET Comm_SendMsg(unsigned char ucTarModNo, unsigned char ucTarSubModNo, \
542 unsigned char ucSrcModNo, unsigned char ucSrcSubModNo, \
543 const char * pBuf, unsigned short wLen);
544
545/**************************************************************************
546* º¯ÊýÃû³Æ£º Comm_GetStatus
547* ¹¦ÄÜÃèÊö£º »ñȡͨѶ´úÀíÓëͨѶ¹¤¾ßµÄÁ´Â·×´Ì¬
548* ²ÎÊý˵Ã÷£º (IN)
549* ucModNo Ä£¿éºÅ
550* (OUT)
551* ·µ »Ø Öµ£º
552* FUNC_RET_SUCCESS Á´Â·ÒÑÁ¬½Ó
553* FUNC_RET_FAILURE Á´Â·Î´Á¬½Ó
554* ÆäËü˵Ã÷£º
555**************************************************************************/
556FUNC_RET Comm_GetStatus(unsigned char ucModNo);
557
558/**************************************************************************
559* º¯ÊýÃû³Æ£º Comm_UnRegister
560* ¹¦ÄÜÃèÊö£º Ä£¿é×¢Ïú½Ó¿Ú
561* ²ÎÊý˵Ã÷£º (IN)
562* ucModNo Ä£¿éºÅ
563* (OUT)
564* ·µ »Ø Öµ£º
565* FUNC_RET_SUCCESS ×¢Ïú³É¹¦
566* FUNC_RET_FAILURE ×¢Ïúʧ°Ü
567* ÆäËü˵Ã÷£º
568**************************************************************************/
569FUNC_RET Comm_UnRegister(unsigned char ucModNo);
570
571/**************************************************************************
572* º¯ÊýÃû³Æ£º Comm_UnRegisterSub
573* ¹¦ÄÜÃèÊö£º ÆÕͨģ¿é(²»ÓùØÐÄÏûÏ¢ID)×ÓÄ£¿é×¢Ïú½Ó¿Ú
574* ²ÎÊý˵Ã÷£º (IN)
575* ucModNo Ä£¿éºÅ
576* ucSubModNo ×ÓÄ£¿éºÅ
577* (OUT)
578* ·µ »Ø Öµ£º
579* FUNC_RET_SUCCESS ×¢Ïú³É¹¦
580* FUNC_RET_FAILURE ×¢Ïúʧ°Ü
581* ÆäËü˵Ã÷£º
582**************************************************************************/
583FUNC_RET Comm_UnRegisterSub(unsigned char ucModNo, unsigned char ucSubModNo);
584
585/**************************************************************************
586* º¯ÊýÃû³Æ£º Comm_RegisterEx
587* ¹¦ÄÜÃèÊö£º À©Õ¹Ä£¿é(ʹÓÃÏûÏ¢ID)×¢²á½Ó¿Ú
588* ²ÎÊý˵Ã÷£º (IN)
589* ucModNo Ä£¿éºÅ
590* linkRptFunc Ä£¿é½ÓÊÕÏûÏ¢»Øµ÷º¯Êý
591* (OUT)
592* ·µ »Ø Öµ£º VOID
593* ÆäËü˵Ã÷£º ûÓзµ»ØÖµ
594**************************************************************************/
595FUNC_RET Comm_RegisterEx(unsigned char ucModNo, LINKRPTFUNC linkRptFunc);
596
597/**************************************************************************
598* º¯ÊýÃû³Æ£º Comm_RegisterSubEx
599* ¹¦ÄÜÃèÊö£º À©Õ¹Ä£¿é(ʹÓÃÏûÏ¢ID)×ÓÄ£¿é×¢²á½Ó¿Ú
600* ²ÎÊý˵Ã÷£º (IN)
601* ucModNo Ä£¿éºÅ
602* ucSubModNo ×ÓÄ£¿éºÅ
603* recvFunc ×ÓÄ£¿é½ÓÊÕÊý¾Ý»Øµ÷º¯Êý
604* (OUT)
605* ·µ »Ø Öµ£º
606* FUNC_RET_SUCCESS ×¢²á³É¹¦
607* FUNC_RET_FAILURE ×¢²áʧ°Ü,Á½ÖÖ¿ÉÄÜÇé¿ö,Ò»ÊÇ×ÓÄ£¿éºÅÖØ¸´ÁË,¶þÊÇ×¢²áµÄ×ÓÄ£¿éÊýÒѾ­µ½×î´óÏÞ¶È
608* ÆäËü˵Ã÷£º Ö»ÊÇ×¢²áÔÚͨѶ´úÀíÖÐ
609**************************************************************************/
610FUNC_RET Comm_RegisterSubEx(unsigned char ucModNo, unsigned char ucSubModNo, RECVFUNCEX recvFunc);
611
612/**************************************************************************
613* º¯ÊýÃû³Æ£º Comm_SendMsgEx
614* ¹¦ÄÜÃèÊö£º À©Õ¹Ä£¿é(ʹÓÃÏûÏ¢ID)·¢ËÍÏûÏ¢½Ó¿Ú
615* ²ÎÊý˵Ã÷£º (IN)
616* ucTarModNo Ä¿±êÄ£¿éºÅ
617* ucTarSubModNo Ä¿±ê×ÓÄ£¿éºÅ
618* ucSrcModNo Ô´Ä£¿éºÅ
619* ucSrcSubModNo Ô´×ÓÄ£¿éºÅ
620* dwMsgID ÏûÏ¢±àºÅ
621* pBuf ÏûÏ¢ÄÚÈÝÖ¸Õë
622* wLen ÏûÏ¢ÄÚÈݳ¤¶È,²»ÄÜ´óÓÚMAX_COMM_LEN - MSG_HEADER_LEN
623* (OUT)
624* ·µ »Ø Öµ£º
625* COMM_RET_SUCCESS ·¢Ëͳɹ¦
626* COMM_ERR_NOTINIT ·¢ËÍʧ°Ü,ͨѶ´úÀíÉÐδ³õʼ»¯
627* COMM_ERR_LINKBREAK ·¢ËÍʧ°Ü,ÒòΪÁ´Â·Î´Á¬½Ó(ÓÃÓÚPC²à)»ò¶Ë¿Úδ´ò¿ª(ÓÃÓÚÊÖ»ú²à)
628* COMM_ERR_DATALEN ·¢ËÍʧ°Ü,ÏûÏ¢ÄÚÈݳ¬¹ý×î´ó³¤¶È
629* COMM_ERR_MEM ·¢ËÍʧ°Ü,ÄÚ´æ²Ù×÷ʧ°Ü
630* COMM_ERR_MUTEX ·¢ËÍʧ°Ü,»¥³âÌå³öÏÖ´íÎó
631* ÆäËü˵Ã÷£º
632**************************************************************************/
633COMM_RET Comm_SendMsgEx(unsigned char ucTarModNo, unsigned char ucTarSubModNo, \
634 unsigned char ucSrcModNo, unsigned char ucSrcSubModNo, \
635 unsigned int dwMsgID, const char * pBuf, unsigned short wLen);
636
637/**************************************************************************
638* º¯ÊýÃû³Æ£º Comm_RegisterUart
639* ¹¦ÄÜÃèÊö£º ÐéÄâ´®¿ÚÄ£¿é×¢²á½Ó¿Ú,Ö§³ÖÏûÏ¢ID,ÕâÖ־Ͳ»ÓÃ×¢²á×ÓÄ£¿éÁË
640* ²ÎÊý˵Ã÷£º (IN)
641* ucModNo Ä£¿éºÅ
642* linkRptFunc Ä£¿é½ÓÊÕÏûÏ¢»Øµ÷º¯Êý
643* recvFunc Ä£¿é½ÓÊÕÊý¾Ý»Øµ÷º¯Êý
644* (OUT)
645* ·µ »Ø Öµ£º VOID
646* ÆäËü˵Ã÷£º ûÓзµ»ØÖµ
647**************************************************************************/
648FUNC_RET Comm_RegisterUart(unsigned char ucModNo, LINKRPTFUNC linkRptFunc, RECVFUNCUART recvFunc);
649
650/**************************************************************************
651* º¯ÊýÃû³Æ£º Comm_TaskSendToPhone
652* ¹¦ÄÜÃèÊö£º ±¾½Ó¿ÚÌṩ¸øÐ­ÒéÕ»µÄ²âÊÔ¹¤¾ßʹÓÃ,Ä£ÄâÈÎÎñ¸ø·¢Ë͵ÄÈÎÎñ»Ø¸´ÏûÏ¢µÄ½Ó¿Ú
653* ²ÎÊý˵Ã÷£º(IN)
654* msg_id ·¢ËÍÏûÏ¢±àºÅ£¬Õâ¸ö¿ÉÒÔÓÉÓû§×Ô¼º¶¨Òå
655* buf ÏûÏ¢Êý¾ÝÖ¸Õë
656* buf_len ÏûÏ¢Êý¾Ý³¤¶È
657* tgtMdlNo Ä¿±êÄ£¿éºÅ£¬ÊÖ»ú»òPCµÈ
658* tgtSubMdlNo Ä¿±ê×ÓÄ£¿éºÅ
659* srcSubMdlNo Ô´×ÓÄ£¿éºÅ
660* srcTask Ô´ÈÎÎñID
661* tgtTask Ä¿±êÈÎÎñID
662* (OUT)
663* ·µ »Ø Öµ£º Èç¹û·¢Ëͳɹ¦£¬·µ»ØZOSS_SUCCESS,·ñÔò·µ»ØZOSS_ERROR
664* ÆäËü˵Ã÷£º ÎÞ
665**************************************************************************/
666unsigned int Comm_TaskSendToPhone(unsigned int msg_id, const unsigned char *buf, unsigned short bufLen, \
667 unsigned char tgtMdlNo, unsigned char tgtSubMdlNo, unsigned char srcSubMdlNo, void * srcTask, void * tgtTask);
668
669
670/**
671 * @brief ·¢ËÍÊý¾Ýµ½"ͳһ»º´æ"ÖÐ
672 * @param[in] buf ·¢ËÍÊý¾Ý(±ØÐëÊÇÓÉComm_MallocÉêÇëµÄÄÚ´æ!!!)
673 * @param[in] buf_len ·¢ËÍÊý¾ÝµÄ³¤¶È
674 * @param[in] tgt_mdl_no Ä¿±êÄ£¿éºÅ£¬ÊÖ»ú»òPCµÈ
675 * @param[in] tgt_submdl_no Ä¿±ê×ÓÄ£¿éºÅ
676 * @param[in] src_submdl_no Ô´×ÓÄ£¿éºÅ
677 * @return ³É¹¦·µ»ØZOSS_SUCCESS, ·ñÔò·µ»ØZOSS_ERROR
678 * @note
679 * @see
680 */
681VOID Comm_HeaderInit(T_COMM_TYPE *commHeader, UINT32 buf_len,
682 UINT8 tgt_mdl_no, UINT8 tgt_submdl_no, UINT8 src_submdl_no);
683#endif /*COMM_PUB_H_*/
684