devices not supported on Windows
Stefan Schuermans

Stefan Schuermans commited on 2017-10-28 20:43:54
Showing 2 changed files, with 120 additions and 0 deletions.

... ...
@@ -0,0 +1,59 @@
1
+/* Blinker
2
+   Copyright 2011-2014 Stefan Schuermans <stefan@blinkenarea.org>
3
+   Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html
4
+   a blinkenarea.org project */
5
+
6
+#include <iostream>
7
+#include <string>
8
+
9
+#include "Device.h"
10
+#include "Io.h"
11
+#include "SerCfg.h"
12
+
13
+namespace Blinker {
14
+
15
+/**
16
+ * @brief constructor
17
+ * @param[in] path path to device
18
+ */
19
+Device::Device(const std::string &path)
20
+{
21
+  std::cerr << "output to devices (\"" << path
22
+            << "\") is not supported on Windows (yet)" << std::endl;
23
+}
24
+
25
+/// destructor
26
+Device::~Device()
27
+{
28
+}
29
+
30
+/**
31
+ * @brief set serial port configuration
32
+ * @param[in] serCfg serial port configuration
33
+ * @return if configuration succeeded
34
+ *
35
+ * This function should only be used if device is a serial port.
36
+ */
37
+bool Device::setSerCfg(const SerCfg& serCfg)
38
+{
39
+  (void)serCfg;
40
+  return false; // devices not supported on Windows
41
+}
42
+
43
+/**
44
+ * @brief write data to device
45
+ * @param[in] data data to write
46
+ * @param[out] len number of byte written to device
47
+ * @return if some (or zero) data could be written,
48
+ *         i.e. if the device is still operational
49
+ */
50
+bool Device::write(const std::string &data, std::string::size_type &len)
51
+{
52
+  (void)data;
53
+  len = 0;
54
+  return false; // devices not supported on Windows
55
+}
56
+
57
+} // namespace Blinker
58
+
59
+
... ...
@@ -0,0 +1,61 @@
1
+/* Blinker
2
+   Copyright 2011-2014 Stefan Schuermans <stefan@blinkenarea.org>
3
+   Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html
4
+   a blinkenarea.org project */
5
+
6
+#ifndef BLINKER_DEVICE_H
7
+#define BLINKER_DEVICE_H
8
+
9
+#include <string>
10
+
11
+#include "Io.h"
12
+#include "SerCfg.h"
13
+
14
+namespace Blinker {
15
+
16
+/// a character device
17
+class Device: public Io
18
+{
19
+public:
20
+  /**
21
+   * @brief constructor
22
+   * @param[in] path path to device
23
+   */
24
+  Device(const std::string &path);
25
+
26
+  /// destructor
27
+  ~Device();
28
+
29
+private:
30
+  /// copy constructor disabled
31
+  Device(const Device &that);
32
+
33
+  /// assignment operator disabled
34
+  const Device & operator=(const Device &that);
35
+
36
+public:
37
+  /**
38
+   * @brief set serial port configuration
39
+   * @param[in] serCfg serial port configuration
40
+   * @return if configuration succeeded
41
+   *
42
+   * This function should only be used if device is a serial port.
43
+   */
44
+  bool setSerCfg(const SerCfg& serCfg);
45
+
46
+  /**
47
+   * @brief write data to device
48
+   * @param[in] data data to write
49
+   * @param[out] len number of byte written to device
50
+   * @return if some (or zero) data could be written,
51
+   *         i.e. if the device is still operational
52
+   */
53
+  bool write(const std::string &data, std::string::size_type &len);
54
+
55
+}; // class Device
56
+
57
+} // namespace Blinker
58
+
59
+#endif // #ifndef BLINKER_DEVICE_H
60
+
61
+
0 62