You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
902 B

#ifndef __SERIAL_H
#define __SERIAL_H
#include <windows.h>
typedef HANDLE PORT;
PORT OpenPort(int idx);
void ClosePort(PORT com_port);
int SetPortBoudRate(PORT com_port, int rate);
int SetPortDataBits(PORT com_port, int bits);
int SetPortStopBits(PORT com_port, int bits);
int SetPortParity(PORT com_port, int parity);
int GetPortBoudRate(PORT com_port);
int GetPortDataBits(PORT com_port);
int GetPortStopBits(PORT com_port);
int GetPortParity(PORT com_port);
int SendData(PORT com_port, const char *data);
int ReciveData(PORT com_port, char *data, int len);
PORT serial_init(int idx, int rate, int databits, int stopbits, int parity);
int Serial_SendData(PORT com_port, const char *data, int len);
int Serial_ReciveData(PORT com_port, char *data, int len);
/* 测试函数,demo工程放在main中,但是我不需要,暂时放在这 */
void serial_test(int serial_com_id);
#endif