-
Notifications
You must be signed in to change notification settings - Fork 1
/
CSerial.h
56 lines (42 loc) · 1.27 KB
/
CSerial.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
55
56
/*
* Copyright (c) 2012 Alexandros Nikolopoulos <[email protected]>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*/
#ifndef CSERIAL_H_
#define CSERIAL_H_
#include "fpd.h"
#include <termios.h>
#include <iostream>
#include <string>
using namespace std;
class CSerial : public CInterface
{
public:
CSerial(map<string,string> settings);
CSerial(string SendingDev, speed_t SendSpeed);
CSerial(string SendingDev, speed_t SendSpeed, string ReceivingDev, speed_t ReceiveSpeed);
virtual ~CSerial();
int Connect(void);
int Disconnect(void);
int Send(uint8_t *message, int length);
int Receive(uint8_t *message, int length, time_t timeout);
// Serials do not have addresses
string GetMyAddress(void) { return "";};
private:
int Lock(string device);
int UnLock(string device);
int SetAttributes(int FileDescriptor, speed_t speed);
speed_t int2speed(int speed);
bool m_IsConnected;
string m_SendingDevName;
int m_SendingDev;
speed_t m_SendingSpeed;
string m_ReceivingDevName;
int m_ReceivingDev;
speed_t m_ReceivingSpeed;
};
#endif /* CINTERFACE_H_ */