blob: cacaafcdb7c1aed172d1731792b09cb8943a8b8e [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/**
2 * ±¾³ÌÐò·ûºÏGPLÌõÔ¼
3 * Ò»×é²Ù×÷´®¿ÚµÄº¯Êý
4 * Beneboy 2003-5-16
5 */
6
7#ifndef _PORT_COM_H
8#define _PORT_COM_H
9
10
11typedef struct
12{
13 char prompt; // prompt after reciving data
14 int baudrate; // baudrate
15 char databit; // data bits, 5, 6, 7, 8
16 char debug; // debug mode, 0: none, 1: debug
17 char echo; // echo mode, 0: none, 1: echo
18 char fctl; // flow control, 0: none, 1: hardware, 2: software
19 char tty; // tty: 0, 1, 2, 3, 4, 5, 6, 7
20 char parity; // parity 0: none, 1: odd, 2: even
21 char stopbit; // stop bits, 1, 2
22 int reserved; // reserved, must be zero
23} portinfo_t, *pportinfo_t;
24
25
26typedef enum
27{
28 NO_WAIT = 0,
29 WAIT_ALL
30} WAIT_FLAG;
31
32/**
33 * ´ò¿ª´®¿Ú, ·µ»ØÎļþÃèÊö·û
34 * pportinfo: ´ýÉèÖõĴ®¿ÚÐÅÏ¢
35 */
36int PortOpen(pportinfo_t pportinfo,int mode);
37
38/**
39 * ¶Ë¿Ú³õʼ»¯
40 */
41int PortInit(int mode);
42/**
43 * ÉèÖô®¿Ú
44 * fdcom: ´®¿ÚÎļþÃèÊö·û, pportinfo: ´ýÉèÖõĴ®¿ÚÐÅÏ¢
45 */
46int PortSet(int fd);
47/**
48 * ¹Ø±Õ´®¿Ú
49 * fdcom: ´®¿ÚÎļþÃèÊö·û
50 */
51void PortClose(int fd);
52
53/**
54 * PortSend
55 * fd: ´®¿ÚÃèÊö·û,
56 * data: ´ý·¢ËÍÊý¾ÝÖ¸Õë
57 * datalen: Êý¾Ý³¤¶È
58 * ·µ»ØÊµ¼Ê·¢Ëͳ¤¶È
59 */
60int PortSend(int fd, unsigned char* data, int datalen, int flag);
61
62/**
63 * PortRecv
64 * ²ÎÊý£º
65 * fd: ´®¿ÚÃèÊö·û,
66 * data: ´ý½ÓÊÕÊý¾ÝÖ¸Õë
67 * datalen: Êý¾Ý³¤¶È
68 * ·µ»ØÊµ¼Ê¶ÁÈëµÄ×Ö½ÚÊý
69 */
70int PortRecv(int fd, unsigned char* data, int datalen, int flag);
71
72/**
73 * ´®¿Ú²âÊÔʱÉèÖô®¿Ú
74 * fdcom: ´®¿ÚÎļþÃèÊö·û, pportinfo: ´ýÉèÖõĴ®¿ÚÐÅÏ¢
75 */
76int uart_set(int fd);
77
78
79#endif
80