DUDS
Distributed Update of Data from Something
GpioDevPort.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of the DUDS project. It is subject to the BSD-style
3  * license terms in the LICENSE file found in the top-level directory of this
4  * distribution and at https://github.com/jjackowski/duds/blob/master/LICENSE.
5  * No part of DUDS, including this file, may be copied, modified, propagated,
6  * or distributed except according to the terms contained in the LICENSE file.
7  *
8  * Copyright (C) 2018 Jeff Jackowski
9  */
11 //#include <fstream>
12 
13 // !@?!#?!#?
14 // It was bad enough to find an MS header had "#define interface struct".
15 // I was hoping such things wouldn't be here, but I was wrong.
16 #undef linux
17 
18 namespace duds { namespace hardware { namespace interface {
19 
20 class PinConfiguration;
21 
22 namespace linux {
23 
33 
38 
43 
48 
96  std::string name;
101  std::string consumer;
105  std::string devpath;
109  int chipFd;
117  void initPin(std::uint32_t offset, unsigned int pid);
118 protected:
119  virtual void madeAccess(DigitalPinAccess &acc);
120  virtual void madeAccess(DigitalPinSetAccess &acc);
121  virtual void retiredAccess(const DigitalPinAccess &acc) noexcept;
122  virtual void retiredAccess(const DigitalPinSetAccess &acc) noexcept;
123 public:
140  GpioDevPort(
141  const std::string &path = "/dev/gpiochip0",
142  unsigned int firstid = 0,
143  const std::string &username = "DUDS"
144  );
166  GpioDevPort(
167  const std::vector<unsigned int> &ids,
168  const std::string &path = "/dev/gpiochip0",
169  unsigned int firstid = 0,
170  const std::string &username = "DUDS"
171  );
190  static std::shared_ptr<GpioDevPort> makeConfiguredPort(
191  PinConfiguration &pc,
192  const std::string &name = "default",
193  const std::string &defaultPath = "/dev/gpiochip0",
194  bool forceDefault = false
195  );
196  virtual ~GpioDevPort();
197 protected:
198  // virtual functions required by Digitalport
199  virtual void configurePort(
200  unsigned int localPinId,
201  const DigitalPinConfig &cfg,
203  );
204  virtual bool inputImpl(
205  unsigned int gid,
207  );
208  virtual std::vector<bool> inputImpl(
209  const std::vector<unsigned int> &pvec,
211  );
212  virtual void outputImpl(
213  unsigned int lid,
214  bool state,
216  );
217  virtual void outputImpl(
218  const std::vector<unsigned int> &pvec,
219  const std::vector<bool> &state,
221  );
222 public:
226  virtual bool simultaneousOperations() const;
227 };
228 
229 } } } } // namespaces
230 
Provides access to multiple pins on a DigitalPort.
Defines the configuration for a digital general purpose I/O pin.
std::string devpath
The path of the device file; retained only for error reporting purposes.
std::string consumer
The consumer name given to the kernel when requesting the use of GPIO lines.
A type for holding arbitrary port-specific data within a DigitalPinAccess or DigitalPinSetAccess obje...
A GPIO implementation using the Linux kernel&#39;s GPIO character devices.
Definition: GpioDevPort.hpp:92
Parses configuration data for DigitalPort, DigitalPin, DigitalPinSet, ChipSelectManager, and ChipSelect objects.
Provides access to a single pin on a DigitalPort.
int chipFd
File descriptor for GPIO chip device file.
std::string name
The reported name of the GPIO chip device.
Definition: GpioDevPort.hpp:96
An error was reported from a GPIOHANDLE_SET_LINE_VALUES_IOCTL operation.
Definition: GpioDevPort.hpp:47
An error was reported from a GPIOHANDLE_GET_LINE_VALUES_IOCTL operation.
Definition: GpioDevPort.hpp:42
A partial DigitalPort implementation for ports where the configuration of each pin is independent of ...
Base exception type for all errors about pins.
Definition: PinErrors.hpp:26
Base class for all errors specific to using the Linux GPIO character device.
Definition: GpioDevPort.hpp:32
An error was reported from a GPIO_GET_LINEHANDLE_IOCTL operation.
Definition: GpioDevPort.hpp:37