ArPiRobot-CoreLib C++
C++ library for ArPiRobot robots
ArduinoUartInterface.hpp
1 /*
2  * Copyright 2021 Marcus Behel
3  *
4  * This file is part of ArPiRobot-CoreLib.
5  *
6  * ArPiRobot-CoreLib is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * ArPiRobot-CoreLib is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with ArPiRobot-CoreLib. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
20 #pragma once
21 
22 #include <thread>
23 #include <vector>
24 #include <string>
25 
26 #include <arpirobot/arduino/iface/BaseArduinoInterface.hpp>
27 #include <arpirobot/core/io/IoDevice.hpp>
28 
29 namespace arpirobot{
30 
37  public:
38 
43  ArduinoUartInterface(std::string port, int baud);
44 
46 
47  ArduinoUartInterface(const ArduinoUartInterface &other) = delete;
48 
49  ArduinoUartInterface &operator=(const ArduinoUartInterface &other) = delete;
50 
51  protected:
52  void open() override;
53  void close() override;
54  bool isOpen() override;
55  int available() override;
56  uint8_t readOne() override;
57  std::vector<uint8_t> readAll() override;
58  void write(const uint8_t &b) override;
59  std::string getDeviceName() override;
60 
61  private:
62  std::string port;
63  char *portCStr;
64  int baud;
65  int handle = -1;
66  };
67 }
Definition: ArduinoUartInterface.hpp:36
ArduinoUartInterface(std::string port, int baud)
Definition: BaseArduinoInterface.hpp:41
Definition: IoDevice.hpp:27
Definition: ArduinoDevice.hpp:27