-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPSoCcom.hpp
65 lines (46 loc) · 1.11 KB
/
PSoCcom.hpp
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
57
58
59
60
#include "Serial.hpp"
#include <unistd.h>
#include <iostream>
#include <cstring>
class PSoCcom
{
public:
PSoCcom() : mySerial_(new Serial)
{
}
~PSoCcom()
{
delete mySerial_;
}
void startSpil(std::string spil, std::string antalSpillere) //sender data til PSoC over UART
{
std::cout << "Start spil kaldt" << std::endl;
std::string spilTemp;
if(spil == "Fisk")
{
spilTemp = "1";
}
if(spil == "500")
{
spilTemp = "2";
}
if(spil == "Røvhul")
{
spilTemp = "3";
}
char message[5];
std::string message_temp= "R"+spilTemp+antalSpillere+"C";
strcpy(message,message_temp.c_str());
size_t n = sprintf(buf, message);
std::cout << "Det der er i bufferen " << buf << std::endl;
mySerial_->writeSome(buf, n);
//clear buffer?
}
void test()
{
std::cout << "Indholdet af bufferen: " << buf << std::endl;
}
private:
Serial *mySerial_;
char buf[5];
};