6#include "dawn/io/encoder.hxx"
14int CIOEncoder::configureDesc(
const CDescObject &desc)
19 for (
size_t i = 0; i < desc.
getSize(); i++)
35 case IO_ENCODER_CFG_POSMAX:
39 DAWNERR(
"invalid encoder posmax cfg size %d\n", item->
cfgid.
s.
size);
43 const uint32_t *tmp =
reinterpret_cast<const uint32_t *
>(&item->
data);
52 DAWNERR(
"unsupported encoder cfg 0x%08" PRIx32
"\n", item->
cfgid.
v);
61 DAWNERR(
"unsupported encoder cfg 0x%08" PRIx32
"\n", item->
cfgid.
v);
70CIOEncoder::~CIOEncoder()
82 DAWNERR(
"encoder configure failed (error %d)\n", ret);
88 DAWNERR(
"encoder device number not configured\n");
92 snprintf(path,
sizeof(path), ENCODER_PATH_FMT,
getCmnDevno());
94 fd = encoder_open(path);
97 DAWNERR(
"failed to open encoder %d\n", -errno);
103 ret = encoder_set_posmax(fd, posmax);
106 DAWNERR(
"encoder set posmax failed %d\n", ret);
120 DAWNERR(
"encoder requires DTYPE_INT32\n");
136 int32_t *tmp =
static_cast<int32_t *
>(data.
getDataPtr());
144 ret = encoder_read_position(fd, tmp);
147 DAWNERR(
"encoder_read_position failed %d\n", ret);
151#ifdef CONFIG_DAWN_IO_TIMESTAMP
165 return encoder_reset(fd);
Descriptor wrapper for individual object configuration.
size_t getSize() const
Get number of configuration items for this object.
SObjectCfg::SObjectCfgItem * objectCfgItemAtOffset(size_t offset) const
Get configuration item at specified offset.
uint64_t getTimestamp()
Get current timestamp.
bool isTimestamp() const
Check if I/O supports timestamp.
int getCmnDevno() const
Get device number for this I/O.
size_t cfgCmnOffset(const SObjectCfg::SObjectCfgItem *cfg)
Get offset of configuration item in descriptor.
@ IO_CLASS_ANY
Any I/O class.
@ IO_CLASS_ENCODER
Quadrature encoder (position)
int getDataImpl(IODataCmn &data, size_t len)
Get data implementation (override in derived classes).
int configure()
Configure object from descriptor data.
int trigger(uint8_t cmd)
Execute a trigger command.
int init()
One-time initialize object after bindings are resolved.
int deinit()
De-initialize object.
CDescObject & getDesc()
Get descriptor object for this object.
uint8_t getDtype() const
Get data type field.
@ CMD_RESET
Reset object internal state.
Out-of-tree user-extension hooks for Dawn.
Base interface for I/O data buffers (static and dynamic).
virtual void * getDataPtr(size_t batch=0)=0
Get pointer to data only (skips timestamp if present).
virtual uint64_t & getTs(size_t batch=0)=0
Get timestamp reference for batch.
Single configuration item within object.
ObjectCfgData_t data[]
Configuration data array (flexible, size from cfgid.s.size).
UObjectCfgId cfgid
Configuration ID header (type, class, id, size, rw, dtype).
@ DTYPE_INT32
Signed 32-bit integer (-2147483648 to 2147483647).
ObjectCfgId v
Raw 32-bit ConfigID value (for storage, comparison).
uint32_t cls
Object class (bits 21-29, max 511).
uint32_t id
Configuration identifier (bits 0-4, max 31).
uint32_t size
Configuration data size in 32-bit words (bits 5-14, max 1023).
struct dawn::SObjectCfg::UObjectCfgId::@10 s
Bit-field structure for named member access.