Commit dff0a10c8d3b33cabd334c1566cd5abfd0ddb8e4
0 parents
Implementation of a serial port library.
Showing
22 changed files
with
2060 additions
and
0 deletions
.dep.inc
0 → 100644
.gitignore
0 → 100644
Exception.hpp
0 → 100644
1 | +++ a/Exception.hpp | ||
1 | +#pragma once | ||
2 | + | ||
3 | +// System includes | ||
4 | +#include <iostream> | ||
5 | +#include <sstream> | ||
6 | +#include <stdexcept> | ||
7 | +#include <string> | ||
8 | + | ||
9 | + | ||
10 | +class Exception : public std::runtime_error | ||
11 | +{ | ||
12 | +public: | ||
13 | + Exception(const char *file, int line, const std::string &arg) | ||
14 | + : std::runtime_error(arg) | ||
15 | + { | ||
16 | + msg_ = std::string(file) + ":" + std::to_string(line) + ": " + arg; | ||
17 | + } | ||
18 | + | ||
19 | + ~Exception() throw() {} | ||
20 | + | ||
21 | + const char *what() const throw() override | ||
22 | + { | ||
23 | + return msg_.c_str(); | ||
24 | + } | ||
25 | + | ||
26 | +private: | ||
27 | + std::string msg_; | ||
28 | +}; | ||
29 | + | ||
30 | +#define THROW_EXCEPT(arg) throw Exception(__FILE__, __LINE__, arg); |
Makefile
0 → 100644
1 | +++ a/Makefile | ||
1 | +# | ||
2 | +# There exist several targets which are by default empty and which can be | ||
3 | +# used for execution of your targets. These targets are usually executed | ||
4 | +# before and after some main targets. They are: | ||
5 | +# | ||
6 | +# .build-pre: called before 'build' target | ||
7 | +# .build-post: called after 'build' target | ||
8 | +# .clean-pre: called before 'clean' target | ||
9 | +# .clean-post: called after 'clean' target | ||
10 | +# .clobber-pre: called before 'clobber' target | ||
11 | +# .clobber-post: called after 'clobber' target | ||
12 | +# .all-pre: called before 'all' target | ||
13 | +# .all-post: called after 'all' target | ||
14 | +# .help-pre: called before 'help' target | ||
15 | +# .help-post: called after 'help' target | ||
16 | +# | ||
17 | +# Targets beginning with '.' are not intended to be called on their own. | ||
18 | +# | ||
19 | +# Main targets can be executed directly, and they are: | ||
20 | +# | ||
21 | +# build build a specific configuration | ||
22 | +# clean remove built files from a configuration | ||
23 | +# clobber remove all built files | ||
24 | +# all build all configurations | ||
25 | +# help print help mesage | ||
26 | +# | ||
27 | +# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and | ||
28 | +# .help-impl are implemented in nbproject/makefile-impl.mk. | ||
29 | +# | ||
30 | +# Available make variables: | ||
31 | +# | ||
32 | +# CND_BASEDIR base directory for relative paths | ||
33 | +# CND_DISTDIR default top distribution directory (build artifacts) | ||
34 | +# CND_BUILDDIR default top build directory (object files, ...) | ||
35 | +# CONF name of current configuration | ||
36 | +# CND_PLATFORM_${CONF} platform name (current configuration) | ||
37 | +# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration) | ||
38 | +# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration) | ||
39 | +# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration) | ||
40 | +# CND_PACKAGE_DIR_${CONF} directory of package (current configuration) | ||
41 | +# CND_PACKAGE_NAME_${CONF} name of package (current configuration) | ||
42 | +# CND_PACKAGE_PATH_${CONF} path to package (current configuration) | ||
43 | +# | ||
44 | +# NOCDDL | ||
45 | + | ||
46 | + | ||
47 | +# Environment | ||
48 | +MKDIR=mkdir | ||
49 | +CP=cp | ||
50 | +CCADMIN=CCadmin | ||
51 | + | ||
52 | + | ||
53 | +# build | ||
54 | +build: .build-post | ||
55 | + | ||
56 | +.build-pre: | ||
57 | +# Add your pre 'build' code here... | ||
58 | + | ||
59 | +.build-post: .build-impl | ||
60 | +# Add your post 'build' code here... | ||
61 | + | ||
62 | + | ||
63 | +# clean | ||
64 | +clean: .clean-post | ||
65 | + | ||
66 | +.clean-pre: | ||
67 | +# Add your pre 'clean' code here... | ||
68 | + | ||
69 | +.clean-post: .clean-impl | ||
70 | +# Add your post 'clean' code here... | ||
71 | + | ||
72 | + | ||
73 | +# clobber | ||
74 | +clobber: .clobber-post | ||
75 | + | ||
76 | +.clobber-pre: | ||
77 | +# Add your pre 'clobber' code here... | ||
78 | + | ||
79 | +.clobber-post: .clobber-impl | ||
80 | +# Add your post 'clobber' code here... | ||
81 | + | ||
82 | + | ||
83 | +# all | ||
84 | +all: .all-post | ||
85 | + | ||
86 | +.all-pre: | ||
87 | +# Add your pre 'all' code here... | ||
88 | + | ||
89 | +.all-post: .all-impl | ||
90 | +# Add your post 'all' code here... | ||
91 | + | ||
92 | + | ||
93 | +# build tests | ||
94 | +build-tests: .build-tests-post | ||
95 | + | ||
96 | +.build-tests-pre: | ||
97 | +# Add your pre 'build-tests' code here... | ||
98 | + | ||
99 | +.build-tests-post: .build-tests-impl | ||
100 | +# Add your post 'build-tests' code here... | ||
101 | + | ||
102 | + | ||
103 | +# run tests | ||
104 | +test: .test-post | ||
105 | + | ||
106 | +.test-pre: build-tests | ||
107 | +# Add your pre 'test' code here... | ||
108 | + | ||
109 | +.test-post: .test-impl | ||
110 | +# Add your post 'test' code here... | ||
111 | + | ||
112 | + | ||
113 | +# help | ||
114 | +help: .help-post | ||
115 | + | ||
116 | +.help-pre: | ||
117 | +# Add your pre 'help' code here... | ||
118 | + | ||
119 | +.help-post: .help-impl | ||
120 | +# Add your post 'help' code here... | ||
121 | + | ||
122 | + | ||
123 | + | ||
124 | +# include project implementation makefile | ||
125 | +include nbproject/Makefile-impl.mk | ||
126 | + | ||
127 | +# include project make variables | ||
128 | +include nbproject/Makefile-variables.mk |
SerialPort.cpp
0 → 100644
1 | +++ a/SerialPort.cpp | ||
1 | +// System includes | ||
2 | +#include <iostream> | ||
3 | +#include <sstream> | ||
4 | +#include <stdio.h> // Standard input/output definitions | ||
5 | +#include <string.h> // String function definitions | ||
6 | +#include <unistd.h> // UNIX standard function definitions | ||
7 | +#include <fcntl.h> // File control definitions | ||
8 | +#include <errno.h> // Error number definitions | ||
9 | +// #include <termios.h> // POSIX terminal control definitions (struct termios) | ||
10 | +#include <system_error> // For throwing std::system_error | ||
11 | +#include <sys/ioctl.h> // Used for TCGETS2, which is required for custom baud rates | ||
12 | +#include <cassert> | ||
13 | +// #include <asm/termios.h> // Terminal control definitions (struct termios) | ||
14 | +#include <asm/ioctls.h> | ||
15 | +#include <asm/termbits.h> | ||
16 | +#include <algorithm> | ||
17 | +#include <iterator> | ||
18 | + | ||
19 | +// User includes | ||
20 | +#include "Exception.hpp" | ||
21 | +#include "SerialPort.hpp" | ||
22 | + | ||
23 | +#define BOTHER 0010000 | ||
24 | + | ||
25 | +SerialPort::SerialPort() | ||
26 | +{ | ||
27 | + echo_ = false; | ||
28 | + timeout_ms_ = defaultTimeout_ms_; | ||
29 | + baudRateType_ = BaudRateType::STANDARD; | ||
30 | + baudRateStandard_ = defaultBaudRate_; | ||
31 | + readBufferSize_B_ = defaultReadBufferSize_B_; | ||
32 | + readBuffer_.reserve(readBufferSize_B_); | ||
33 | + state_ = State::CLOSED; | ||
34 | +} | ||
35 | + | ||
36 | +SerialPort::SerialPort(const std::string& device, BaudRate baudRate) | ||
37 | + : SerialPort() | ||
38 | +{ | ||
39 | + device_ = device; | ||
40 | + baudRateType_ = BaudRateType::STANDARD; | ||
41 | + baudRateStandard_ = baudRate; | ||
42 | +} | ||
43 | + | ||
44 | +SerialPort::SerialPort(const std::string& device, speed_t baudRate) | ||
45 | + : SerialPort() | ||
46 | +{ | ||
47 | + device_ = device; | ||
48 | + baudRateType_ = BaudRateType::CUSTOM; | ||
49 | + baudRateCustom_ = baudRate; | ||
50 | +} | ||
51 | + | ||
52 | +SerialPort::SerialPort( | ||
53 | + const std::string& device, | ||
54 | + BaudRate baudRate, | ||
55 | + NumDataBits numDataBits, | ||
56 | + Parity parity, | ||
57 | + NumStopBits numStopBits) | ||
58 | + : SerialPort() | ||
59 | +{ | ||
60 | + device_ = device; | ||
61 | + baudRateType_ = BaudRateType::STANDARD; | ||
62 | + baudRateStandard_ = baudRate; | ||
63 | + numDataBits_ = numDataBits; | ||
64 | + parity_ = parity; | ||
65 | + numStopBits_ = numStopBits; | ||
66 | +} | ||
67 | + | ||
68 | +SerialPort::~SerialPort() | ||
69 | +{ | ||
70 | + try | ||
71 | + { | ||
72 | + Close(); | ||
73 | + } | ||
74 | + catch(...) | ||
75 | + { | ||
76 | + // We can't do anything about this! | ||
77 | + // But we don't want to throw within destructor, so swallow | ||
78 | + } | ||
79 | +} | ||
80 | + | ||
81 | +void SerialPort::SetDevice(const std::string& device) | ||
82 | +{ | ||
83 | + device_ = device; | ||
84 | + if(state_ == State::OPEN) | ||
85 | + ConfigureTermios(); | ||
86 | +} | ||
87 | + | ||
88 | +void SerialPort::SetBaudRate(BaudRate baudRate) | ||
89 | +{ | ||
90 | + baudRateType_ = BaudRateType::STANDARD; | ||
91 | + baudRateStandard_ = baudRate; | ||
92 | + if(state_ == State::OPEN) | ||
93 | + ConfigureTermios(); | ||
94 | +} | ||
95 | + | ||
96 | +void SerialPort::SetBaudRate(speed_t baudRate) | ||
97 | +{ | ||
98 | + baudRateType_ = BaudRateType::CUSTOM; | ||
99 | + baudRateCustom_ = baudRate; | ||
100 | + if(state_ == State::OPEN) | ||
101 | + ConfigureTermios(); | ||
102 | +} | ||
103 | + | ||
104 | +void SerialPort::SetNumDataBits(NumDataBits numDataBits) | ||
105 | +{ | ||
106 | + numDataBits_ = numDataBits; | ||
107 | + if(state_ == State::OPEN) | ||
108 | + ConfigureTermios(); | ||
109 | +} | ||
110 | + | ||
111 | +void SerialPort::SetParity(Parity parity) | ||
112 | +{ | ||
113 | + parity_ = parity; | ||
114 | + if(state_ == State::OPEN) | ||
115 | + ConfigureTermios(); | ||
116 | +} | ||
117 | + | ||
118 | +void SerialPort::SetNumStopBits(NumStopBits numStopBits) | ||
119 | +{ | ||
120 | + numStopBits_ = numStopBits; | ||
121 | + if(state_ == State::OPEN) | ||
122 | + ConfigureTermios(); | ||
123 | +} | ||
124 | + | ||
125 | +void SerialPort::Open() | ||
126 | +{ | ||
127 | + if(device_.empty()) | ||
128 | + { | ||
129 | + THROW_EXCEPT("Attempted to open file when file path has not been assigned to."); | ||
130 | + } | ||
131 | + | ||
132 | + // Attempt to open file | ||
133 | + //this->fileDesc = open(this->filePath, O_RDWR | O_NOCTTY | O_NDELAY); | ||
134 | + | ||
135 | + // O_RDONLY for read-only, O_WRONLY for write only, O_RDWR for both read/write access | ||
136 | + // 3rd, optional parameter is mode_t mode | ||
137 | + fileDesc_ = open(device_.c_str(), O_RDWR); | ||
138 | + | ||
139 | + // Check status | ||
140 | + if(fileDesc_ == -1) | ||
141 | + { | ||
142 | + THROW_EXCEPT("Could not open device " + device_ + ". Is the device name correct and do you have read/write permission?"); | ||
143 | + } | ||
144 | + | ||
145 | + ConfigureTermios(); | ||
146 | + | ||
147 | + // std::cout << "COM port opened successfully." << std::endl; | ||
148 | + state_ = State::OPEN; | ||
149 | +} | ||
150 | + | ||
151 | +void SerialPort::SetEcho(bool value) | ||
152 | +{ | ||
153 | + echo_ = value; | ||
154 | + ConfigureTermios(); | ||
155 | +} | ||
156 | + | ||
157 | +void SerialPort::ConfigureTermios() | ||
158 | +{ | ||
159 | + // std::cout << "Configuring COM port \"" << device_ << "\"." << std::endl; | ||
160 | + //================== CONFIGURE ==================// | ||
161 | + | ||
162 | + // termios tty = GetTermios(); | ||
163 | + termios2 tty = GetTermios2(); | ||
164 | + | ||
165 | + //================= (.c_cflag) ===============// | ||
166 | + | ||
167 | + // Set num. data bits | ||
168 | + // See https://man7.org/linux/man-pages/man3/tcflush.3.html | ||
169 | + tty.c_cflag &= ~CSIZE; // CSIZE is a mask for the number of bits per character | ||
170 | + switch(numDataBits_) | ||
171 | + { | ||
172 | + case NumDataBits::FIVE: | ||
173 | + tty.c_cflag |= CS5; | ||
174 | + break; | ||
175 | + case NumDataBits::SIX: | ||
176 | + tty.c_cflag |= CS6; | ||
177 | + break; | ||
178 | + case NumDataBits::SEVEN: | ||
179 | + tty.c_cflag |= CS7; | ||
180 | + break; | ||
181 | + case NumDataBits::EIGHT: | ||
182 | + tty.c_cflag |= CS8; | ||
183 | + break; | ||
184 | + default: | ||
185 | + THROW_EXCEPT("numDataBits_ value not supported!"); | ||
186 | + } | ||
187 | + | ||
188 | + // Set parity | ||
189 | + // See https://man7.org/linux/man-pages/man3/tcflush.3.html | ||
190 | + switch(parity_) | ||
191 | + { | ||
192 | + case Parity::NONE: | ||
193 | + tty.c_cflag &= ~PARENB; | ||
194 | + break; | ||
195 | + case Parity::EVEN: | ||
196 | + tty.c_cflag |= PARENB; | ||
197 | + tty.c_cflag &= ~PARODD; // Clearing PARODD makes the parity even | ||
198 | + break; | ||
199 | + case Parity::ODD: | ||
200 | + tty.c_cflag |= PARENB; | ||
201 | + tty.c_cflag |= PARODD; | ||
202 | + break; | ||
203 | + default: | ||
204 | + THROW_EXCEPT("parity_ value not supported!"); | ||
205 | + | ||
206 | + } | ||
207 | + | ||
208 | + // Set num. stop bits | ||
209 | + switch(numStopBits_) | ||
210 | + { | ||
211 | + case NumStopBits::ONE: | ||
212 | + tty.c_cflag &= ~CSTOPB; | ||
213 | + break; | ||
214 | + case NumStopBits::TWO: | ||
215 | + tty.c_cflag |= CSTOPB; | ||
216 | + break; | ||
217 | + default: | ||
218 | + THROW_EXCEPT("numStopBits_ value not supported!"); | ||
219 | + } | ||
220 | + | ||
221 | + tty.c_cflag &= ~CRTSCTS; // Disable hadrware flow control (RTS/CTS) | ||
222 | + tty.c_cflag |= CREAD | CLOCAL; // Turn on READ & ignore ctrl lines (CLOCAL = 1) | ||
223 | + | ||
224 | + | ||
225 | +//===================== BAUD RATE =================// | ||
226 | + | ||
227 | + // We used to use cfsetispeed() and cfsetospeed() with the B... macros, but this didn't allow | ||
228 | + // us to set custom baud rates. So now to support both standard and custom baud rates lets | ||
229 | + // just make everything "custom". This giant switch statement could be replaced with a map/lookup | ||
230 | + // in the future | ||
231 | + if (baudRateType_ == BaudRateType::STANDARD) | ||
232 | + { | ||
233 | + tty.c_cflag &= ~CBAUD; | ||
234 | + tty.c_cflag |= CBAUDEX; | ||
235 | + switch(baudRateStandard_) | ||
236 | + { | ||
237 | + case BaudRate::B_0: | ||
238 | + // cfsetispeed(&tty, B0); | ||
239 | + // cfsetospeed(&tty, B0); | ||
240 | + tty.c_ispeed = 0; | ||
241 | + tty.c_ospeed = 0; | ||
242 | + break; | ||
243 | + case BaudRate::B_50: | ||
244 | + // cfsetispeed(&tty, B50); | ||
245 | + // cfsetospeed(&tty, B50); | ||
246 | + tty.c_ispeed = 50; | ||
247 | + tty.c_ospeed = 50; | ||
248 | + break; | ||
249 | + case BaudRate::B_75: | ||
250 | + // cfsetispeed(&tty, B75); | ||
251 | + // cfsetospeed(&tty, B75); | ||
252 | + tty.c_ispeed = 75; | ||
253 | + tty.c_ospeed = 75; | ||
254 | + break; | ||
255 | + case BaudRate::B_110: | ||
256 | + // cfsetispeed(&tty, B110); | ||
257 | + // cfsetospeed(&tty, B110); | ||
258 | + tty.c_ispeed = 110; | ||
259 | + tty.c_ospeed = 110; | ||
260 | + break; | ||
261 | + case BaudRate::B_134: | ||
262 | + // cfsetispeed(&tty, B134); | ||
263 | + // cfsetospeed(&tty, B134); | ||
264 | + tty.c_ispeed = 134; | ||
265 | + tty.c_ospeed = 134; | ||
266 | + break; | ||
267 | + case BaudRate::B_150: | ||
268 | + // cfsetispeed(&tty, B150); | ||
269 | + // cfsetospeed(&tty, B150); | ||
270 | + tty.c_ispeed = 150; | ||
271 | + tty.c_ospeed = 150; | ||
272 | + break; | ||
273 | + case BaudRate::B_200: | ||
274 | + // cfsetispeed(&tty, B200); | ||
275 | + // cfsetospeed(&tty, B200); | ||
276 | + tty.c_ispeed = 200; | ||
277 | + tty.c_ospeed = 200; | ||
278 | + break; | ||
279 | + case BaudRate::B_300: | ||
280 | + // cfsetispeed(&tty, B300); | ||
281 | + // cfsetospeed(&tty, B300); | ||
282 | + tty.c_ispeed = 300; | ||
283 | + tty.c_ospeed = 300; | ||
284 | + break; | ||
285 | + case BaudRate::B_600: | ||
286 | + // cfsetispeed(&tty, B600); | ||
287 | + // cfsetospeed(&tty, B600); | ||
288 | + tty.c_ispeed = 600; | ||
289 | + tty.c_ospeed = 600; | ||
290 | + break; | ||
291 | + case BaudRate::B_1200: | ||
292 | + // cfsetispeed(&tty, B1200); | ||
293 | + // cfsetospeed(&tty, B1200); | ||
294 | + tty.c_ispeed = 1200; | ||
295 | + tty.c_ospeed = 1200; | ||
296 | + break; | ||
297 | + case BaudRate::B_1800: | ||
298 | + // cfsetispeed(&tty, B1800); | ||
299 | + // cfsetospeed(&tty, B1800); | ||
300 | + tty.c_ispeed = 1800; | ||
301 | + tty.c_ospeed = 1800; | ||
302 | + break; | ||
303 | + case BaudRate::B_2400: | ||
304 | + // cfsetispeed(&tty, B2400); | ||
305 | + // cfsetospeed(&tty, B2400); | ||
306 | + tty.c_ispeed = 2400; | ||
307 | + tty.c_ospeed = 2400; | ||
308 | + break; | ||
309 | + case BaudRate::B_4800: | ||
310 | + // cfsetispeed(&tty, B4800); | ||
311 | + // cfsetospeed(&tty, B4800); | ||
312 | + tty.c_ispeed = 4800; | ||
313 | + tty.c_ospeed = 4800; | ||
314 | + break; | ||
315 | + case BaudRate::B_9600: | ||
316 | + // cfsetispeed(&tty, B9600); | ||
317 | + // cfsetospeed(&tty, B9600); | ||
318 | + tty.c_ispeed = 9600; | ||
319 | + tty.c_ospeed = 9600; | ||
320 | + break; | ||
321 | + case BaudRate::B_19200: | ||
322 | + // cfsetispeed(&tty, B19200); | ||
323 | + // cfsetospeed(&tty, B19200); | ||
324 | + tty.c_ispeed = 19200; | ||
325 | + tty.c_ospeed = 19200; | ||
326 | + break; | ||
327 | + case BaudRate::B_38400: | ||
328 | + // cfsetispeed(&tty, B38400); | ||
329 | + // cfsetospeed(&tty, B38400); | ||
330 | + tty.c_ispeed = 38400; | ||
331 | + tty.c_ospeed = 38400; | ||
332 | + break; | ||
333 | + case BaudRate::B_57600: | ||
334 | + // cfsetispeed(&tty, B57600); | ||
335 | + // cfsetospeed(&tty, B57600); | ||
336 | + tty.c_ispeed = 57600; | ||
337 | + tty.c_ospeed = 57600; | ||
338 | + break; | ||
339 | + case BaudRate::B_115200: | ||
340 | + // cfsetispeed(&tty, B115200); | ||
341 | + // cfsetospeed(&tty, B115200); | ||
342 | + tty.c_ispeed = 115200; | ||
343 | + tty.c_ospeed = 115200; | ||
344 | + break; | ||
345 | + case BaudRate::B_230400: | ||
346 | + // cfsetispeed(&tty, B230400); | ||
347 | + // cfsetospeed(&tty, B230400); | ||
348 | + tty.c_ispeed = 230400; | ||
349 | + tty.c_ospeed = 230400; | ||
350 | + break; | ||
351 | + case BaudRate::B_460800: | ||
352 | + // cfsetispeed(&tty, B460800); | ||
353 | + // cfsetospeed(&tty, B460800); | ||
354 | + tty.c_ispeed = 460800; | ||
355 | + tty.c_ospeed = 460800; | ||
356 | + break; | ||
357 | + default: | ||
358 | + throw std::runtime_error(std::string() + "baudRate passed to " + __PRETTY_FUNCTION__ + " unrecognized."); | ||
359 | + } | ||
360 | + } | ||
361 | + // This does no different than STANDARD atm, but let's keep | ||
362 | + // them separate for now.... | ||
363 | + else if (baudRateType_ == BaudRateType::CUSTOM) | ||
364 | + { | ||
365 | + tty.c_cflag &= ~CBAUD; | ||
366 | + tty.c_cflag |= CBAUDEX; | ||
367 | + // tty.c_cflag |= BOTHER; | ||
368 | + tty.c_ispeed = baudRateCustom_; | ||
369 | + tty.c_ospeed = baudRateCustom_; | ||
370 | + | ||
371 | + | ||
372 | + // #include <linux/serial.h> | ||
373 | + // // configure port to use custom speed instead of 38400 | ||
374 | + // struct serial_struct ss; | ||
375 | + // ioctl(fileDesc_, TIOCGSERIAL, &ss); | ||
376 | + // ss.flags = (ss.flags & ~ASYNC_SPD_MASK) | ASYNC_SPD_CUST; | ||
377 | + // ss.custom_divisor = (ss.baud_base + (baudRateCustom_ / 2)) / baudRateCustom_; | ||
378 | + // int closestSpeed = ss.baud_base / ss.custom_divisor; | ||
379 | + | ||
380 | + // if (closestSpeed < baudRateCustom_ * 98 / 100 || closestSpeed > baudRateCustom_ * 102 / 100) { | ||
381 | + // printf("Cannot set serial port speed to %d. Closest possible is %d\n", baudRateCustom_, closestSpeed); | ||
382 | + // } | ||
383 | + | ||
384 | + // ioctl(fileDesc_, TIOCSSERIAL, &ss); | ||
385 | + | ||
386 | + // cfsetispeed(&tty, B38400); | ||
387 | + // cfsetospeed(&tty, B38400); | ||
388 | + } | ||
389 | + else | ||
390 | + { | ||
391 | + // Should never get here, bug in this libraries code! | ||
392 | + assert(false); | ||
393 | + } | ||
394 | + | ||
395 | + //===================== (.c_oflag) =================// | ||
396 | + | ||
397 | + tty.c_oflag = 0; // No remapping, no delays | ||
398 | + tty.c_oflag &= ~OPOST; // Make raw | ||
399 | + | ||
400 | + //================= CONTROL CHARACTERS (.c_cc[]) ==================// | ||
401 | + | ||
402 | + // c_cc[VTIME] sets the inter-character timer, in units of 0.1s. | ||
403 | + // Only meaningful when port is set to non-canonical mode | ||
404 | + // VMIN = 0, VTIME = 0: No blocking, return immediately with what is available | ||
405 | + // VMIN > 0, VTIME = 0: read() waits for VMIN bytes, could block indefinitely | ||
406 | + // VMIN = 0, VTIME > 0: Block until any amount of data is available, OR timeout occurs | ||
407 | + // VMIN > 0, VTIME > 0: Block until either VMIN characters have been received, or VTIME | ||
408 | + // after first character has elapsed | ||
409 | + // c_cc[WMIN] sets the number of characters to block (wait) for when read() is called. | ||
410 | + // Set to 0 if you don't want read to block. Only meaningful when port set to non-canonical mode | ||
411 | + | ||
412 | + if(timeout_ms_ == -1) | ||
413 | + { | ||
414 | + // Always wait for at least one byte, this could | ||
415 | + // block indefinitely | ||
416 | + tty.c_cc[VTIME] = 0; | ||
417 | + tty.c_cc[VMIN] = 1; | ||
418 | + } | ||
419 | + else if(timeout_ms_ == 0) | ||
420 | + { | ||
421 | + // Setting both to 0 will give a non-blocking read | ||
422 | + tty.c_cc[VTIME] = 0; | ||
423 | + tty.c_cc[VMIN] = 0; | ||
424 | + } | ||
425 | + else if(timeout_ms_ > 0) | ||
426 | + { | ||
427 | + tty.c_cc[VTIME] = (cc_t)(timeout_ms_/100); // 0.5 seconds read timeout | ||
428 | + tty.c_cc[VMIN] = 0; | ||
429 | + } | ||
430 | + | ||
431 | + //======================== (.c_iflag) ====================// | ||
432 | + | ||
433 | + tty.c_iflag &= ~(IXON | IXOFF | IXANY); // Turn off s/w flow ctrl | ||
434 | + tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL); | ||
435 | + | ||
436 | + //=========================== LOCAL MODES (c_lflag) =======================// | ||
437 | + | ||
438 | + // Canonical input is when read waits for EOL or EOF characters before returning. In non-canonical mode, the rate at which | ||
439 | + // read() returns is instead controlled by c_cc[VMIN] and c_cc[VTIME] | ||
440 | + tty.c_lflag &= ~ICANON; // Turn off canonical input, which is suitable for pass-through | ||
441 | + // Configure echo depending on echo_ boolean | ||
442 | + if(echo_) | ||
443 | + { | ||
444 | + tty.c_lflag |= ECHO; | ||
445 | + } | ||
446 | + else | ||
447 | + { | ||
448 | + tty.c_lflag &= ~(ECHO); | ||
449 | + } | ||
450 | + tty.c_lflag &= ~ECHOE; // Turn off echo erase (echo erase only relevant if canonical input is active) | ||
451 | + tty.c_lflag &= ~ECHONL; // | ||
452 | + tty.c_lflag &= ~ISIG; // Disables recognition of INTR (interrupt), QUIT and SUSP (suspend) characters | ||
453 | + | ||
454 | + | ||
455 | + // Try and use raw function call | ||
456 | + //cfmakeraw(&tty); | ||
457 | + | ||
458 | + // this->SetTermios(tty); | ||
459 | + this->SetTermios2(tty); | ||
460 | + | ||
461 | + /* | ||
462 | + // Flush port, then apply attributes | ||
463 | + tcflush(this->fileDesc, TCIFLUSH); | ||
464 | + | ||
465 | + if(tcsetattr(this->fileDesc, TCSANOW, &tty) != 0) | ||
466 | + { | ||
467 | + // Error occurred | ||
468 | + this->sp->PrintError(SmartPrint::Ss() << "Could not apply terminal attributes for \"" << this->filePath << "\" - " << strerror(errno)); | ||
469 | + return; | ||
470 | + }*/ | ||
471 | +} | ||
472 | + | ||
473 | +void SerialPort::Write(const std::string& data) | ||
474 | +{ | ||
475 | + | ||
476 | + if(state_ != State::OPEN) | ||
477 | + THROW_EXCEPT(std::string() + __PRETTY_FUNCTION__ + " called but state != OPEN. Please call Open() first."); | ||
478 | + | ||
479 | + if(fileDesc_ < 0) | ||
480 | + { | ||
481 | + THROW_EXCEPT(std::string() + __PRETTY_FUNCTION__ + " called but file descriptor < 0, indicating file has not been opened."); | ||
482 | + } | ||
483 | + | ||
484 | + int writeResult = write(fileDesc_, data.c_str(), data.size()); | ||
485 | + | ||
486 | + // Check status | ||
487 | + if (writeResult == -1) | ||
488 | + { | ||
489 | + throw std::system_error(EFAULT, std::system_category()); | ||
490 | + } | ||
491 | +} | ||
492 | + | ||
493 | +void SerialPort::WriteBinary( const std::vector<uint8_t>& data ) | ||
494 | +{ | ||
495 | + | ||
496 | + if(state_ != State::OPEN) | ||
497 | + THROW_EXCEPT(std::string() + __PRETTY_FUNCTION__ + " called but state != OPEN. Please call Open() first."); | ||
498 | + | ||
499 | + if(fileDesc_ < 0) | ||
500 | + { | ||
501 | + THROW_EXCEPT(std::string() + __PRETTY_FUNCTION__ + " called but file descriptor < 0, indicating file has not been opened."); | ||
502 | + } | ||
503 | + | ||
504 | + int writeResult = write(fileDesc_, data.data(), data.size()); | ||
505 | + | ||
506 | + // Check status | ||
507 | + if (writeResult == -1) | ||
508 | + { | ||
509 | + throw std::system_error(EFAULT, std::system_category()); | ||
510 | + } | ||
511 | + } | ||
512 | + | ||
513 | +void SerialPort::Read(std::string& data) | ||
514 | +{ | ||
515 | + data.clear(); | ||
516 | + | ||
517 | + if(fileDesc_ == 0) | ||
518 | + { | ||
519 | + //this->sp->PrintError(SmartPrint::Ss() << "Read() was called but file descriptor (fileDesc) was 0, indicating file has not been opened."); | ||
520 | + //return false; | ||
521 | + THROW_EXCEPT("Read() was called but file descriptor (fileDesc) was 0, indicating file has not been opened."); | ||
522 | + } | ||
523 | + | ||
524 | + // Allocate memory for read buffer | ||
525 | + // char buf [256]; | ||
526 | + // memset (&buf, '\0', sizeof buf); | ||
527 | + | ||
528 | + // Read from file | ||
529 | + // We provide the underlying raw array from the readBuffer_ vector to this C api. | ||
530 | + // This will work because we do not delete/resize the vector while this method | ||
531 | + // is called | ||
532 | + ssize_t n = read( fileDesc_, &readBuffer_[0], readBufferSize_B_ ); | ||
533 | + | ||
534 | + // Error Handling | ||
535 | + if( n < 0 ) | ||
536 | + { | ||
537 | + // Read was unsuccessful | ||
538 | + throw std::system_error(EFAULT, std::system_category()); | ||
539 | + } | ||
540 | + | ||
541 | + if( n > 0 ) | ||
542 | + { | ||
543 | + // buf[n] = '\0'; | ||
544 | + // printf("%s\r\n", buf); | ||
545 | + // data.append(buf); | ||
546 | + data = std::string( &readBuffer_[0], n ); | ||
547 | + //std::cout << *str << " and size of string =" << str->size() << "\r\n"; | ||
548 | + } | ||
549 | +} | ||
550 | + | ||
551 | +void SerialPort::ReadBinary(std::vector<uint8_t>& data) | ||
552 | +{ | ||
553 | + data.clear(); | ||
554 | + | ||
555 | + if( fileDesc_ == 0 ) | ||
556 | + { | ||
557 | + THROW_EXCEPT("Read() was called but file descriptor (fileDesc) was 0, indicating file has not been opened."); | ||
558 | + } | ||
559 | + | ||
560 | + // Read from file | ||
561 | + // We provide the underlying raw array from the readBuffer_ vector to this C api. | ||
562 | + // This will work because we do not delete/resize the vector while this method | ||
563 | + // is called | ||
564 | + ssize_t n = read(fileDesc_, &readBuffer_[0], readBufferSize_B_); | ||
565 | + | ||
566 | + // Error Handling | ||
567 | + if( n < 0 ) | ||
568 | + { | ||
569 | + // Read was unsuccessful | ||
570 | + throw std::system_error(EFAULT, std::system_category()); | ||
571 | + } | ||
572 | + | ||
573 | + if( n > 0 ) | ||
574 | + { | ||
575 | + copy(readBuffer_.begin(), readBuffer_.begin() + n, back_inserter(data)); | ||
576 | + } | ||
577 | +} | ||
578 | + | ||
579 | + // termios SerialPort::GetTermios() { | ||
580 | +// if(fileDesc_ == -1) | ||
581 | +// throw std::runtime_error("GetTermios() called but file descriptor was not valid."); | ||
582 | + | ||
583 | + // struct termios tty; | ||
584 | + // memset(&tty, 0, sizeof(tty)); | ||
585 | + | ||
586 | + // // Get current settings (will be stored in termios structure) | ||
587 | + // if(tcgetattr(fileDesc_, &tty) != 0) | ||
588 | + // { | ||
589 | + // // Error occurred | ||
590 | + // std::cout << "Could not get terminal attributes for \"" << device_ << "\" - " << strerror(errno) << std::endl; | ||
591 | + // throw std::system_error(EFAULT, std::system_category()); | ||
592 | + // //return false; | ||
593 | + // } | ||
594 | + | ||
595 | + // return tty; | ||
596 | + // } | ||
597 | + | ||
598 | + // void SerialPort::SetTermios(termios myTermios) | ||
599 | + // { | ||
600 | + // // Flush port, then apply attributes | ||
601 | + // tcflush(fileDesc_, TCIFLUSH); | ||
602 | + | ||
603 | + // if(tcsetattr(fileDesc_, TCSANOW, &myTermios) != 0) | ||
604 | + // { | ||
605 | + // // Error occurred | ||
606 | + // std::cout << "Could not apply terminal attributes for \"" << device_ << "\" - " << strerror(errno) << std::endl; | ||
607 | + // throw std::system_error(EFAULT, std::system_category()); | ||
608 | + | ||
609 | + // } | ||
610 | + | ||
611 | + // // Successful! | ||
612 | + // } | ||
613 | + | ||
614 | +termios2 SerialPort::GetTermios2() | ||
615 | +{ | ||
616 | + struct termios2 term2; | ||
617 | + | ||
618 | + ioctl(fileDesc_, TCGETS2, &term2); | ||
619 | + | ||
620 | + return term2; | ||
621 | + | ||
622 | + // term2.c_cflag &= ~CBAUD; /* Remove current BAUD rate */ | ||
623 | + // term2.c_cflag |= BOTHER; /* Allow custom BAUD rate using int input */ | ||
624 | + // term2.c_ispeed = speed; /* Set the input BAUD rate */ | ||
625 | + // term2.c_ospeed = speed; /* Set the output BAUD rate */ | ||
626 | + | ||
627 | + // ioctl(fd, TCSETS2, &term2); | ||
628 | +} | ||
629 | + | ||
630 | +void SerialPort::SetTermios2(termios2 tty) | ||
631 | +{ | ||
632 | + ioctl(fileDesc_, TCSETS2, &tty); | ||
633 | +} | ||
634 | + | ||
635 | +void SerialPort::Close() | ||
636 | +{ | ||
637 | + if(fileDesc_ != -1) | ||
638 | + { | ||
639 | + auto retVal = close(fileDesc_); | ||
640 | + if(retVal != 0) | ||
641 | + THROW_EXCEPT("Tried to close serial port " + device_ + ", but close() failed."); | ||
642 | + | ||
643 | + fileDesc_ = -1; | ||
644 | + } | ||
645 | + | ||
646 | + state_ = State::CLOSED; | ||
647 | +} | ||
648 | + | ||
649 | +void SerialPort::SetTimeout(int32_t timeout_ms) | ||
650 | +{ | ||
651 | + if(timeout_ms < -1) | ||
652 | + THROW_EXCEPT(std::string() + "timeout_ms provided to " + __PRETTY_FUNCTION__ + " was < -1, which is invalid."); | ||
653 | + | ||
654 | + if(timeout_ms > 25500) | ||
655 | + THROW_EXCEPT(std::string() + "timeout_ms provided to " + __PRETTY_FUNCTION__ + " was > 25500, which is invalid."); | ||
656 | + | ||
657 | + if(state_ == State::OPEN) | ||
658 | + THROW_EXCEPT(std::string() + __PRETTY_FUNCTION__ + " called while state == OPEN."); | ||
659 | + | ||
660 | + timeout_ms_ = timeout_ms; | ||
661 | +} | ||
662 | + | ||
663 | +int32_t SerialPort::Available() | ||
664 | +{ | ||
665 | + if(state_ != State::OPEN) | ||
666 | + THROW_EXCEPT(std::string() + __PRETTY_FUNCTION__ + " called but state != OPEN. Please call Open() first."); | ||
667 | + | ||
668 | + int32_t ret = 0; | ||
669 | + ioctl(fileDesc_, FIONREAD, &ret); | ||
670 | + return ret; | ||
671 | + | ||
672 | +} | ||
673 | + | ||
674 | +State SerialPort::GetState() | ||
675 | +{ | ||
676 | + return state_; | ||
677 | +} |
SerialPort.hpp
0 → 100644
1 | +++ a/SerialPort.hpp | ||
1 | +#pragma once | ||
2 | + | ||
3 | +// System headers | ||
4 | +#include <string> | ||
5 | +#include <fstream> // For file I/O (reading/writing to COM port) | ||
6 | +#include <sstream> | ||
7 | +// #include <termios.h> // POSIX terminal control definitions (struct termios) | ||
8 | +// #include <asm/termios.h> // Terminal control definitions (struct termios) | ||
9 | +#include <vector> | ||
10 | +#include <asm/ioctls.h> | ||
11 | +#include <asm/termbits.h> | ||
12 | + | ||
13 | +// User headers | ||
14 | +#include "Exception.hpp" | ||
15 | + | ||
16 | +/// \brief Represents the baud rate "types" that can be used with the serial port. STANDARD represents all | ||
17 | +/// the standard baud rates as provided by UNIX, CUSTOM represents a baud rate defined by an arbitray integer. | ||
18 | +enum class BaudRateType | ||
19 | +{ | ||
20 | + STANDARD, | ||
21 | + CUSTOM, | ||
22 | +}; | ||
23 | + | ||
24 | +/// \brief Strongly-typed enumeration of baud rates for use with the SerialPort class | ||
25 | +/// \details Specifies all the same baud rates as UNIX, as well as B_CUSTOM to specify your | ||
26 | +/// own. See https://linux.die.net/man/3/cfsetispeed for list of supported UNIX baud rates. | ||
27 | +enum class BaudRate | ||
28 | +{ | ||
29 | + B_0, | ||
30 | + B_50, | ||
31 | + B_75, | ||
32 | + B_110, | ||
33 | + B_134, | ||
34 | + B_150, | ||
35 | + B_200, | ||
36 | + B_300, | ||
37 | + B_600, | ||
38 | + B_1200, | ||
39 | + B_1800, | ||
40 | + B_2400, | ||
41 | + B_4800, | ||
42 | + B_9600, | ||
43 | + B_19200, | ||
44 | + B_38400, | ||
45 | + B_57600, | ||
46 | + B_115200, | ||
47 | + B_230400, | ||
48 | + B_460800, | ||
49 | + B_CUSTOM, // Placeholder | ||
50 | +}; | ||
51 | + | ||
52 | +/// \brief Enumeration of all the valid num. of data bits. Must align with the options | ||
53 | +/// provided in termbits.h, i.e. CS5, CS6, CS7 and CS8. | ||
54 | +enum class NumDataBits | ||
55 | +{ | ||
56 | + FIVE, | ||
57 | + SIX, | ||
58 | + SEVEN, | ||
59 | + EIGHT, | ||
60 | +}; | ||
61 | + | ||
62 | +enum class Parity | ||
63 | +{ | ||
64 | + NONE, | ||
65 | + EVEN, | ||
66 | + ODD, | ||
67 | +}; | ||
68 | + | ||
69 | +enum class NumStopBits | ||
70 | +{ | ||
71 | + ONE, | ||
72 | + TWO, | ||
73 | +}; | ||
74 | + | ||
75 | +/// \brief Represents the state of the serial port. | ||
76 | +enum class State | ||
77 | +{ | ||
78 | + CLOSED, | ||
79 | + OPEN, | ||
80 | +}; | ||
81 | + | ||
82 | +/// \brief SerialPort object is used to perform rx/tx serial communication. | ||
83 | +class SerialPort | ||
84 | +{ | ||
85 | +public: | ||
86 | + /// \brief Default constructor. You must specify at least the device before calling Open(). | ||
87 | + SerialPort(); | ||
88 | + | ||
89 | + /// \brief Constructor that sets up serial port with the basic (required) parameters. | ||
90 | + SerialPort(const std::string &device, BaudRate baudRate); | ||
91 | + | ||
92 | + /// \brief Constructor that sets up serial port and allows the user to specify all the common parameters. | ||
93 | + SerialPort(const std::string &device, BaudRate baudRate, NumDataBits numDataBits, Parity parity, NumStopBits numStopBits); | ||
94 | + | ||
95 | + /// \brief Constructor that sets up serial port with the basic parameters, and a custom baud rate. | ||
96 | + SerialPort(const std::string &device, speed_t baudRate); | ||
97 | + | ||
98 | + /// \brief Destructor. Closes serial port if still open. | ||
99 | + virtual ~SerialPort(); | ||
100 | + | ||
101 | + /// \brief Sets the device to use for serial port communications. | ||
102 | + /// \details Method can be called when serial port is in any state. | ||
103 | + void SetDevice(const std::string &device); | ||
104 | + | ||
105 | + /// \brief Call this to set a standard baud rate. | ||
106 | + void SetBaudRate(BaudRate baudRate); | ||
107 | + | ||
108 | + /// \brief Call this to set a custom baud rate. | ||
109 | + void SetBaudRate(speed_t baudRate); | ||
110 | + | ||
111 | + /// \brief Call this to set the num. of data bits. | ||
112 | + void SetNumDataBits(NumDataBits numDataBits); | ||
113 | + | ||
114 | + /// \brief Call this to set the parity. | ||
115 | + void SetParity(Parity parity); | ||
116 | + | ||
117 | + void SetNumStopBits(NumStopBits numStopBits); | ||
118 | + | ||
119 | + /// \brief Sets the read timeout (in milliseconds)/blocking mode. | ||
120 | + /// \details Only call when state != OPEN. This method manupulates VMIN and VTIME. | ||
121 | + /// \param timeout_ms Set to -1 to infinite timeout, 0 to return immediately with any data (non | ||
122 | + /// blocking, or >0 to wait for data for a specified number of milliseconds). Timeout will | ||
123 | + /// be rounded to the nearest 100ms (a Linux API restriction). Maximum value limited to | ||
124 | + /// 25500ms (another Linux API restriction). | ||
125 | + void SetTimeout(int32_t timeout_ms); | ||
126 | + | ||
127 | + /// \brief Enables/disables echo. | ||
128 | + /// \param value Pass in true to enable echo, false to disable echo. | ||
129 | + void SetEcho(bool value); | ||
130 | + | ||
131 | + /// \brief Opens the COM port for use. | ||
132 | + /// \throws CppLinuxSerial::Exception if device cannot be opened. | ||
133 | + /// \note Must call this before you can configure the COM port. | ||
134 | + void Open(); | ||
135 | + | ||
136 | + /// \brief Closes the COM port. | ||
137 | + void Close(); | ||
138 | + | ||
139 | + /// \brief Sends a text message over the com port. | ||
140 | + /// \param data The data that will be written to the COM port. | ||
141 | + /// \throws CppLinuxSerial::Exception if state != OPEN. | ||
142 | + void Write(const std::string& data); | ||
143 | + | ||
144 | + /// \brief Sends a binary message over the com port. | ||
145 | + /// \param data The data that will be written to the COM port. | ||
146 | + /// \throws CppLinuxSerial::Exception if state != OPEN. | ||
147 | + void WriteBinary(const std::vector<uint8_t>& data); | ||
148 | + | ||
149 | + /// \brief Use to read text from the COM port. | ||
150 | + /// \param data The object the read characters from the COM port will be saved to. | ||
151 | + /// \param wait_ms The amount of time to wait for data. Set to 0 for non-blocking mode. Set to -1 | ||
152 | + /// to wait indefinitely for new data. | ||
153 | + /// \throws CppLinuxSerial::Exception if state != OPEN. | ||
154 | + void Read(std::string& data); | ||
155 | + | ||
156 | + /// \brief Use to read binary data from the COM port. | ||
157 | + /// \param data The object the read uint8_t bytes from the COM port will be saved to. | ||
158 | + /// \param wait_ms The amount of time to wait for data. Set to 0 for non-blocking mode. Set to -1 | ||
159 | + /// to wait indefinitely for new data. | ||
160 | + /// \throws CppLinuxSerial::Exception if state != OPEN. | ||
161 | + void ReadBinary(std::vector<uint8_t>& data); | ||
162 | + | ||
163 | + /// \brief Use to get number of bytes available in receive buffer. | ||
164 | + /// \returns The number of bytes available in the receive buffer (ready to be read). | ||
165 | + /// \throws CppLinuxSerial::Exception if state != OPEN. | ||
166 | + int32_t Available(); | ||
167 | + | ||
168 | + /// \brief Use to get the state of the serial port | ||
169 | + /// \returns The state of the serial port | ||
170 | + State GetState(); | ||
171 | + | ||
172 | +private: | ||
173 | + | ||
174 | + /// \brief Configures the tty device as a serial port. | ||
175 | + /// \warning Device must be open (valid file descriptor) when this is called. | ||
176 | + void ConfigureTermios(); | ||
177 | + | ||
178 | + // void SetTermios(termios myTermios); | ||
179 | + | ||
180 | + /// \brief Returns a populated termios2 structure for the serial port pointed to by the file descriptor. | ||
181 | + termios2 GetTermios2(); | ||
182 | + | ||
183 | + /// \brief Assigns the provided tty settings to the serial port pointed to by the file descriptor. | ||
184 | + void SetTermios2(termios2 tty); | ||
185 | + | ||
186 | + /// \brief Keeps track of the serial port's state. | ||
187 | + State state_; | ||
188 | + | ||
189 | + /// \brief The file path to the serial port device (e.g. "/dev/ttyUSB0"). | ||
190 | + std::string device_; | ||
191 | + | ||
192 | + /// \brief The type of baud rate that the user has specified. | ||
193 | + BaudRateType baudRateType_; | ||
194 | + | ||
195 | + /// \brief The current baud rate if baudRateType_ == STANDARD. | ||
196 | + BaudRate baudRateStandard_; | ||
197 | + | ||
198 | + /// \brief The current baud rate if baudRateType_ == CUSTOM. | ||
199 | + speed_t baudRateCustom_; | ||
200 | + | ||
201 | + /// \brief The num. of data bits. Defaults to 8 (most common). | ||
202 | + NumDataBits numDataBits_ = NumDataBits::EIGHT; | ||
203 | + | ||
204 | + /// \brief The parity. Defaults to none (most common). | ||
205 | + Parity parity_ = Parity::NONE; | ||
206 | + | ||
207 | + /// \brief The num. of stop bits. Defaults to 1 (most common). | ||
208 | + NumStopBits numStopBits_ = NumStopBits::ONE; | ||
209 | + | ||
210 | + /// \brief The file descriptor for the open file. This gets written to when Open() is called. | ||
211 | + int fileDesc_; | ||
212 | + | ||
213 | + bool echo_; | ||
214 | + | ||
215 | + int32_t timeout_ms_; | ||
216 | + | ||
217 | + std::vector<char> readBuffer_; | ||
218 | + unsigned char readBufferSize_B_; | ||
219 | + | ||
220 | + static constexpr BaudRate defaultBaudRate_ = BaudRate::B_57600; | ||
221 | + static constexpr int32_t defaultTimeout_ms_ = -1; | ||
222 | + static constexpr unsigned char defaultReadBufferSize_B_ = 255; | ||
223 | +}; |
main.cpp
0 → 100644
1 | +++ a/main.cpp | ||
1 | +#include "SerialPort.hpp" | ||
2 | + | ||
3 | +#include <iostream> | ||
4 | +#include <string> | ||
5 | +#include <vector> | ||
6 | + | ||
7 | +int main(int argc, char** argv) | ||
8 | +{ | ||
9 | + SerialPort oPort; | ||
10 | + | ||
11 | + oPort.SetDevice( "/dev/ttyUSB0" ); | ||
12 | + oPort.SetNumDataBits(NumDataBits::EIGHT); | ||
13 | + oPort.SetParity(Parity::NONE); | ||
14 | + oPort.SetNumStopBits(NumStopBits::ONE); | ||
15 | + oPort.SetBaudRate( BaudRate::B_2400 ); | ||
16 | + | ||
17 | + oPort.Open(); | ||
18 | + | ||
19 | + // Create data package. | ||
20 | + std::vector<uint8_t> data_binair; | ||
21 | + std::string data_string; | ||
22 | + | ||
23 | + for( uint8_t nCount = 0; nCount < 255; nCount++ ) | ||
24 | + { | ||
25 | + data_binair.push_back( nCount ); | ||
26 | + data_string += std::to_string(nCount); | ||
27 | + } | ||
28 | + while( 1 ) | ||
29 | + { | ||
30 | + oPort.WriteBinary( data_binair ); | ||
31 | + oPort.Write( data_string ); | ||
32 | + } | ||
33 | + | ||
34 | + return 0; | ||
35 | +} | ||
36 | + |
nbproject/Makefile-Debug.mk
0 → 100644
1 | +++ a/nbproject/Makefile-Debug.mk | ||
1 | +# | ||
2 | +# Generated Makefile - do not edit! | ||
3 | +# | ||
4 | +# Edit the Makefile in the project folder instead (../Makefile). Each target | ||
5 | +# has a -pre and a -post target defined where you can add customized code. | ||
6 | +# | ||
7 | +# This makefile implements configuration specific macros and targets. | ||
8 | + | ||
9 | + | ||
10 | +# Environment | ||
11 | +MKDIR=mkdir | ||
12 | +CP=cp | ||
13 | +GREP=grep | ||
14 | +NM=nm | ||
15 | +CCADMIN=CCadmin | ||
16 | +RANLIB=ranlib | ||
17 | +CC=gcc | ||
18 | +CCC=g++ | ||
19 | +CXX=g++ | ||
20 | +FC=gfortran | ||
21 | +AS=as | ||
22 | + | ||
23 | +# Macros | ||
24 | +CND_PLATFORM=GNU-Linux | ||
25 | +CND_DLIB_EXT=so | ||
26 | +CND_CONF=Debug | ||
27 | +CND_DISTDIR=dist | ||
28 | +CND_BUILDDIR=build | ||
29 | + | ||
30 | +# Include project Makefile | ||
31 | +include Makefile | ||
32 | + | ||
33 | +# Object Directory | ||
34 | +OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM} | ||
35 | + | ||
36 | +# Object Files | ||
37 | +OBJECTFILES= \ | ||
38 | + ${OBJECTDIR}/SerialPort.o \ | ||
39 | + ${OBJECTDIR}/main.o | ||
40 | + | ||
41 | + | ||
42 | +# C Compiler Flags | ||
43 | +CFLAGS= | ||
44 | + | ||
45 | +# CC Compiler Flags | ||
46 | +CCFLAGS=-m64 | ||
47 | +CXXFLAGS=-m64 | ||
48 | + | ||
49 | +# Fortran Compiler Flags | ||
50 | +FFLAGS= | ||
51 | + | ||
52 | +# Assembler Flags | ||
53 | +ASFLAGS= | ||
54 | + | ||
55 | +# Link Libraries and Options | ||
56 | +LDLIBSOPTIONS= | ||
57 | + | ||
58 | +# Build Targets | ||
59 | +.build-conf: ${BUILD_SUBPROJECTS} | ||
60 | + "${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/serialport | ||
61 | + | ||
62 | +${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/serialport: ${OBJECTFILES} | ||
63 | + ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM} | ||
64 | + ${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/serialport ${OBJECTFILES} ${LDLIBSOPTIONS} | ||
65 | + | ||
66 | +${OBJECTDIR}/SerialPort.o: SerialPort.cpp | ||
67 | + ${MKDIR} -p ${OBJECTDIR} | ||
68 | + ${RM} "$@.d" | ||
69 | + $(COMPILE.cc) -g -std=c++14 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/SerialPort.o SerialPort.cpp | ||
70 | + | ||
71 | +${OBJECTDIR}/main.o: main.cpp | ||
72 | + ${MKDIR} -p ${OBJECTDIR} | ||
73 | + ${RM} "$@.d" | ||
74 | + $(COMPILE.cc) -g -std=c++14 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/main.o main.cpp | ||
75 | + | ||
76 | +# Subprojects | ||
77 | +.build-subprojects: | ||
78 | + | ||
79 | +# Clean Targets | ||
80 | +.clean-conf: ${CLEAN_SUBPROJECTS} | ||
81 | + ${RM} -r ${CND_BUILDDIR}/${CND_CONF} | ||
82 | + | ||
83 | +# Subprojects | ||
84 | +.clean-subprojects: | ||
85 | + | ||
86 | +# Enable dependency checking | ||
87 | +.dep.inc: .depcheck-impl | ||
88 | + | ||
89 | +include .dep.inc |
nbproject/Makefile-Release.mk
0 → 100644
1 | +++ a/nbproject/Makefile-Release.mk | ||
1 | +# | ||
2 | +# Generated Makefile - do not edit! | ||
3 | +# | ||
4 | +# Edit the Makefile in the project folder instead (../Makefile). Each target | ||
5 | +# has a -pre and a -post target defined where you can add customized code. | ||
6 | +# | ||
7 | +# This makefile implements configuration specific macros and targets. | ||
8 | + | ||
9 | + | ||
10 | +# Environment | ||
11 | +MKDIR=mkdir | ||
12 | +CP=cp | ||
13 | +GREP=grep | ||
14 | +NM=nm | ||
15 | +CCADMIN=CCadmin | ||
16 | +RANLIB=ranlib | ||
17 | +CC=gcc | ||
18 | +CCC=g++ | ||
19 | +CXX=g++ | ||
20 | +FC=gfortran | ||
21 | +AS=as | ||
22 | + | ||
23 | +# Macros | ||
24 | +CND_PLATFORM=GNU-Linux | ||
25 | +CND_DLIB_EXT=so | ||
26 | +CND_CONF=Release | ||
27 | +CND_DISTDIR=dist | ||
28 | +CND_BUILDDIR=build | ||
29 | + | ||
30 | +# Include project Makefile | ||
31 | +include Makefile | ||
32 | + | ||
33 | +# Object Directory | ||
34 | +OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM} | ||
35 | + | ||
36 | +# Object Files | ||
37 | +OBJECTFILES= \ | ||
38 | + ${OBJECTDIR}/SerialPort.o \ | ||
39 | + ${OBJECTDIR}/main.o | ||
40 | + | ||
41 | + | ||
42 | +# C Compiler Flags | ||
43 | +CFLAGS= | ||
44 | + | ||
45 | +# CC Compiler Flags | ||
46 | +CCFLAGS= | ||
47 | +CXXFLAGS= | ||
48 | + | ||
49 | +# Fortran Compiler Flags | ||
50 | +FFLAGS= | ||
51 | + | ||
52 | +# Assembler Flags | ||
53 | +ASFLAGS= | ||
54 | + | ||
55 | +# Link Libraries and Options | ||
56 | +LDLIBSOPTIONS= | ||
57 | + | ||
58 | +# Build Targets | ||
59 | +.build-conf: ${BUILD_SUBPROJECTS} | ||
60 | + "${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/serialport | ||
61 | + | ||
62 | +${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/serialport: ${OBJECTFILES} | ||
63 | + ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM} | ||
64 | + ${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/serialport ${OBJECTFILES} ${LDLIBSOPTIONS} | ||
65 | + | ||
66 | +${OBJECTDIR}/SerialPort.o: SerialPort.cpp | ||
67 | + ${MKDIR} -p ${OBJECTDIR} | ||
68 | + ${RM} "$@.d" | ||
69 | + $(COMPILE.cc) -O2 -std=c++14 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/SerialPort.o SerialPort.cpp | ||
70 | + | ||
71 | +${OBJECTDIR}/main.o: main.cpp | ||
72 | + ${MKDIR} -p ${OBJECTDIR} | ||
73 | + ${RM} "$@.d" | ||
74 | + $(COMPILE.cc) -O2 -std=c++14 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/main.o main.cpp | ||
75 | + | ||
76 | +# Subprojects | ||
77 | +.build-subprojects: | ||
78 | + | ||
79 | +# Clean Targets | ||
80 | +.clean-conf: ${CLEAN_SUBPROJECTS} | ||
81 | + ${RM} -r ${CND_BUILDDIR}/${CND_CONF} | ||
82 | + | ||
83 | +# Subprojects | ||
84 | +.clean-subprojects: | ||
85 | + | ||
86 | +# Enable dependency checking | ||
87 | +.dep.inc: .depcheck-impl | ||
88 | + | ||
89 | +include .dep.inc |
nbproject/Makefile-impl.mk
0 → 100644
1 | +++ a/nbproject/Makefile-impl.mk | ||
1 | +# | ||
2 | +# Generated Makefile - do not edit! | ||
3 | +# | ||
4 | +# Edit the Makefile in the project folder instead (../Makefile). Each target | ||
5 | +# has a pre- and a post- target defined where you can add customization code. | ||
6 | +# | ||
7 | +# This makefile implements macros and targets common to all configurations. | ||
8 | +# | ||
9 | +# NOCDDL | ||
10 | + | ||
11 | + | ||
12 | +# Building and Cleaning subprojects are done by default, but can be controlled with the SUB | ||
13 | +# macro. If SUB=no, subprojects will not be built or cleaned. The following macro | ||
14 | +# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf | ||
15 | +# and .clean-reqprojects-conf unless SUB has the value 'no' | ||
16 | +SUB_no=NO | ||
17 | +SUBPROJECTS=${SUB_${SUB}} | ||
18 | +BUILD_SUBPROJECTS_=.build-subprojects | ||
19 | +BUILD_SUBPROJECTS_NO= | ||
20 | +BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}} | ||
21 | +CLEAN_SUBPROJECTS_=.clean-subprojects | ||
22 | +CLEAN_SUBPROJECTS_NO= | ||
23 | +CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}} | ||
24 | + | ||
25 | + | ||
26 | +# Project Name | ||
27 | +PROJECTNAME=serialport | ||
28 | + | ||
29 | +# Active Configuration | ||
30 | +DEFAULTCONF=Debug | ||
31 | +CONF=${DEFAULTCONF} | ||
32 | + | ||
33 | +# All Configurations | ||
34 | +ALLCONFS=Debug Release | ||
35 | + | ||
36 | + | ||
37 | +# build | ||
38 | +.build-impl: .build-pre .validate-impl .depcheck-impl | ||
39 | + @#echo "=> Running $@... Configuration=$(CONF)" | ||
40 | + "${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf | ||
41 | + | ||
42 | + | ||
43 | +# clean | ||
44 | +.clean-impl: .clean-pre .validate-impl .depcheck-impl | ||
45 | + @#echo "=> Running $@... Configuration=$(CONF)" | ||
46 | + "${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf | ||
47 | + | ||
48 | + | ||
49 | +# clobber | ||
50 | +.clobber-impl: .clobber-pre .depcheck-impl | ||
51 | + @#echo "=> Running $@..." | ||
52 | + for CONF in ${ALLCONFS}; \ | ||
53 | + do \ | ||
54 | + "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf; \ | ||
55 | + done | ||
56 | + | ||
57 | +# all | ||
58 | +.all-impl: .all-pre .depcheck-impl | ||
59 | + @#echo "=> Running $@..." | ||
60 | + for CONF in ${ALLCONFS}; \ | ||
61 | + do \ | ||
62 | + "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf; \ | ||
63 | + done | ||
64 | + | ||
65 | +# build tests | ||
66 | +.build-tests-impl: .build-impl .build-tests-pre | ||
67 | + @#echo "=> Running $@... Configuration=$(CONF)" | ||
68 | + "${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-tests-conf | ||
69 | + | ||
70 | +# run tests | ||
71 | +.test-impl: .build-tests-impl .test-pre | ||
72 | + @#echo "=> Running $@... Configuration=$(CONF)" | ||
73 | + "${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .test-conf | ||
74 | + | ||
75 | +# dependency checking support | ||
76 | +.depcheck-impl: | ||
77 | + @echo "# This code depends on make tool being used" >.dep.inc | ||
78 | + @if [ -n "${MAKE_VERSION}" ]; then \ | ||
79 | + echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES} \$${TESTOBJECTFILES}))" >>.dep.inc; \ | ||
80 | + echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \ | ||
81 | + echo "include \$${DEPFILES}" >>.dep.inc; \ | ||
82 | + echo "endif" >>.dep.inc; \ | ||
83 | + else \ | ||
84 | + echo ".KEEP_STATE:" >>.dep.inc; \ | ||
85 | + echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \ | ||
86 | + fi | ||
87 | + | ||
88 | +# configuration validation | ||
89 | +.validate-impl: | ||
90 | + @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ | ||
91 | + then \ | ||
92 | + echo ""; \ | ||
93 | + echo "Error: can not find the makefile for configuration '${CONF}' in project ${PROJECTNAME}"; \ | ||
94 | + echo "See 'make help' for details."; \ | ||
95 | + echo "Current directory: " `pwd`; \ | ||
96 | + echo ""; \ | ||
97 | + fi | ||
98 | + @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ | ||
99 | + then \ | ||
100 | + exit 1; \ | ||
101 | + fi | ||
102 | + | ||
103 | + | ||
104 | +# help | ||
105 | +.help-impl: .help-pre | ||
106 | + @echo "This makefile supports the following configurations:" | ||
107 | + @echo " ${ALLCONFS}" | ||
108 | + @echo "" | ||
109 | + @echo "and the following targets:" | ||
110 | + @echo " build (default target)" | ||
111 | + @echo " clean" | ||
112 | + @echo " clobber" | ||
113 | + @echo " all" | ||
114 | + @echo " help" | ||
115 | + @echo "" | ||
116 | + @echo "Makefile Usage:" | ||
117 | + @echo " make [CONF=<CONFIGURATION>] [SUB=no] build" | ||
118 | + @echo " make [CONF=<CONFIGURATION>] [SUB=no] clean" | ||
119 | + @echo " make [SUB=no] clobber" | ||
120 | + @echo " make [SUB=no] all" | ||
121 | + @echo " make help" | ||
122 | + @echo "" | ||
123 | + @echo "Target 'build' will build a specific configuration and, unless 'SUB=no'," | ||
124 | + @echo " also build subprojects." | ||
125 | + @echo "Target 'clean' will clean a specific configuration and, unless 'SUB=no'," | ||
126 | + @echo " also clean subprojects." | ||
127 | + @echo "Target 'clobber' will remove all built files from all configurations and," | ||
128 | + @echo " unless 'SUB=no', also from subprojects." | ||
129 | + @echo "Target 'all' will will build all configurations and, unless 'SUB=no'," | ||
130 | + @echo " also build subprojects." | ||
131 | + @echo "Target 'help' prints this message." | ||
132 | + @echo "" | ||
133 | + |
nbproject/Makefile-variables.mk
0 → 100644
1 | +++ a/nbproject/Makefile-variables.mk | ||
1 | +# | ||
2 | +# Generated - do not edit! | ||
3 | +# | ||
4 | +# NOCDDL | ||
5 | +# | ||
6 | +CND_BASEDIR=`pwd` | ||
7 | +CND_BUILDDIR=build | ||
8 | +CND_DISTDIR=dist | ||
9 | +# Debug configuration | ||
10 | +CND_PLATFORM_Debug=GNU-Linux | ||
11 | +CND_ARTIFACT_DIR_Debug=dist/Debug/GNU-Linux | ||
12 | +CND_ARTIFACT_NAME_Debug=serialport | ||
13 | +CND_ARTIFACT_PATH_Debug=dist/Debug/GNU-Linux/serialport | ||
14 | +CND_PACKAGE_DIR_Debug=dist/Debug/GNU-Linux/package | ||
15 | +CND_PACKAGE_NAME_Debug=serialport.tar | ||
16 | +CND_PACKAGE_PATH_Debug=dist/Debug/GNU-Linux/package/serialport.tar | ||
17 | +# Release configuration | ||
18 | +CND_PLATFORM_Release=GNU-Linux | ||
19 | +CND_ARTIFACT_DIR_Release=dist/Release/GNU-Linux | ||
20 | +CND_ARTIFACT_NAME_Release=serialport | ||
21 | +CND_ARTIFACT_PATH_Release=dist/Release/GNU-Linux/serialport | ||
22 | +CND_PACKAGE_DIR_Release=dist/Release/GNU-Linux/package | ||
23 | +CND_PACKAGE_NAME_Release=serialport.tar | ||
24 | +CND_PACKAGE_PATH_Release=dist/Release/GNU-Linux/package/serialport.tar | ||
25 | +# | ||
26 | +# include compiler specific variables | ||
27 | +# | ||
28 | +# dmake command | ||
29 | +ROOT:sh = test -f nbproject/private/Makefile-variables.mk || \ | ||
30 | + (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk) | ||
31 | +# | ||
32 | +# gmake command | ||
33 | +.PHONY: $(shell test -f nbproject/private/Makefile-variables.mk || (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk)) | ||
34 | +# | ||
35 | +include nbproject/private/Makefile-variables.mk |
nbproject/Package-Debug.bash
0 → 100644
1 | +++ a/nbproject/Package-Debug.bash | ||
1 | +#!/bin/bash -x | ||
2 | + | ||
3 | +# | ||
4 | +# Generated - do not edit! | ||
5 | +# | ||
6 | + | ||
7 | +# Macros | ||
8 | +TOP=`pwd` | ||
9 | +CND_PLATFORM=GNU-Linux | ||
10 | +CND_CONF=Debug | ||
11 | +CND_DISTDIR=dist | ||
12 | +CND_BUILDDIR=build | ||
13 | +CND_DLIB_EXT=so | ||
14 | +NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging | ||
15 | +TMPDIRNAME=tmp-packaging | ||
16 | +OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/serialport | ||
17 | +OUTPUT_BASENAME=serialport | ||
18 | +PACKAGE_TOP_DIR=serialport/ | ||
19 | + | ||
20 | +# Functions | ||
21 | +function checkReturnCode | ||
22 | +{ | ||
23 | + rc=$? | ||
24 | + if [ $rc != 0 ] | ||
25 | + then | ||
26 | + exit $rc | ||
27 | + fi | ||
28 | +} | ||
29 | +function makeDirectory | ||
30 | +# $1 directory path | ||
31 | +# $2 permission (optional) | ||
32 | +{ | ||
33 | + mkdir -p "$1" | ||
34 | + checkReturnCode | ||
35 | + if [ "$2" != "" ] | ||
36 | + then | ||
37 | + chmod $2 "$1" | ||
38 | + checkReturnCode | ||
39 | + fi | ||
40 | +} | ||
41 | +function copyFileToTmpDir | ||
42 | +# $1 from-file path | ||
43 | +# $2 to-file path | ||
44 | +# $3 permission | ||
45 | +{ | ||
46 | + cp "$1" "$2" | ||
47 | + checkReturnCode | ||
48 | + if [ "$3" != "" ] | ||
49 | + then | ||
50 | + chmod $3 "$2" | ||
51 | + checkReturnCode | ||
52 | + fi | ||
53 | +} | ||
54 | + | ||
55 | +# Setup | ||
56 | +cd "${TOP}" | ||
57 | +mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package | ||
58 | +rm -rf ${NBTMPDIR} | ||
59 | +mkdir -p ${NBTMPDIR} | ||
60 | + | ||
61 | +# Copy files and create directories and links | ||
62 | +cd "${TOP}" | ||
63 | +makeDirectory "${NBTMPDIR}/serialport/bin" | ||
64 | +copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755 | ||
65 | + | ||
66 | + | ||
67 | +# Generate tar file | ||
68 | +cd "${TOP}" | ||
69 | +rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/serialport.tar | ||
70 | +cd ${NBTMPDIR} | ||
71 | +tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/serialport.tar * | ||
72 | +checkReturnCode | ||
73 | + | ||
74 | +# Cleanup | ||
75 | +cd "${TOP}" | ||
76 | +rm -rf ${NBTMPDIR} |
nbproject/Package-Release.bash
0 → 100644
1 | +++ a/nbproject/Package-Release.bash | ||
1 | +#!/bin/bash -x | ||
2 | + | ||
3 | +# | ||
4 | +# Generated - do not edit! | ||
5 | +# | ||
6 | + | ||
7 | +# Macros | ||
8 | +TOP=`pwd` | ||
9 | +CND_PLATFORM=GNU-Linux | ||
10 | +CND_CONF=Release | ||
11 | +CND_DISTDIR=dist | ||
12 | +CND_BUILDDIR=build | ||
13 | +CND_DLIB_EXT=so | ||
14 | +NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging | ||
15 | +TMPDIRNAME=tmp-packaging | ||
16 | +OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/serialport | ||
17 | +OUTPUT_BASENAME=serialport | ||
18 | +PACKAGE_TOP_DIR=serialport/ | ||
19 | + | ||
20 | +# Functions | ||
21 | +function checkReturnCode | ||
22 | +{ | ||
23 | + rc=$? | ||
24 | + if [ $rc != 0 ] | ||
25 | + then | ||
26 | + exit $rc | ||
27 | + fi | ||
28 | +} | ||
29 | +function makeDirectory | ||
30 | +# $1 directory path | ||
31 | +# $2 permission (optional) | ||
32 | +{ | ||
33 | + mkdir -p "$1" | ||
34 | + checkReturnCode | ||
35 | + if [ "$2" != "" ] | ||
36 | + then | ||
37 | + chmod $2 "$1" | ||
38 | + checkReturnCode | ||
39 | + fi | ||
40 | +} | ||
41 | +function copyFileToTmpDir | ||
42 | +# $1 from-file path | ||
43 | +# $2 to-file path | ||
44 | +# $3 permission | ||
45 | +{ | ||
46 | + cp "$1" "$2" | ||
47 | + checkReturnCode | ||
48 | + if [ "$3" != "" ] | ||
49 | + then | ||
50 | + chmod $3 "$2" | ||
51 | + checkReturnCode | ||
52 | + fi | ||
53 | +} | ||
54 | + | ||
55 | +# Setup | ||
56 | +cd "${TOP}" | ||
57 | +mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package | ||
58 | +rm -rf ${NBTMPDIR} | ||
59 | +mkdir -p ${NBTMPDIR} | ||
60 | + | ||
61 | +# Copy files and create directories and links | ||
62 | +cd "${TOP}" | ||
63 | +makeDirectory "${NBTMPDIR}/serialport/bin" | ||
64 | +copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755 | ||
65 | + | ||
66 | + | ||
67 | +# Generate tar file | ||
68 | +cd "${TOP}" | ||
69 | +rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/serialport.tar | ||
70 | +cd ${NBTMPDIR} | ||
71 | +tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/serialport.tar * | ||
72 | +checkReturnCode | ||
73 | + | ||
74 | +# Cleanup | ||
75 | +cd "${TOP}" | ||
76 | +rm -rf ${NBTMPDIR} |
nbproject/configurations.xml
0 → 100644
1 | +++ a/nbproject/configurations.xml | ||
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<configurationDescriptor version="100"> | ||
3 | + <logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT"> | ||
4 | + <logicalFolder name="HeaderFiles" | ||
5 | + displayName="Header Files" | ||
6 | + projectFiles="true"> | ||
7 | + <itemPath>Exception.hpp</itemPath> | ||
8 | + <itemPath>SerialPort.hpp</itemPath> | ||
9 | + </logicalFolder> | ||
10 | + <logicalFolder name="ResourceFiles" | ||
11 | + displayName="Resource Files" | ||
12 | + projectFiles="true"> | ||
13 | + </logicalFolder> | ||
14 | + <logicalFolder name="SourceFiles" | ||
15 | + displayName="Source Files" | ||
16 | + projectFiles="true"> | ||
17 | + <itemPath>SerialPort.cpp</itemPath> | ||
18 | + <itemPath>main.cpp</itemPath> | ||
19 | + </logicalFolder> | ||
20 | + <logicalFolder name="TestFiles" | ||
21 | + displayName="Test Files" | ||
22 | + projectFiles="false" | ||
23 | + kind="TEST_LOGICAL_FOLDER"> | ||
24 | + </logicalFolder> | ||
25 | + <logicalFolder name="ExternalFiles" | ||
26 | + displayName="Important Files" | ||
27 | + projectFiles="false" | ||
28 | + kind="IMPORTANT_FILES_FOLDER"> | ||
29 | + <itemPath>Makefile</itemPath> | ||
30 | + </logicalFolder> | ||
31 | + </logicalFolder> | ||
32 | + <projectmakefile>Makefile</projectmakefile> | ||
33 | + <confs> | ||
34 | + <conf name="Debug" type="1"> | ||
35 | + <toolsSet> | ||
36 | + <compilerSet>default</compilerSet> | ||
37 | + <dependencyChecking>true</dependencyChecking> | ||
38 | + <rebuildPropChanged>false</rebuildPropChanged> | ||
39 | + </toolsSet> | ||
40 | + <compileType> | ||
41 | + <ccTool> | ||
42 | + <architecture>2</architecture> | ||
43 | + <standard>11</standard> | ||
44 | + </ccTool> | ||
45 | + </compileType> | ||
46 | + <item path="Exception.hpp" ex="false" tool="3" flavor2="0"> | ||
47 | + </item> | ||
48 | + <item path="SerialPort.cpp" ex="false" tool="1" flavor2="0"> | ||
49 | + </item> | ||
50 | + <item path="SerialPort.hpp" ex="false" tool="3" flavor2="0"> | ||
51 | + </item> | ||
52 | + <item path="main.cpp" ex="false" tool="1" flavor2="0"> | ||
53 | + </item> | ||
54 | + </conf> | ||
55 | + <conf name="Release" type="1"> | ||
56 | + <toolsSet> | ||
57 | + <compilerSet>default</compilerSet> | ||
58 | + <dependencyChecking>true</dependencyChecking> | ||
59 | + <rebuildPropChanged>false</rebuildPropChanged> | ||
60 | + </toolsSet> | ||
61 | + <compileType> | ||
62 | + <cTool> | ||
63 | + <developmentMode>5</developmentMode> | ||
64 | + </cTool> | ||
65 | + <ccTool> | ||
66 | + <developmentMode>5</developmentMode> | ||
67 | + <standard>11</standard> | ||
68 | + </ccTool> | ||
69 | + <fortranCompilerTool> | ||
70 | + <developmentMode>5</developmentMode> | ||
71 | + </fortranCompilerTool> | ||
72 | + <asmTool> | ||
73 | + <developmentMode>5</developmentMode> | ||
74 | + </asmTool> | ||
75 | + </compileType> | ||
76 | + <item path="Exception.hpp" ex="false" tool="3" flavor2="0"> | ||
77 | + </item> | ||
78 | + <item path="SerialPort.cpp" ex="false" tool="1" flavor2="0"> | ||
79 | + </item> | ||
80 | + <item path="SerialPort.hpp" ex="false" tool="3" flavor2="0"> | ||
81 | + </item> | ||
82 | + <item path="main.cpp" ex="false" tool="1" flavor2="0"> | ||
83 | + </item> | ||
84 | + </conf> | ||
85 | + </confs> | ||
86 | +</configurationDescriptor> |
nbproject/private/Makefile-variables.mk
0 → 100644
nbproject/private/c_standard_headers_indexer.c
0 → 100644
1 | +++ a/nbproject/private/c_standard_headers_indexer.c | ||
1 | +/* | ||
2 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | ||
3 | + * | ||
4 | + * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. | ||
5 | + * | ||
6 | + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. | ||
7 | + * Other names may be trademarks of their respective owners. | ||
8 | + * | ||
9 | + * The contents of this file are subject to the terms of either the GNU | ||
10 | + * General Public License Version 2 only ("GPL") or the Common | ||
11 | + * Development and Distribution License("CDDL") (collectively, the | ||
12 | + * "License"). You may not use this file except in compliance with the | ||
13 | + * License. You can obtain a copy of the License at | ||
14 | + * http://www.netbeans.org/cddl-gplv2.html | ||
15 | + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the | ||
16 | + * specific language governing permissions and limitations under the | ||
17 | + * License. When distributing the software, include this License Header | ||
18 | + * Notice in each file and include the License file at | ||
19 | + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this | ||
20 | + * particular file as subject to the "Classpath" exception as provided | ||
21 | + * by Oracle in the GPL Version 2 section of the License file that | ||
22 | + * accompanied this code. If applicable, add the following below the | ||
23 | + * License Header, with the fields enclosed by brackets [] replaced by | ||
24 | + * your own identifying information: | ||
25 | + * "Portions Copyrighted [year] [name of copyright owner]" | ||
26 | + * | ||
27 | + * If you wish your version of this file to be governed by only the CDDL | ||
28 | + * or only the GPL Version 2, indicate your decision by adding | ||
29 | + * "[Contributor] elects to include this software in this distribution | ||
30 | + * under the [CDDL or GPL Version 2] license." If you do not indicate a | ||
31 | + * single choice of license, a recipient has the option to distribute | ||
32 | + * your version of this file under either the CDDL, the GPL Version 2 or | ||
33 | + * to extend the choice of license to its licensees as provided above. | ||
34 | + * However, if you add GPL Version 2 code and therefore, elected the GPL | ||
35 | + * Version 2 license, then the option applies only if the new code is | ||
36 | + * made subject to such option by the copyright holder. | ||
37 | + * | ||
38 | + * Contributor(s): | ||
39 | + */ | ||
40 | + | ||
41 | +// List of standard headers was taken in http://en.cppreference.com/w/c/header | ||
42 | + | ||
43 | +#include <assert.h> // Conditionally compiled macro that compares its argument to zero | ||
44 | +#include <ctype.h> // Functions to determine the type contained in character data | ||
45 | +#include <errno.h> // Macros reporting error conditions | ||
46 | +#include <float.h> // Limits of float types | ||
47 | +#include <limits.h> // Sizes of basic types | ||
48 | +#include <locale.h> // Localization utilities | ||
49 | +#include <math.h> // Common mathematics functions | ||
50 | +#include <setjmp.h> // Nonlocal jumps | ||
51 | +#include <signal.h> // Signal handling | ||
52 | +#include <stdarg.h> // Variable arguments | ||
53 | +#include <stddef.h> // Common macro definitions | ||
54 | +#include <stdio.h> // Input/output | ||
55 | +#include <string.h> // String handling | ||
56 | +#include <stdlib.h> // General utilities: memory management, program utilities, string conversions, random numbers | ||
57 | +#include <time.h> // Time/date utilities | ||
58 | +#include <iso646.h> // (since C95) Alternative operator spellings | ||
59 | +#include <wchar.h> // (since C95) Extended multibyte and wide character utilities | ||
60 | +#include <wctype.h> // (since C95) Wide character classification and mapping utilities | ||
61 | +#ifdef _STDC_C99 | ||
62 | +#include <complex.h> // (since C99) Complex number arithmetic | ||
63 | +#include <fenv.h> // (since C99) Floating-point environment | ||
64 | +#include <inttypes.h> // (since C99) Format conversion of integer types | ||
65 | +#include <stdbool.h> // (since C99) Boolean type | ||
66 | +#include <stdint.h> // (since C99) Fixed-width integer types | ||
67 | +#include <tgmath.h> // (since C99) Type-generic math (macros wrapping math.h and complex.h) | ||
68 | +#endif | ||
69 | +#ifdef _STDC_C11 | ||
70 | +#include <stdalign.h> // (since C11) alignas and alignof convenience macros | ||
71 | +#include <stdatomic.h> // (since C11) Atomic types | ||
72 | +#include <stdnoreturn.h> // (since C11) noreturn convenience macros | ||
73 | +#include <threads.h> // (since C11) Thread library | ||
74 | +#include <uchar.h> // (since C11) UTF-16 and UTF-32 character utilities | ||
75 | +#endif |
nbproject/private/configurations.xml
0 → 100644
1 | +++ a/nbproject/private/configurations.xml | ||
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<configurationDescriptor version="100"> | ||
3 | + <projectmakefile>Makefile</projectmakefile> | ||
4 | + <confs> | ||
5 | + <conf name="Debug" type="1"> | ||
6 | + <toolsSet> | ||
7 | + <developmentServer>localhost</developmentServer> | ||
8 | + <platform>2</platform> | ||
9 | + </toolsSet> | ||
10 | + <dbx_gdbdebugger version="1"> | ||
11 | + <gdb_pathmaps> | ||
12 | + </gdb_pathmaps> | ||
13 | + <gdb_interceptlist> | ||
14 | + <gdbinterceptoptions gdb_all="false" gdb_unhandled="true" gdb_unexpected="true"/> | ||
15 | + </gdb_interceptlist> | ||
16 | + <gdb_options> | ||
17 | + <DebugOptions> | ||
18 | + </DebugOptions> | ||
19 | + </gdb_options> | ||
20 | + <gdb_buildfirst gdb_buildfirst_overriden="false" gdb_buildfirst_old="false"/> | ||
21 | + </dbx_gdbdebugger> | ||
22 | + <nativedebugger version="1"> | ||
23 | + <engine>gdb</engine> | ||
24 | + </nativedebugger> | ||
25 | + <runprofile version="9"> | ||
26 | + <runcommandpicklist> | ||
27 | + <runcommandpicklistitem>"${OUTPUT_PATH}"</runcommandpicklistitem> | ||
28 | + </runcommandpicklist> | ||
29 | + <runcommand>"${OUTPUT_PATH}"</runcommand> | ||
30 | + <rundir></rundir> | ||
31 | + <buildfirst>true</buildfirst> | ||
32 | + <terminal-type>0</terminal-type> | ||
33 | + <remove-instrumentation>0</remove-instrumentation> | ||
34 | + <environment> | ||
35 | + </environment> | ||
36 | + </runprofile> | ||
37 | + </conf> | ||
38 | + <conf name="Release" type="1"> | ||
39 | + <toolsSet> | ||
40 | + <developmentServer>localhost</developmentServer> | ||
41 | + <platform>2</platform> | ||
42 | + </toolsSet> | ||
43 | + <dbx_gdbdebugger version="1"> | ||
44 | + <gdb_pathmaps> | ||
45 | + </gdb_pathmaps> | ||
46 | + <gdb_interceptlist> | ||
47 | + <gdbinterceptoptions gdb_all="false" gdb_unhandled="true" gdb_unexpected="true"/> | ||
48 | + </gdb_interceptlist> | ||
49 | + <gdb_options> | ||
50 | + <DebugOptions> | ||
51 | + </DebugOptions> | ||
52 | + </gdb_options> | ||
53 | + <gdb_buildfirst gdb_buildfirst_overriden="false" gdb_buildfirst_old="false"/> | ||
54 | + </dbx_gdbdebugger> | ||
55 | + <nativedebugger version="1"> | ||
56 | + <engine>gdb</engine> | ||
57 | + </nativedebugger> | ||
58 | + <runprofile version="9"> | ||
59 | + <runcommandpicklist> | ||
60 | + <runcommandpicklistitem>"${OUTPUT_PATH}"</runcommandpicklistitem> | ||
61 | + </runcommandpicklist> | ||
62 | + <runcommand>"${OUTPUT_PATH}"</runcommand> | ||
63 | + <rundir></rundir> | ||
64 | + <buildfirst>true</buildfirst> | ||
65 | + <terminal-type>0</terminal-type> | ||
66 | + <remove-instrumentation>0</remove-instrumentation> | ||
67 | + <environment> | ||
68 | + </environment> | ||
69 | + </runprofile> | ||
70 | + </conf> | ||
71 | + </confs> | ||
72 | +</configurationDescriptor> |
nbproject/private/cpp_standard_headers_indexer.cpp
0 → 100644
1 | +++ a/nbproject/private/cpp_standard_headers_indexer.cpp | ||
1 | +/* | ||
2 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | ||
3 | + * | ||
4 | + * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. | ||
5 | + * | ||
6 | + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. | ||
7 | + * Other names may be trademarks of their respective owners. | ||
8 | + * | ||
9 | + * The contents of this file are subject to the terms of either the GNU | ||
10 | + * General Public License Version 2 only ("GPL") or the Common | ||
11 | + * Development and Distribution License("CDDL") (collectively, the | ||
12 | + * "License"). You may not use this file except in compliance with the | ||
13 | + * License. You can obtain a copy of the License at | ||
14 | + * http://www.netbeans.org/cddl-gplv2.html | ||
15 | + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the | ||
16 | + * specific language governing permissions and limitations under the | ||
17 | + * License. When distributing the software, include this License Header | ||
18 | + * Notice in each file and include the License file at | ||
19 | + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this | ||
20 | + * particular file as subject to the "Classpath" exception as provided | ||
21 | + * by Oracle in the GPL Version 2 section of the License file that | ||
22 | + * accompanied this code. If applicable, add the following below the | ||
23 | + * License Header, with the fields enclosed by brackets [] replaced by | ||
24 | + * your own identifying information: | ||
25 | + * "Portions Copyrighted [year] [name of copyright owner]" | ||
26 | + * | ||
27 | + * If you wish your version of this file to be governed by only the CDDL | ||
28 | + * or only the GPL Version 2, indicate your decision by adding | ||
29 | + * "[Contributor] elects to include this software in this distribution | ||
30 | + * under the [CDDL or GPL Version 2] license." If you do not indicate a | ||
31 | + * single choice of license, a recipient has the option to distribute | ||
32 | + * your version of this file under either the CDDL, the GPL Version 2 or | ||
33 | + * to extend the choice of license to its licensees as provided above. | ||
34 | + * However, if you add GPL Version 2 code and therefore, elected the GPL | ||
35 | + * Version 2 license, then the option applies only if the new code is | ||
36 | + * made subject to such option by the copyright holder. | ||
37 | + * | ||
38 | + * Contributor(s): | ||
39 | + */ | ||
40 | + | ||
41 | +// List of standard headers was taken in http://en.cppreference.com/w/cpp/header | ||
42 | + | ||
43 | +#include <cstdlib> // General purpose utilities: program control, dynamic memory allocation, random numbers, sort and search | ||
44 | +#include <csignal> // Functions and macro constants for signal management | ||
45 | +#include <csetjmp> // Macro (and function) that saves (and jumps) to an execution context | ||
46 | +#include <cstdarg> // Handling of variable length argument lists | ||
47 | +#include <typeinfo> // Runtime type information utilities | ||
48 | +#include <bitset> // std::bitset class template | ||
49 | +#include <functional> // Function objects, designed for use with the standard algorithms | ||
50 | +#include <utility> // Various utility components | ||
51 | +#include <ctime> // C-style time/date utilites | ||
52 | +#include <cstddef> // typedefs for types such as size_t, NULL and others | ||
53 | +#include <new> // Low-level memory management utilities | ||
54 | +#include <memory> // Higher level memory management utilities | ||
55 | +#include <climits> // limits of integral types | ||
56 | +#include <cfloat> // limits of float types | ||
57 | +#include <limits> // standardized way to query properties of arithmetic types | ||
58 | +#include <exception> // Exception handling utilities | ||
59 | +#include <stdexcept> // Standard exception objects | ||
60 | +#include <cassert> // Conditionally compiled macro that compares its argument to zero | ||
61 | +#include <cerrno> // Macro containing the last error number | ||
62 | +#include <cctype> // functions to determine the type contained in character data | ||
63 | +#include <cwctype> // functions for determining the type of wide character data | ||
64 | +#include <cstring> // various narrow character string handling functions | ||
65 | +#include <cwchar> // various wide and multibyte string handling functions | ||
66 | +#include <string> // std::basic_string class template | ||
67 | +#include <vector> // std::vector container | ||
68 | +#include <deque> // std::deque container | ||
69 | +#include <list> // std::list container | ||
70 | +#include <set> // std::set and std::multiset associative containers | ||
71 | +#include <map> // std::map and std::multimap associative containers | ||
72 | +#include <stack> // std::stack container adaptor | ||
73 | +#include <queue> // std::queue and std::priority_queue container adaptors | ||
74 | +#include <algorithm> // Algorithms that operate on containers | ||
75 | +#include <iterator> // Container iterators | ||
76 | +#include <cmath> // Common mathematics functions | ||
77 | +#include <complex> // Complex number type | ||
78 | +#include <valarray> // Class for representing and manipulating arrays of values | ||
79 | +#include <numeric> // Numeric operations on values in containers | ||
80 | +#include <iosfwd> // forward declarations of all classes in the input/output library | ||
81 | +#include <ios> // std::ios_base class, std::basic_ios class template and several typedefs | ||
82 | +#include <istream> // std::basic_istream class template and several typedefs | ||
83 | +#include <ostream> // std::basic_ostream, std::basic_iostream class templates and several typedefs | ||
84 | +#include <iostream> // several standard stream objects | ||
85 | +#include <fstream> // std::basic_fstream, std::basic_ifstream, std::basic_ofstream class templates and several typedefs | ||
86 | +#include <sstream> // std::basic_stringstream, std::basic_istringstream, std::basic_ostringstream class templates and several typedefs | ||
87 | +#include <strstream> // std::strstream, std::istrstream, std::ostrstream(deprecated) | ||
88 | +#include <iomanip> // Helper functions to control the format or input and output | ||
89 | +#include <streambuf> // std::basic_streambuf class template | ||
90 | +#include <cstdio> // C-style input-output functions | ||
91 | +#include <locale> // Localization utilities | ||
92 | +#include <clocale> // C localization utilities | ||
93 | +#include <ciso646> // empty header. The macros that appear in iso646.h in C are keywords in C++ | ||
94 | +#if __cplusplus >= 201103L | ||
95 | +#include <typeindex> // (since C++11) std::type_index | ||
96 | +#include <type_traits> // (since C++11) Compile-time type information | ||
97 | +#include <chrono> // (since C++11) C++ time utilites | ||
98 | +#include <initializer_list> // (since C++11) std::initializer_list class template | ||
99 | +#include <tuple> // (since C++11) std::tuple class template | ||
100 | +#include <scoped_allocator> // (since C++11) Nested allocator class | ||
101 | +#include <cstdint> // (since C++11) fixed-size types and limits of other types | ||
102 | +#include <cinttypes> // (since C++11) formatting macros , intmax_t and uintmax_t math and conversions | ||
103 | +#include <system_error> // (since C++11) defines std::error_code, a platform-dependent error code | ||
104 | +#include <cuchar> // (since C++11) C-style Unicode character conversion functions | ||
105 | +#include <array> // (since C++11) std::array container | ||
106 | +#include <forward_list> // (since C++11) std::forward_list container | ||
107 | +#include <unordered_set> // (since C++11) std::unordered_set and std::unordered_multiset unordered associative containers | ||
108 | +#include <unordered_map> // (since C++11) std::unordered_map and std::unordered_multimap unordered associative containers | ||
109 | +#include <random> // (since C++11) Random number generators and distributions | ||
110 | +#include <ratio> // (since C++11) Compile-time rational arithmetic | ||
111 | +#include <cfenv> // (since C++11) Floating-point environment access functions | ||
112 | +#include <codecvt> // (since C++11) Unicode conversion facilities | ||
113 | +#include <regex> // (since C++11) Classes, algorithms and iterators to support regular expression processing | ||
114 | +#include <atomic> // (since C++11) Atomic operations library | ||
115 | +#include <ccomplex> // (since C++11)(deprecated in C++17) simply includes the header <complex> | ||
116 | +#include <ctgmath> // (since C++11)(deprecated in C++17) simply includes the headers <ccomplex> (until C++17)<complex> (since C++17) and <cmath>: the overloads equivalent to the contents of the C header tgmath.h are already provided by those headers | ||
117 | +#include <cstdalign> // (since C++11)(deprecated in C++17) defines one compatibility macro constant | ||
118 | +#include <cstdbool> // (since C++11)(deprecated in C++17) defines one compatibility macro constant | ||
119 | +#include <thread> // (since C++11) std::thread class and supporting functions | ||
120 | +#include <mutex> // (since C++11) mutual exclusion primitives | ||
121 | +#include <future> // (since C++11) primitives for asynchronous computations | ||
122 | +#include <condition_variable> // (since C++11) thread waiting conditions | ||
123 | +#endif | ||
124 | +#if __cplusplus >= 201300L | ||
125 | +#include <shared_mutex> // (since C++14) shared mutual exclusion primitives | ||
126 | +#endif | ||
127 | +#if __cplusplus >= 201500L | ||
128 | +#include <any> // (since C++17) std::any class template | ||
129 | +#include <optional> // (since C++17) std::optional class template | ||
130 | +#include <variant> // (since C++17) std::variant class template | ||
131 | +#include <memory_resource> // (since C++17) Polymorphic allocators and memory resources | ||
132 | +#include <string_view> // (since C++17) std::basic_string_view class template | ||
133 | +#include <execution> // (since C++17) Predefined execution policies for parallel versions of the algorithms | ||
134 | +#include <filesystem> // (since C++17) std::path class and supporting functions | ||
135 | +#endif |
nbproject/private/launcher.properties
0 → 100644
1 | +++ a/nbproject/private/launcher.properties | ||
1 | +# Launchers File syntax: | ||
2 | +# | ||
3 | +# [Must-have property line] | ||
4 | +# launcher1.runCommand=<Run Command> | ||
5 | +# [Optional extra properties] | ||
6 | +# launcher1.displayName=<Display Name, runCommand by default> | ||
7 | +# launcher1.hide=<true if lancher is not visible in menu, false by default> | ||
8 | +# launcher1.buildCommand=<Build Command, Build Command specified in project properties by default> | ||
9 | +# launcher1.runDir=<Run Directory, ${PROJECT_DIR} by default> | ||
10 | +# launcher1.runInOwnTab=<false if launcher reuse common "Run" output tab, true by default> | ||
11 | +# launcher1.symbolFiles=<Symbol Files loaded by debugger, ${OUTPUT_PATH} by default> | ||
12 | +# launcher1.env.<Environment variable KEY>=<Environment variable VALUE> | ||
13 | +# (If this value is quoted with ` it is handled as a native command which execution result will become the value) | ||
14 | +# [Common launcher properties] | ||
15 | +# common.runDir=<Run Directory> | ||
16 | +# (This value is overwritten by a launcher specific runDir value if the latter exists) | ||
17 | +# common.env.<Environment variable KEY>=<Environment variable VALUE> | ||
18 | +# (Environment variables from common launcher are merged with launcher specific variables) | ||
19 | +# common.symbolFiles=<Symbol Files loaded by debugger> | ||
20 | +# (This value is overwritten by a launcher specific symbolFiles value if the latter exists) | ||
21 | +# | ||
22 | +# In runDir, symbolFiles and env fields you can use these macroses: | ||
23 | +# ${PROJECT_DIR} - project directory absolute path | ||
24 | +# ${OUTPUT_PATH} - linker output path (relative to project directory path) | ||
25 | +# ${OUTPUT_BASENAME}- linker output filename | ||
26 | +# ${TESTDIR} - test files directory (relative to project directory path) | ||
27 | +# ${OBJECTDIR} - object files directory (relative to project directory path) | ||
28 | +# ${CND_DISTDIR} - distribution directory (relative to project directory path) | ||
29 | +# ${CND_BUILDDIR} - build directory (relative to project directory path) | ||
30 | +# ${CND_PLATFORM} - platform name | ||
31 | +# ${CND_CONF} - configuration name | ||
32 | +# ${CND_DLIB_EXT} - dynamic library extension | ||
33 | +# | ||
34 | +# All the project launchers must be listed in the file! | ||
35 | +# | ||
36 | +# launcher1.runCommand=... | ||
37 | +# launcher2.runCommand=... | ||
38 | +# ... | ||
39 | +# common.runDir=... | ||
40 | +# common.env.KEY=VALUE | ||
41 | + | ||
42 | +# launcher1.runCommand=<type your run command here> | ||
0 | \ No newline at end of file | 43 | \ No newline at end of file |
nbproject/private/private.xml
0 → 100644
1 | +++ a/nbproject/private/private.xml | ||
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<project-private xmlns="http://www.netbeans.org/ns/project-private/1"> | ||
3 | + <data xmlns="http://www.netbeans.org/ns/make-project-private/1"> | ||
4 | + <activeConfTypeElem>1</activeConfTypeElem> | ||
5 | + <activeConfIndexElem>0</activeConfIndexElem> | ||
6 | + </data> | ||
7 | + <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/> | ||
8 | + <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2"> | ||
9 | + <group> | ||
10 | + <file>file:/home/pgroen/projects/serialport/Exception.hpp</file> | ||
11 | + <file>file:/home/pgroen/projects/serialport/SerialPort.cpp</file> | ||
12 | + <file>file:/home/pgroen/projects/serialport/main.cpp</file> | ||
13 | + </group> | ||
14 | + </open-files> | ||
15 | +</project-private> |
nbproject/project.properties
0 → 100644
nbproject/project.xml
0 → 100644
1 | +++ a/nbproject/project.xml | ||
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<project xmlns="http://www.netbeans.org/ns/project/1"> | ||
3 | + <type>org.netbeans.modules.cnd.makeproject</type> | ||
4 | + <configuration> | ||
5 | + <data xmlns="http://www.netbeans.org/ns/make-project/1"> | ||
6 | + <name>SerPortTest</name> | ||
7 | + <c-extensions/> | ||
8 | + <cpp-extensions>cpp</cpp-extensions> | ||
9 | + <header-extensions>hpp</header-extensions> | ||
10 | + <sourceEncoding>UTF-8</sourceEncoding> | ||
11 | + <make-dep-projects/> | ||
12 | + <sourceRootList/> | ||
13 | + <confList> | ||
14 | + <confElem> | ||
15 | + <name>Debug</name> | ||
16 | + <type>1</type> | ||
17 | + </confElem> | ||
18 | + <confElem> | ||
19 | + <name>Release</name> | ||
20 | + <type>1</type> | ||
21 | + </confElem> | ||
22 | + </confList> | ||
23 | + <formatting> | ||
24 | + <project-formatting-style>false</project-formatting-style> | ||
25 | + </formatting> | ||
26 | + </data> | ||
27 | + </configuration> | ||
28 | +</project> |