DUDS
Distributed Update of Data from Something
MasterSyncSerialAccess.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) 2017 Jeff Jackowski
9  */
11 #include <initializer_list>
12 
13 namespace duds { namespace hardware { namespace interface {
14 
28 class MasterSyncSerialAccess : boost::noncopyable {
32  friend std::unique_ptr<MasterSyncSerialAccess> MasterSyncSerial::access();
41  std::shared_ptr<MasterSyncSerial> mss;
45  MasterSyncSerialAccess(std::shared_ptr<MasterSyncSerial> m) : mss(m) { }
46 public:
47  typedef std::initializer_list<std::uint8_t> ByteList;
48  //typedef std::vector<std::uint8_t> ByteVector;
57  retire();
58  }
62  void retire() {
63  if (mss) {
64  mss->retire(this);
65  }
66  }
71  void start() {
72  mss->condStart();
73  }
78  void stop() {
79  mss->condStop();
80  }
101  void transfer(
102  const std::uint8_t * __restrict__ out,
103  std::uint8_t * __restrict__ in,
105  ) {
106  mss->transfer(out, in, bits);
107  }
129  void transfer(
130  const std::int8_t * __restrict__ out,
131  std::int8_t * __restrict__ in,
133  ) {
134  transfer((std::uint8_t*)out, (std::uint8_t*)in, bits);
135  }
156  void transfer(
157  const ByteList &out,
158  std::uint8_t * __restrict__ in,
160  ) {
161  mss->transfer(out.begin(), in, bits);
162  }
178  void transmit(const std::uint8_t *buff, duds::general::Bits bits) {
179  mss->transmit(buff, bits);
180  }
196  void transmit(const std::int8_t *buff, duds::general::Bits bits) {
197  transmit((std::uint8_t*)buff, bits);
198  }
212  void transmit(const ByteList &buff) {
213  mss->transmit(buff.begin(), duds::general::Bytes(buff.size()));
214  }
231  void receive(std::uint8_t *buff, duds::general::Bits bits) {
232  mss->receive(buff, bits);
233  }
251  void receive(std::int8_t *buff, duds::general::Bits bits) {
252  receive((std::uint8_t*)buff, bits);
253  }
267  mss->converseAlreadyOpen(conv);
268  }
269 };
270 
271 } } }
void transfer(const ByteList &out, std::uint8_t *__restrict__ in, duds::general::Bits bits)
Sends and/or receives bits of data.
void receive(std::int8_t *buff, duds::general::Bits bits)
Receives bits of data using signed bytes for convenience.
void receive(std::uint8_t *buff, duds::general::Bits bits)
Receives bits of data.
void transmit(const std::int8_t *buff, duds::general::Bits bits)
Sends bits of data using signed bytes for convenience.
std::unique_ptr< MasterSyncSerialAccess > access()
Obtain access for communication; transitions the object from the ready (MssReady) to the open (MssOpe...
void converse(Conversation &conv)
Has a half-duplex Conversation with the connected device.
void transmit(const std::uint8_t *buff, duds::general::Bits bits)
Sends bits of data.
void transfer(const std::int8_t *__restrict__ out, std::int8_t *__restrict__ in, duds::general::Bits bits)
Sends and/or receives bits of data using signed bytes for convenience.
void stop()
Ends the conversation; transitions from the communicating state to the open state.
static std::wstring_convert< std::codecvt_utf8< char32_t >, char32_t > conv
String converter; UTF-8 to/from UTF-32.
Definition: BppFont.cpp:165
void transmit(const ByteList &buff)
Sends bytes stored in a temporary value.
void start()
Starts a conversation; transitions from the open state to the communicating state.
Provides access for communicating using a MasterSyncSerial object.
std::shared_ptr< MasterSyncSerial > mss
The serial interface used by this access object.
~MasterSyncSerialAccess()
Ends the conversation and closes communication.
A class to assist with specifiying the sizes of data with scaling units, much like std::chrono::durat...
Definition: DataSize.hpp:106
void retire(MasterSyncSerialAccess *acc)
Removes the access object from use.
MasterSyncSerialAccess(std::shared_ptr< MasterSyncSerial > m)
Constructs an access object; called by MasterSyncSerial::access().
void transfer(const std::uint8_t *__restrict__ out, std::uint8_t *__restrict__ in, duds::general::Bits bits)
Sends and/or receives bits of data.
DataSize< 8 > Bytes
DataSize type for a size in bytes.
Definition: DataSize.hpp:384
Represents a two-way conversation with a device.
void retire()
Ends the conversation and closes communication.