Commit f0c30279385b0544d35d34ad2a90152f3cf6e316

Authored by Peter M. Groen
1 parent ab279ee8

Add TCP connection

src/CMakeLists.txt
... ... @@ -14,6 +14,10 @@ set(SRC_LIST
14 14 ${CMAKE_CURRENT_SOURCE_DIR}/imodbusport.h
15 15 ${CMAKE_CURRENT_SOURCE_DIR}/modbus.h
16 16 ${CMAKE_CURRENT_SOURCE_DIR}/modbus.cpp
  17 + ${CMAKE_CURRENT_SOURCE_DIR}/modbustcp.h
  18 + ${CMAKE_CURRENT_SOURCE_DIR}/modbustcp.cpp
  19 + ${CMAKE_CURRENT_SOURCE_DIR}/modbusrtu.h
  20 + ${CMAKE_CURRENT_SOURCE_DIR}/modbusrtu.cpp
17 21 ${CMAKE_CURRENT_SOURCE_DIR}/connectionconfig.h
18 22 ${CMAKE_CURRENT_SOURCE_DIR}/connectionconfig.cpp
19 23 )
... ...
src/modbusrtu.cpp
  1 +/*
  2 + * Copyright (c) 2022 Peter M. Groen
  3 + *
  4 + * This source code is licensed under the MIT license found in the
  5 + * LICENSE file in the root directory of this source tree.
  6 + */
... ...
src/modbusrtu.h
  1 +/*
  2 + * Copyright (c) 2022 Peter M. Groen
  3 + *
  4 + * This source code is licensed under the MIT license found in the
  5 + * LICENSE file in the root directory of this source tree.
  6 + */
  7 +
... ...
src/modbustcp.cpp
  1 +/*
  2 + * Copyright (c) 2022 Peter M. Groen
  3 + *
  4 + * This source code is licensed under the MIT license found in the
  5 + * LICENSE file in the root directory of this source tree.
  6 + */
  7 +#include "modbustcp.h"
  8 +
  9 +using namespace osdev::components::modbus;
  10 +
  11 +ModbusTcp::ModbusTcp(const ConnectionConfig &con_config)
  12 +{
  13 +
  14 +}
  15 +
  16 +bool ModbusTcp::Open() const
  17 +{
  18 +
  19 +}
  20 +
  21 +bool ModbusTcp::Close() const
  22 +{
  23 +
  24 +}
  25 +
  26 +int ModbusTcp::Read(uint8_t *buffer) const
  27 +{
  28 +
  29 +}
  30 +
  31 +int ModbusTcp::Write(uint8_t *buffer, size_t length) const
  32 +{
  33 +
  34 +}
... ...
src/modbustcp.h
  1 +/*
  2 + * Copyright (c) 2022 Peter M. Groen
  3 + *
  4 + * This source code is licensed under the MIT license found in the
  5 + * LICENSE file in the root directory of this source tree.
  6 + */
  7 +#pragma once
  8 +
  9 +#include "imodbusport.h"
  10 +
  11 +namespace osdev {
  12 +namespace components {
  13 +namespace modbus {
  14 +
  15 +class ModbusTcp : public IModbusPort
  16 +{
  17 +public:
  18 + explicit ModbusTcp(const ConnectionConfig &con_config);
  19 + virtual ~ModbusTcp() {}
  20 +
  21 + // The standard device interface.
  22 + // Implementation of IModbusPort
  23 + virtual bool Open() const override;
  24 + virtual bool Close() const override;
  25 + virtual int Read(uint8_t *buffer) const override;
  26 + virtual int Write(uint8_t *buffer, size_t length) const override;
  27 +};
  28 +
  29 +} /* End namespace modbus */
  30 +} /* End namespace components */
  31 +} /* End namespace osdev */
... ...