1 |
torben |
38 |
/*
|
2 |
|
|
* SlipSerial.h & SlipSerial.cpp - (C) 2007 by Torben H. Nielsen
|
3 |
|
|
*
|
4 |
|
|
* Class for implementing the slip data-link protocol on top of a serial port.
|
5 |
|
|
*/
|
6 |
|
|
|
7 |
|
|
#pragma once
|
8 |
torben |
44 |
#include "Serial.h"
|
9 |
torben |
38 |
|
10 |
|
|
#include <vector>
|
11 |
torben |
62 |
#include <string>
|
12 |
|
|
#include <stdexcept>
|
13 |
torben |
38 |
|
14 |
torben |
62 |
|
15 |
|
|
class timeout_error : std::runtime_error
|
16 |
|
|
{
|
17 |
|
|
public:
|
18 |
|
|
timeout_error(const std::string& arg)
|
19 |
|
|
: runtime_error(arg) {}
|
20 |
|
|
};
|
21 |
|
|
|
22 |
torben |
38 |
class CSlipSerial :
|
23 |
|
|
public CSerial
|
24 |
|
|
{
|
25 |
|
|
public:
|
26 |
torben |
54 |
CSlipSerial(char* port, Baudrate bitrate);
|
27 |
torben |
38 |
CSlipSerial();
|
28 |
|
|
virtual ~CSlipSerial(void);
|
29 |
|
|
|
30 |
|
|
std::vector<unsigned char> readFrame();
|
31 |
|
|
void writeFrame(std::vector<unsigned char> data);
|
32 |
|
|
void writeFrame(unsigned char buf[], int len);
|
33 |
|
|
protected:
|
34 |
|
|
void writeSlipByte(unsigned char out);
|
35 |
|
|
};
|