|
Dawn Framework 1.0
Universal data acquisition framework for embedded systems
|
Modbus TCP protocol implementation. More...
#include <tcp.hxx>
Public Member Functions | |
| int | configure () |
| Configure object from descriptor data. | |
| int | deinit () |
| De-initialize object. | |
| int | doStart () |
| Start implementation hook. | |
| int | doStop () |
| Stop implementation hook. | |
| bool | getCfgFlag () const |
| Check if configuration flag is set. | |
| uint16_t | getCls () const |
| Get object class field. | |
| CDescObject & | getDesc () |
| Get descriptor object for this object. | |
| uint8_t | getDtype () const |
| Get data type field. | |
| size_t | getDtypeSize () const |
| Get size of this object's data type. | |
| uint8_t | getFlags () const |
| Get type-specific flags field. | |
| SObjectId::UObjectId | getId () const |
| Get object identifier as union structure. | |
| SObjectId::ObjectId | getIdV () const |
| Get object identifier as raw 32-bit value. | |
| CIOCommon * | getIO (SObjectId::ObjectId id) |
| Get an I/O object by ID. | |
| const std::map< SObjectId::ObjectId, CIOCommon * > & | getIOMap () const |
| Get the I/O map for this object. | |
| int | getObjConfig (SObjectCfg::ObjectCfgId objcfg, uint32_t *data, size_t len) |
| Get object configuration item. | |
| CObject * | getObject (SObjectId::ObjectId id) |
| Get an object by ID. | |
| uint16_t | getPriv () const |
| Get instance/private data field. | |
| virtual EObjectState | getState () const |
| Get current operational state. | |
| uint8_t | getType () const |
| Get object type field. | |
| bool | hasThread () const |
| Check if a background thread is active. | |
| int | init () |
| One-time initialize object after bindings are resolved. | |
| int | setObjConfig (SObjectCfg::ObjectCfgId objcfg, uint32_t *data, size_t len) |
| Set object configuration item. | |
| void | setObjectMapItem (SObjectId::ObjectId id, CObject *obj) |
| Set an item in the object map. | |
| int | start () |
| Start object. | |
| int | stop () |
| Stop object. | |
| virtual int | trigger (uint8_t cmd) |
| Execute a trigger command. | |
Static Public Member Functions | |
| static int | descValidDefault (const uint32_t *data, size_t len) |
| Default descriptor validation method. | |
| static int | validateDesc (const uint32_t *desc, size_t len) |
| Validate entire descriptor. | |
Protected Member Functions | |
| const SThreadConfig & | getThreadConfig () const |
| Get current thread configuration. | |
| int | getThreadPriority () const |
| Get configured worker thread priority. | |
| int | getThreadScheduler () const |
| Get configured worker thread scheduler policy. | |
| size_t | getThreadStackSize () const |
| Get configured worker thread stack size. | |
| bool | isRunning () const |
| Check if the worker thread is running. | |
| virtual int | onSetObjConfig (SObjectCfg::ObjectCfgId objcfg, uint32_t *data, size_t len) |
| Pre-update hook for runtime configuration writes. | |
| void | setThreadConfig (const SThreadConfig &config) |
| Replace the full thread configuration. | |
| template<typename Func > | |
| void | setThreadFunc (Func &&func) |
| Assign the function executed by threadStart(). | |
| void | setThreadPriority (int priority) |
| Configure worker thread priority. | |
| void | setThreadScheduler (int scheduler) |
| Configure worker thread scheduler policy. | |
| void | setThreadStackSize (size_t stackSize) |
| Configure worker thread stack size. | |
| template<typename Func > | |
| int | startWorkerThread (Func &&func) |
| Start the worker thread with a given function. | |
| int | stopWorkerThread () |
| Stop the worker thread. | |
| int | threadStart () |
| Start the worker thread. | |
| int | threadStop () |
| Stop the worker thread. | |
| CThreadedObject & | workerThread () |
| Get a reference to this thread controller. | |
| const CThreadedObject & | workerThread () const |
| Get a const reference to this thread controller. | |
| bool | workerThreadRunning () const |
| Check if the worker thread is running. | |
Static Protected Attributes | |
| static int | THREAD_PRIORITY_DEFAULT = 0 |
| Default thread priority behavior. | |
| static int | THREAD_SCHEDULER_DEFAULT = -1 |
| Default scheduler behavior. | |
Modbus TCP protocol implementation.
CProtoModbusTcp implements the Modbus TCP protocol over network, providing industrial-standard register mapping for I/O objects.
|
inherited |
Control command identifiers for control()
| Enumerator | |
|---|---|
| CMD_RESET | Reset object internal state. |
| CMD_TRIGGER1 | Object-specific trigger slot 1. |
| CMD_TRIGGER2 | Object-specific trigger slot 2. |
| CMD_TRIGGER3 | Object-specific trigger slot 3. |
Definition at line 40 of file object.hxx.
|
inherited |
Default descriptor validation failure codes.
Negative values identify which length check failed in descValidDefault().
Definition at line 314 of file object.hxx.
|
inherited |
|
inherited |
Object operational state returned by getState()
| Enumerator | |
|---|---|
| STATE_STOPPED | Object is stopped. |
| STATE_RUNNING | Object is running. |
Definition at line 32 of file object.hxx.
|
inherited |
Protocol object class types.
Definition at line 27 of file common.hxx.
|
virtual |
Configure object from descriptor data.
Called during framework setup before dependency binding. Implementations should parse/validate descriptor configuration and store object settings, but avoid one-time allocations that depend on bound objects.
Reimplemented from dawn::CObject.
Definition at line 164 of file tcp.cxx.
References dawn::CObject::getDesc().
|
virtual |
De-initialize object.
Clean up resources allocated during init().
Reimplemented from dawn::CObject.
|
staticinherited |
Default descriptor validation method.
Provides basic validation that only checks if descriptor lengths are correct.
| data | Descriptor data pointer. |
| len | Length of descriptor data in 32-bit words. |
Definition at line 42 of file object.cxx.
References dawn::SObjectCfg::UObjectCfgId::s, dawn::SObjectCfg::UObjectCfgId::size, and dawn::SObjectCfg::UObjectCfgId::v.
|
virtual |
Start implementation hook.
Override in derived classes instead of start().
Reimplemented from dawn::CObject.
Definition at line 218 of file tcp.cxx.
References dawn::CThreadedObject::startWorkerThread().
|
virtual |
Stop implementation hook.
Override in derived classes instead of stop().
Reimplemented from dawn::CObject.
Definition at line 232 of file tcp.cxx.
References dawn::CThreadedObject::stopWorkerThread().
|
inherited |
Check if configuration flag is set.
Definition at line 160 of file object.cxx.
References dawn::CDescObject::getSize().
|
inherited |
Get object class field.
Definition at line 170 of file object.cxx.
References dawn::SObjectId::UObjectId::cls, and dawn::SObjectId::UObjectId::s.
|
inherited |
Get descriptor object for this object.
Definition at line 190 of file object.cxx.
|
inherited |
Get data type field.
Definition at line 175 of file object.cxx.
References dawn::SObjectId::UObjectId::dtype, and dawn::SObjectId::UObjectId::s.
|
inherited |
Get size of this object's data type.
Definition at line 195 of file object.cxx.
References dawn::SObjectId::getDtypeSize_(), and dawn::CDescObject::getObjectDtype().
|
inherited |
Get type-specific flags field.
Definition at line 180 of file object.cxx.
References dawn::SObjectId::UObjectId::flags, and dawn::SObjectId::UObjectId::s.
|
inherited |
Get object identifier as union structure.
Definition at line 150 of file object.cxx.
|
inherited |
Get object identifier as raw 32-bit value.
Definition at line 155 of file object.cxx.
References dawn::SObjectId::UObjectId::v.
|
inherited |
Get an I/O object by ID.
| id | Object ID to retrieve. |
Definition at line 41 of file bindable.cxx.
|
inherited |
Get the I/O map for this object.
Definition at line 18 of file bindable.cxx.
|
inherited |
Get object configuration item.
Retrieves configuration data for this object.
| objcfg | Configuration ID specifying which config item to retrieve. |
| data | Pointer to buffer for configuration data. |
| len | Length of buffer in 32-bit words. |
Definition at line 240 of file object.cxx.
References dawn::SObjectCfg::SObjectCfgItem::data, dawn::SObjectCfg::objectCfgGetSize(), and dawn::CDescObject::objectCfgItemId().
|
inherited |
Get an object by ID.
| id | Object ID to retrieve. |
Definition at line 52 of file bindable.cxx.
References dawn::CBindableObject::getIO(), dawn::SObjectId::objectIdGetType(), and dawn::SObjectId::OBJTYPE_IO.
|
inherited |
Get instance/private data field.
Definition at line 185 of file object.cxx.
References dawn::SObjectId::UObjectId::priv, and dawn::SObjectId::UObjectId::s.
|
inlinevirtualinherited |
Get current operational state.
Default returns STATE_RUNNING after successful start(), STATE_STOPPED otherwise. Objects with richer states (e.g. paused) should override.
Definition at line 183 of file object.hxx.
References dawn::CObject::STATE_RUNNING, and dawn::CObject::STATE_STOPPED.
|
inherited |
Get object type field.
Definition at line 165 of file object.cxx.
References dawn::SObjectId::UObjectId::s, and dawn::SObjectId::UObjectId::type.
|
virtual |
Check if a background thread is active.
Used by Dawn's main loop to detect when clean exit is possible. Objects without a background thread must return false. Independent of operational state tracked via getState().
Reimplemented from dawn::CObject.
Definition at line 239 of file tcp.cxx.
References dawn::CThreadedObject::workerThreadRunning().
|
virtual |
One-time initialize object after bindings are resolved.
Called once during framework setup after dependency binding. Allocate lifetime resources here (buffers, register maps, etc.).
Reimplemented from dawn::CObject.
|
inherited |
Check if the worker thread is running.
Definition at line 256 of file thread.cxx.
|
inlineprotectedvirtualinherited |
Pre-update hook for runtime configuration writes.
Called by setObjConfig() before descriptor-backed storage is updated. Derived classes may validate incoming data and prepare/apply runtime side effects. Returning a negative error rejects the update.
| objcfg | Configuration ID that will be updated. |
| data | Pointer to new config words. |
| len | Number of config words. |
Reimplemented in dawn::CIOAdcStream, dawn::CIOAdcSync, and dawn::CIOPwm.
Definition at line 386 of file object.hxx.
|
inherited |
Set object configuration item.
Updates a configuration item for this object.
| objcfg | Configuration ID specifying which config item to update. |
| data | Pointer to configuration data. |
| len | Length of configuration data in 32-bit words. |
Definition at line 200 of file object.cxx.
References dawn::SObjectCfg::SObjectCfgItem::data, dawn::SObjectCfg::objectCfgGetRw(), dawn::SObjectCfg::objectCfgGetSize(), dawn::CDescObject::objectCfgItemId(), and dawn::CObject::onSetObjConfig().
|
inherited |
Set an item in the object map.
| id | Object ID to set. |
| obj | Object pointer to associate with the ID. |
Definition at line 23 of file bindable.cxx.
References dawn::SObjectId::objectIdGetType(), and dawn::SObjectId::OBJTYPE_IO.
|
inlineinherited |
Assign the function executed by threadStart().
| func | Callable object to execute in the worker thread. |
Definition at line 100 of file thread.hxx.
|
inlineinherited |
Configure worker thread priority.
| priority | Requested priority (0 = creator default). |
Definition at line 149 of file thread.hxx.
References dawn::CThreadedObject::SThreadConfig::priority.
|
inlineinherited |
Configure worker thread scheduler policy.
| scheduler | POSIX scheduler policy (-1 = creator default). |
Definition at line 169 of file thread.hxx.
References dawn::CThreadedObject::SThreadConfig::scheduler.
|
inlineinherited |
Configure worker thread stack size.
| stackSize | Requested stack size in bytes (0 = OS default). |
Definition at line 129 of file thread.hxx.
References dawn::CThreadedObject::SThreadConfig::stackSize.
|
inlineinherited |
Start object.
Tracks operational state and calls doStart(). This phase may run many times during an object's lifetime and should not perform one-time allocation. Sets started on successful doStart() return.
Definition at line 116 of file object.hxx.
References dawn::CObject::doStart().
|
inlineprotectedinherited |
Start the worker thread with a given function.
| func | Callable object to execute in thread. |
Definition at line 246 of file thread.hxx.
References dawn::CThreadedObject::setThreadFunc(), and dawn::CThreadedObject::threadStart().
|
inlineinherited |
Stop object.
Tracks operational state and calls doStop(). This phase may run many times during an object's lifetime and should not perform one-time deallocation. Always clears started regardless of doStop() return value.
Definition at line 145 of file object.hxx.
References dawn::CObject::doStop().
|
inlineprotectedinherited |
Stop the worker thread.
Definition at line 258 of file thread.hxx.
References dawn::CThreadedObject::threadStop().
|
inherited |
Start the worker thread.
Definition at line 166 of file thread.cxx.
|
inherited |
Stop the worker thread.
Definition at line 240 of file thread.cxx.
|
inlinevirtualinherited |
Execute a trigger command.
| cmd | Command identifier (EObjectCmd value). |
Reimplemented in dawn::CIOAdcFetch, dawn::CIOAdcStream, dawn::CIOAdcSync, dawn::CIOEncoder, dawn::CIOEncoderIndex, dawn::CIOPwm, dawn::CProgBuffer, dawn::CProgCounter, dawn::CProgProcess, dawn::CProgSequencer, dawn::CProgThresholdBase, and dawn::CProgToggle.
Definition at line 195 of file object.hxx.
|
staticinherited |
Validate entire descriptor.
Validates a descriptor binary object-by-object using default checks.
| desc | Descriptor binary pointer. |
| len | Descriptor length in 32-bit words. |
Definition at line 123 of file object.cxx.
References dawn::CObject::descValidDefault().
|
inlineprotectedinherited |
Get a reference to this thread controller.
Definition at line 280 of file thread.hxx.
|
inlineprotectedinherited |
Get a const reference to this thread controller.
Definition at line 291 of file thread.hxx.
|
inlineprotectedinherited |
Check if the worker thread is running.
Definition at line 269 of file thread.hxx.
References dawn::CThreadedObject::isRunning().
|
staticinherited |
Default thread priority behavior.
Value 0 keeps the creator thread's default priority.
Definition at line 40 of file thread.hxx.
|
staticinherited |
Default scheduler behavior.
Value -1 keeps the creator thread's current scheduling policy.
Definition at line 48 of file thread.hxx.