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

2 years ago
  1. #ifndef __SERIAL_H
  2. #define __SERIAL_H
  3. #include <windows.h>
  4. typedef HANDLE PORT;
  5. PORT OpenPort(int idx);
  6. void ClosePort(PORT com_port);
  7. int SetPortBoudRate(PORT com_port, int rate);
  8. int SetPortDataBits(PORT com_port, int bits);
  9. int SetPortStopBits(PORT com_port, int bits);
  10. int SetPortParity(PORT com_port, int parity);
  11. int GetPortBoudRate(PORT com_port);
  12. int GetPortDataBits(PORT com_port);
  13. int GetPortStopBits(PORT com_port);
  14. int GetPortParity(PORT com_port);
  15. int SendData(PORT com_port, const char *data);
  16. int ReciveData(PORT com_port, char *data, int len);
  17. PORT serial_init(int idx, int rate, int databits, int stopbits, int parity);
  18. int Serial_SendData(PORT com_port, const char *data, int len);
  19. int Serial_ReciveData(PORT com_port, char *data, int len);
  20. /* 测试函数,demo工程放在main中,但是我不需要,暂时放在这 */
  21. void serial_test(int serial_com_id);
  22. #endif