rogue
Loading...
Searching...
No Matches
Cmd.cpp
Go to the documentation of this file.
1
17#include "rogue/Directives.h"
18
20
21#include <stdint.h>
22
23#include <memory>
24#include <thread>
25
29
30namespace rps = rogue::protocols::srp;
32
33#ifndef NO_PYTHON
34 #include <boost/python.hpp>
35namespace bp = boost::python;
36#endif
37
39rps::CmdPtr rps::Cmd::create() {
40 rps::CmdPtr p = std::make_shared<rps::Cmd>();
41 return (p);
42}
43
45void 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
54rps::Cmd::Cmd() : ris::Master() {}
55
57rps::Cmd::~Cmd() {}
58
60void rps::Cmd::sendCmd(uint8_t opCode, uint32_t context) {
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}
Random-access byte iterator across a Frame payload.
std::shared_ptr< rogue::interfaces::stream::Frame > FramePtr
Shared pointer alias for Frame.
Definition Frame.h:549
static void toFrame(rogue::interfaces::stream::FrameIterator &iter, uint32_t size, void *src)
Copies bytes from a source pointer into a frame iterator.
std::shared_ptr< rogue::protocols::srp::Cmd > CmdPtr
Definition Cmd.h:87