| 1 | /*************************************************************************** |
| 2 | ccomport.h - header file for serial port comms |
| 3 | class. |
| 4 | ------------------- |
| 5 | begin : Wed Sep 25 18:58:35 BST 2002 |
| 6 | copyright : (C) 2002 by Greg Reynolds, Jim Hawkridge |
| 7 | email : [email protected] |
| 8 | ***************************************************************************/ |
| 9 | |
| 10 | /*************************************************************************** |
| 11 | * * |
| 12 | * This program is free software; you can redistribute it and/or modify * |
| 13 | * it under the terms of the GNU General Public License as published by * |
| 14 | * the Free Software Foundation; either version 2 of the License, or * |
| 15 | * (at your option) any later version. * |
| 16 | * * |
| 17 | ***************************************************************************/ |
| 18 | |
| 19 | #include <stdio.h> |
| 20 | #include <string.h> |
| 21 | #include <unistd.h> |
| 22 | #include <fcntl.h> |
| 23 | #include <errno.h> |
| 24 | #include <termios.h> |
| 25 | #include <assert.h> |
| 26 | |
| 27 | class CCOMPort { |
| 28 | |
| 29 | public: |
| 30 | |
| 31 | CCOMPort(); |
| 32 | ~CCOMPort(); |
| 33 | |
| 34 | int openPort(const char* pszDev); |
| 35 | int setPortOptions(speed_t spdBaud); |
| 36 | int readBytes(unsigned char* pBuffer, int nBytes); |
| 37 | int sendBytes(const unsigned char* pBuffer, int nBytes); |
| 38 | int closePort(); |
| 39 | int flush(); |
| 40 | |
| 41 | protected: |
| 42 | int m_fd; /* file descriptor for port */ |
| 43 | termios m_trmOptions; /* port options */ |
| 44 | |
| 45 | |
| 46 | }; |