1 |
#ifdef _WINDOWS |
//#ifdef _MSC_VER |
2 |
#include "StdAfx.h" |
#include "stdafx.h" |
3 |
#endif |
//#endif |
4 |
|
|
5 |
|
#include <stdexcept> |
6 |
|
|
7 |
#include "SlipSerial.h" |
#include "SlipSerial.h" |
8 |
|
|
9 |
#include <iomanip> |
#include <iomanip> |
10 |
|
#include <iostream> |
11 |
enum SlipState{ |
enum SlipState{ |
12 |
SlipNormal, |
SlipNormal, |
13 |
SlipEscaped, |
SlipEscaped, |
21 |
#define SLIP_ESCAPED_ESC 221 |
#define SLIP_ESCAPED_ESC 221 |
22 |
|
|
23 |
|
|
24 |
CSlipSerial::CSlipSerial(char* port, int bitrate) |
CSlipSerial::CSlipSerial(char* port, Baudrate bitrate) |
25 |
: CSerial(port,bitrate) |
: CSerial(port,bitrate) |
26 |
{ |
{ |
27 |
} |
} |
42 |
|
|
43 |
int state = SlipNormal; |
int state = SlipNormal; |
44 |
|
|
45 |
|
int now; |
46 |
|
int start = time(0); |
47 |
|
|
48 |
while ( /*bytesReady() >0 &&*/ state != SlipStopped) |
while ( /*bytesReady() >0 &&*/ state != SlipStopped) |
49 |
{ |
{ |
50 |
|
now = time(0); |
51 |
|
if ( (now - start)>3) |
52 |
|
throw timeout_error("readFrame() timed out"); |
53 |
|
|
54 |
int c = readByte(); |
int c = readByte(); |
55 |
if (c == -1) |
if (c == -1) |
56 |
{ |
{ |