moddef-cpp
Idiomatic C++ runtime for ModDef
Loading...
Searching...
No Matches
command.hpp File Reference

Command executor (spec §11.7): multi-step register procedures. More...

#include <cstdint>
#include <span>
#include <string_view>
#include "moddef/device.hpp"
#include "moddef/error.hpp"
#include "moddef/str.hpp"
#include "moddef/value.hpp"
#include "moddef/command.h"

Go to the source code of this file.

Classes

class  moddef::CommandParams< N >
 Fixed-capacity param set for CommandExecutor::begin. More...
 
class  moddef::CommandExecutor
 One armed command run. More...
 

Namespaces

namespace  moddef
 

Enumerations

enum class  moddef::CommandStatus : std::uint8_t { moddef::Running = MD_CMD_RUNNING , moddef::WaitingPoll = MD_CMD_WAITING_POLL , moddef::Done = MD_CMD_DONE , moddef::Error = MD_CMD_ERROR }
 

Detailed Description

Command executor (spec §11.7): multi-step register procedures.

RAII over the C core's tick-driven md_cmd_exec_t — the caller drives tick(now_ms) from its own scheduler with any monotonic millisecond clock; the library never sleeps (same embedded targets as the C core).

auto ex = moddef::CommandExecutor::begin(dev, "start_transaction",
                                         params.c_params(), sink);
while (ex->tick(now_ms()) < moddef::CommandStatus::Done)
    ;  // yield; WaitingPoll means "call again later"

Param values and the data sink reference caller storage and must outlive the run. String/bytes results are untrimmed register-window bytes.