rogue
Loading...
Searching...
No Matches
src
rogue
protocols
srp
Cmd.cpp
Go to the documentation of this file.
1
17
#include "
rogue/Directives.h
"
18
19
#include "
rogue/protocols/srp/Cmd.h
"
20
21
#include <stdint.h>
22
23
#include <memory>
24
#include <thread>
25
26
#include "
rogue/interfaces/stream/Frame.h
"
27
#include "
rogue/interfaces/stream/FrameIterator.h
"
28
#include "
rogue/interfaces/stream/Master.h
"
29
30
namespace
rps
=
rogue::protocols::srp
;
31
namespace
ris
=
rogue::interfaces::stream
;
32
33
#ifndef NO_PYTHON
34
#include <boost/python.hpp>
35
namespace
bp = boost::python;
36
#endif
37
39
rps::CmdPtr
rps::Cmd::create() {
40
rps::CmdPtr
p = std::make_shared<rps::Cmd>();
41
return
(p);
42
}
43
45
void
rps::Cmd::setup_python() {
46
#ifndef NO_PYTHON
47
48
bp::class_<rps::Cmd, rps::CmdPtr, bp::bases<ris::Master>, boost::noncopyable>(
"Cmd"
, bp::init<>())
49
.def(
"sendCmd"
, &rps::Cmd::sendCmd);
50
#endif
51
}
52
54
rps::Cmd::Cmd() :
ris
::Master() {}
55
57
rps::Cmd::~Cmd() {}
58
60
void
rps::Cmd::sendCmd(uint8_t opCode, uint32_t context) {
61
ris::FrameIterator
it;
62
ris::FramePtr
frame;
63
uint32_t txData[4];
64
65
// Build frame
66
txData[0] = context;
67
txData[1] = opCode;
68
txData[2] = 0;
69
txData[3] = 0;
70
71
// Request frame
72
frame = reqFrame(
sizeof
(txData),
true
);
73
frame->setPayload(
sizeof
(txData));
74
it = frame->begin();
75
76
// Copy frame
77
ris::toFrame
(it,
sizeof
(txData), txData);
78
sendFrame(frame);
79
}
Cmd.h
Directives.h
FrameIterator.h
Frame.h
rogue::interfaces::stream::FrameIterator
Random-access byte iterator across a Frame payload.
Definition
FrameIterator.h:45
rogue::interfaces::stream
Definition
Buffer.h:29
rogue::interfaces::stream::FramePtr
std::shared_ptr< rogue::interfaces::stream::Frame > FramePtr
Shared pointer alias for Frame.
Definition
Frame.h:549
rogue::interfaces::stream::toFrame
static void toFrame(rogue::interfaces::stream::FrameIterator &iter, uint32_t size, void *src)
Copies bytes from a source pointer into a frame iterator.
Definition
FrameIterator.h:337
rogue::protocols::srp
Definition
Cmd.h:30
rogue::protocols::srp::CmdPtr
std::shared_ptr< rogue::protocols::srp::Cmd > CmdPtr
Definition
Cmd.h:87
Master.h
Generated by
1.9.8