/** | |
* ±¾³ÌÐò·ûºÏGPLÌõÔ¼ | |
* Ò»×é²Ù×÷´®¿ÚµÄº¯Êý | |
* Beneboy 2003-5-16 | |
*/ | |
#ifndef _PORT_COM_H | |
#define _PORT_COM_H | |
typedef struct | |
{ | |
char prompt; // prompt after reciving data | |
int baudrate; // baudrate | |
char databit; // data bits, 5, 6, 7, 8 | |
char debug; // debug mode, 0: none, 1: debug | |
char echo; // echo mode, 0: none, 1: echo | |
char fctl; // flow control, 0: none, 1: hardware, 2: software | |
char tty; // tty: 0, 1, 2, 3, 4, 5, 6, 7 | |
char parity; // parity 0: none, 1: odd, 2: even | |
char stopbit; // stop bits, 1, 2 | |
int reserved; // reserved, must be zero | |
} portinfo_t, *pportinfo_t; | |
typedef enum | |
{ | |
NO_WAIT = 0, | |
WAIT_ALL | |
} WAIT_FLAG; | |
/** | |
* ´ò¿ª´®¿Ú, ·µ»ØÎļþÃèÊö·û | |
* pportinfo: ´ýÉèÖõĴ®¿ÚÐÅÏ¢ | |
*/ | |
int PortOpen(pportinfo_t pportinfo,int mode); | |
/** | |
* ¶Ë¿Ú³õʼ»¯ | |
*/ | |
int PortInit(int mode); | |
/** | |
* ÉèÖô®¿Ú | |
* fdcom: ´®¿ÚÎļþÃèÊö·û, pportinfo: ´ýÉèÖõĴ®¿ÚÐÅÏ¢ | |
*/ | |
int PortSet(int fd); | |
/** | |
* ¹Ø±Õ´®¿Ú | |
* fdcom: ´®¿ÚÎļþÃèÊö·û | |
*/ | |
void PortClose(int fd); | |
/** | |
* PortSend | |
* fd: ´®¿ÚÃèÊö·û, | |
* data: ´ý·¢ËÍÊý¾ÝÖ¸Õë | |
* datalen: Êý¾Ý³¤¶È | |
* ·µ»ØÊµ¼Ê·¢Ëͳ¤¶È | |
*/ | |
int PortSend(int fd, unsigned char* data, int datalen, int flag); | |
/** | |
* PortRecv | |
* ²ÎÊý£º | |
* fd: ´®¿ÚÃèÊö·û, | |
* data: ´ý½ÓÊÕÊý¾ÝÖ¸Õë | |
* datalen: Êý¾Ý³¤¶È | |
* ·µ»ØÊµ¼Ê¶ÁÈëµÄ×Ö½ÚÊý | |
*/ | |
int PortRecv(int fd, unsigned char* data, int datalen, int flag); | |
/** | |
* ´®¿Ú²âÊÔʱÉèÖô®¿Ú | |
* fdcom: ´®¿ÚÎļþÃèÊö·û, pportinfo: ´ýÉèÖõĴ®¿ÚÐÅÏ¢ | |
*/ | |
int uart_set(int fd); | |
#endif | |