-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSerialHubThread.cpp
More file actions
55 lines (42 loc) · 911 Bytes
/
SerialHubThread.cpp
File metadata and controls
55 lines (42 loc) · 911 Bytes
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
#include "SerialHubThread.h"
#include <boost/thread/thread.hpp>
#include <boost/thread/xtime.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time/posix_time/posix_time_io.hpp>
#include <iostream>
#include <fstream>
#include <wiringPi.h>
#include <wiringSerial.h>
SerialHubThread::SerialHubThread()
{
pinMode(SERIAL_SYNC_PIN, OUTPUT);
}
SerialHubThread::~SerialHubThread()
{}
void SerialHubThread::setFD(int fd)
{
this->serialFD = fd;
}
int SerialHubThread::getFD()
{
return serialFD;
}
void SerialHubThread::start()
{
isRunning = true;
run();
}
void SerialHubThread::stop()
{
isRunning = false;
}
void SerialHubThread::run()
{
int count = 0;
while(isRunning)
{
boost::this_thread::sleep(boost::posix_time::milliseconds(100));
digitalWrite(SERIAL_SYNC_PIN, HIGH);
digitalWrite(SERIAL_SYNC_PIN, LOW);
}
}