PL::ModbusTypedMemoryArea class

template<class Type>
class ModbusTypedMemoryArea : public PL::ModbusMemoryArea

Class template for modbus memory area with typed data member.

Template Parameters:

Type – data type

Public Functions

inline ModbusTypedMemoryArea(ModbusMemoryType type, uint16_t address)

Creates a typed Modbus memory area and allocate memory.

Parameters:
  • type – memory area type

  • address – memory area address

inline ModbusTypedMemoryArea(ModbusMemoryType type, uint16_t address, Type *data)

Creates a typed Modbus memory area from preallocated memory.

Parameters:
  • type – memory area type

  • address – memory area address

  • data – memory area data pointer

inline ModbusTypedMemoryArea(ModbusMemoryType type, uint16_t address, Type *data, std::shared_ptr<Lockable> lockable)

Creates a typed Modbus memory area from preallocated memory with shared lockable.

Parameters:
  • type – memory area type

  • address – memory area address

  • data – memory area data pointer

  • lockable – lockable object that is locked when this memory area is locked

virtual esp_err_t OnRead()

Callback method that is called when memory area is about to be read.

virtual esp_err_t OnWrite()

Callback method that is called when memory area has just been written.

virtual esp_err_t Lock(TickType_t timeout = portMAX_DELAY) override

Locks the object.

Parameters:

timeout – timeout in FreeRTOS ticks

Returns:

error code

virtual esp_err_t Unlock() override

Unlocks the object.

Returns:

error code

void Clear()

Sets all bytes of the buffer data to zero.

Public Members

Type *const data

typed modbus memory area data

const ModbusMemoryType type

Memory area type.

const uint16_t address

Memory area address.

const size_t numberOfItems

Number of memory area items (bits or 16-bit registers)

const size_t size

buffer data size