-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSerialTest.cpp
More file actions
107 lines (77 loc) · 4 KB
/
SerialTest.cpp
File metadata and controls
107 lines (77 loc) · 4 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include <iostream>
#include <Arduino.hpp>
#include <BX3SSU.hpp>
#include <Serial.hpp>
// _________ _______ ________ _________ ________ _________ ________ ________ _______
// |\___ ___\\ ___ \ |\ ____\|\___ ___\ |\ ____\|\___ ___\\ __ \|\ ____\|\ ___ \
// \|___ \ \_\ \ __/|\ \ \___|\|___ \ \_| \ \ \___|\|___ \ \_\ \ \|\ \ \ \___|\ \ __/|
// \ \ \ \ \ \_|/_\ \_____ \ \ \ \ \ \_____ \ \ \ \ \ \ __ \ \ \ __\ \ \_|/__
// \ \ \ \ \ \_|\ \|____|\ \ \ \ \ \|____|\ \ \ \ \ \ \ \ \ \ \ \|\ \ \ \_|\ \
// \ \__\ \ \_______\____\_\ \ \ \__\ ____\_\ \ \ \__\ \ \__\ \__\ \_______\ \_______\
// \|__| \|_______|\_________\ \|__| |\_________\ \|__| \|__|\|__|\|_______|\|_______|
// \|_________| \|_________|
int main()
{
asio::io_service io;
Serial serial(io);
auto ports = serial.enumerate_ports();
for(const auto& port : ports)
{
std::cout << port << std::endl;
}
// BX3SSU stage(io,argv[1]);
// stage.move(10000000,0);
return 0;
}
// _________ _______ ________ _________ ________ ________ ________ ___ ___ ___ ________ ________
// |\___ ___\\ ___ \ |\ ____\|\___ ___\ |\ __ \|\ __ \|\ ___ \|\ \|\ \|\ \|\ ___ \|\ __ \
// \|___ \ \_\ \ __/|\ \ \___|\|___ \ \_| \ \ \|\ \ \ \|\ \ \ \_|\ \ \ \\\ \ \ \ \ \\ \ \ \ \|\ \
// \ \ \ \ \ \_|/_\ \_____ \ \ \ \ \ \ __ \ \ _ _\ \ \ \\ \ \ \\\ \ \ \ \ \\ \ \ \ \\\ \
// \ \ \ \ \ \_|\ \|____|\ \ \ \ \ \ \ \ \ \ \ \\ \\ \ \_\\ \ \ \\\ \ \ \ \ \\ \ \ \ \\\ \
// \ \__\ \ \_______\____\_\ \ \ \__\ \ \__\ \__\ \__\\ _\\ \_______\ \_______\ \__\ \__\\ \__\ \_______\
// \|__| \|_______|\_________\ \|__| \|__|\|__|\|__|\|__|\|_______|\|_______|\|__|\|__| \|__|\|_______|
// \|_________|
// int main(int argc, const char *argv[])
// {
// asio::io_service io;
// Arduino arduino(io,argv[1]);
// arduino.LEDSwitch(argv[2]);
// return 0;
// }
// #include <iostream>
// #include <string>
// #include <asio.hpp>
// asio::streambuf serialData;
// asio::io_service io;
// asio::serial_port Serial(io);
// void SerialReadHandler(const asio::error_code &ec,std::size_t size)
// {
// std::istream str(&serialData);
// std::string line;
// std::getline(str,line);
// std::cout << line << std::endl;
// asio::async_read_until(Serial,serialData,"\n",
// [](const asio::error_code &ec,std::size_t size){SerialReadHandler(ec, size);});
// }
// int main()
// {
// Serial.open("COM7");
// Serial.set_option(asio::serial_port_base::baud_rate(9600));
// Serial.set_option(asio::serial_port_base::character_size(8));
// asio::async_read_until(Serial,serialData,"\n",
// [](const asio::error_code &ec,std::size_t size){SerialReadHandler(ec, size);});
// int n = 0;
// while(true)
// {
// if(n%2==0)
// asio::write(Serial,asio::buffer("X",1));
// else
// asio::write(Serial,asio::buffer("Y",1));
// n++;
// std::cout << "Waiting for 1 second" << std::endl;
// std::this_thread::sleep_for(std::chrono::milliseconds(1000));
// }
// io.run();
// std::cout << "Finished" << std::endl;
// return 0;
// }