#pragma once
#include <myapp/modbus/rawdata.h>
#include <modbus/modbus.h>

namespace myapp::modbus {

class raw_tcp_data
	: public raw_data
{
public:
	uint8_t* data() override;
	int data_length() const override;
	void data_length(int) override;

	int size() const override { return size_; }
	void size(int value) override { size_ = value; }
	int max_size() const noexcept override { return MODBUS_TCP_MAX_ADU_LENGTH; }

	uint8_t& operator[](std::size_t pos) override { return adu_[pos]; }
	const uint8_t& operator[](std::size_t pos) const override { return adu_[pos]; };

private:
	uint8_t adu_[MODBUS_TCP_MAX_ADU_LENGTH];
	int size_{ 0 };
};
	
} /* namespace myapp::modbus */
