-
Notifications
You must be signed in to change notification settings - Fork 1
/
SerialComm.h
55 lines (41 loc) · 1.14 KB
/
SerialComm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*!
* \file SerialComm.h
* \brief Wrap around serial communication
*
* Current solution is directly for Win32, but can be simply split.
*
* URL: http://robotika.cz/
*
* Revision: 1.2
* Date: 2005/11/01
*/
#ifndef _SerialComm_H_
#define _SerialComm_H_
#include <windows.h>
// this can be already defined
typedef unsigned char BYTE;
#include "ACommLine.h"
class SerialComm : public ACommLine
{
public:
//SerialComm(char *a_comName = "COM2", char *a_comParams = "38400,n,8,1"); pavel
SerialComm(TCHAR *a_comName, int in_baudRate);
~SerialComm();
/*!
* \brief wait X ms (infinitely for negative number) for a byte to be received
* \retval -1 for time out
*/
virtual int waitForByte(int a_waitMs = -1);
virtual void sendByte(BYTE a_byte);
//! send buffer of n bytes
virtual void sendBuffer(BYTE *a_buf, unsigned int a_len);
//! was the connection established ok?
virtual bool connected();
private:
HANDLE m_hComm; // COM port handle
int m_timeOutMs; // time out in miliseconds
// set time-outs for reading, and preserve original values (md)
COMMTIMEOUTS m_timeouts;
bool getByte(BYTE *b_byte);
};
#endif // _SerialComm_H_