Skip to content

Commit b8ba536

Browse files
Merge pull request #1 from NikolasK-source/development
Development
2 parents 947a0e2 + 7200007 commit b8ba536

File tree

10 files changed

+619
-30
lines changed

10 files changed

+619
-30
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.13.4 FATAL_ERROR)
44
# ======================================================================================================================
55

66
# project
7-
project(Modbus_TCP_client_shm LANGUAGES CXX VERSION 1.0.2)
7+
project(Modbus_TCP_client_shm LANGUAGES CXX VERSION 1.0.3)
88

99
# settings
1010
set(Target "Modbus_TCP_client_shm") # Executable name (without file extension!)

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 Nikolas Koesling
3+
Copyright (c) 2021-2022 Nikolas Koesling
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
target_sources(${Target} PRIVATE main.cpp)
55
target_sources(${Target} PRIVATE modbus_shm.cpp)
66
target_sources(${Target} PRIVATE Modbus_TCP_Slave.cpp)
7+
target_sources(${Target} PRIVATE license.cpp)
78

89

910
# ---------------------------------------- header files (*.jpp, *.h, ...) ----------------------------------------------
1011
# ======================================================================================================================
1112
target_sources(${Target} PRIVATE modbus_shm.hpp)
1213
target_sources(${Target} PRIVATE Modbus_TCP_Slave.hpp)
14+
target_sources(${Target} PRIVATE license.hpp)
1315

1416

1517

src/Modbus_TCP_Slave.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright (C) 2021-2022 Nikolas Koesling <nikolas@koesling.info>.
3+
* This program is free software. You can redistribute it and/or modify it under the terms of the MIT License.
4+
*/
5+
16
#include "Modbus_TCP_Slave.hpp"
27

38
#include <stdexcept>

src/Modbus_TCP_Slave.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright (C) 2021-2022 Nikolas Koesling <nikolas@koesling.info>.
3+
* This program is free software. You can redistribute it and/or modify it under the terms of the MIT License.
4+
*/
5+
16
#pragma once
27

38
#include <modbus/modbus.h>
@@ -9,7 +14,7 @@ namespace TCP {
914
//! Modbus TCP slave
1015
class Slave {
1116
private:
12-
modbus_t * modbus; //!< modbus object (see libmodbus library)
17+
modbus_t *modbus; //!< modbus object (see libmodbus library)
1318
modbus_mapping_t *mapping; //!< modbus data object (see libmodbus library)
1419
bool delete_mapping; //!< indicates whether the mapping object was created by this instance
1520
int socket = -1; //!< socket of the modbus connection
@@ -23,7 +28,7 @@ class Slave {
2328
*/
2429
explicit Slave(const std::string &ip = "0.0.0.0",
2530
short unsigned int port = 502,
26-
modbus_mapping_t * mapping = nullptr);
31+
modbus_mapping_t *mapping = nullptr);
2732

2833
/*! \brief destroy the modbus slave
2934
*

src/license.cpp

Lines changed: 563 additions & 0 deletions
Large diffs are not rendered by default.

src/license.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (C) 2022 Nikolas Koesling <nikolas@koesling.info>.
3+
* This program is free software. You can redistribute it and/or modify it under the terms of the MIT License.
4+
*/
5+
6+
#pragma once
7+
8+
#include <ostream>
9+
10+
/**
11+
* \brief print licences
12+
* @param o output stream used to print licenses
13+
*/
14+
void print_licenses(std::ostream &o);

src/main.cpp

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright (C) 2021-2022 Nikolas Koesling <nikolas@koesling.info>.
3+
* This program is free software. You can redistribute it and/or modify it under the terms of the MIT License.
4+
*/
5+
16
#include <csignal>
27
#include <cxxopts.hpp>
38
#include <filesystem>
@@ -7,6 +12,7 @@
712
#include <unistd.h>
813

914
#include "Modbus_TCP_Slave.hpp"
15+
#include "license.hpp"
1016
#include "modbus_shm.hpp"
1117

1218
//! terminate flag
@@ -83,7 +89,9 @@ int main(int argc, char **argv) {
8389
("h,help",
8490
"print usage")
8591
("version",
86-
"print version information");
92+
"print version information")
93+
("license",
94+
"show licences");
8795
// clang-format on
8896

8997
// parse arguments
@@ -111,29 +119,6 @@ int main(int argc, char **argv) {
111119
std::cout << "This application uses the following libraries:" << std::endl;
112120
std::cout << " - cxxopts by jarro2783 (https://github.com/jarro2783/cxxopts)" << std::endl;
113121
std::cout << " - libmodbus by Stéphane Raimbault (https://github.com/stephane/libmodbus)" << std::endl;
114-
std::cout << std::endl;
115-
std::cout << std::endl;
116-
std::cout << "MIT License:" << std::endl;
117-
std::cout << std::endl;
118-
std::cout << "Copyright (c) 2021 Nikolas Koesling" << std::endl;
119-
std::cout << std::endl;
120-
std::cout << "Permission is hereby granted, free of charge, to any person obtaining a copy" << std::endl;
121-
std::cout << "of this software and associated documentation files (the \"Software\"), to deal" << std::endl;
122-
std::cout << "in the Software without restriction, including without limitation the rights" << std::endl;
123-
std::cout << "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell" << std::endl;
124-
std::cout << "copies of the Software, and to permit persons to whom the Software is" << std::endl;
125-
std::cout << "furnished to do so, subject to the following conditions:" << std::endl;
126-
std::cout << std::endl;
127-
std::cout << "The above copyright notice and this permission notice shall be included in all" << std::endl;
128-
std::cout << "copies or substantial portions of the Software." << std::endl;
129-
std::cout << std::endl;
130-
std::cout << "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR" << std::endl;
131-
std::cout << "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY," << std::endl;
132-
std::cout << "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE" << std::endl;
133-
std::cout << "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER" << std::endl;
134-
std::cout << "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM," << std::endl;
135-
std::cout << "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE" << std::endl;
136-
std::cout << "SOFTWARE." << std::endl;
137122
exit(EX_OK);
138123
}
139124

@@ -143,6 +128,12 @@ int main(int argc, char **argv) {
143128
exit(EX_OK);
144129
}
145130

131+
// print licenses
132+
if (args.count("license")) {
133+
print_licenses(std::cout);
134+
exit(EX_OK);
135+
}
136+
146137
// check arguments
147138
if (args["do-registers"].as<std::size_t>() > 0x10000) {
148139
std::cerr << "to many do_registers (maximum: 65536)." << std::endl;

src/modbus_shm.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
/*
2+
* Copyright (C) 2021-2022 Nikolas Koesling <nikolas@koesling.info>.
3+
* This program is free software. You can redistribute it and/or modify it under the terms of the MIT License.
4+
*/
5+
16
#include "modbus_shm.hpp"
27

38
#include <fcntl.h>
4-
#include <iostream>
59
#include <stdexcept>
610
#include <sys/mman.h>
711
#include <system_error>

src/modbus_shm.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright (C) 2021-2022 Nikolas Koesling <nikolas@koesling.info>.
3+
* This program is free software. You can redistribute it and/or modify it under the terms of the MIT License.
4+
*/
5+
16
#pragma once
27

38
#include "modbus/modbus.h"
@@ -21,7 +26,7 @@ class Shm_Mapping {
2126
std::string name = std::string(); //!< name of the object
2227
int fd = -1; //!< file descriptor
2328
std::size_t size; //!< size in bytes
24-
void * addr = nullptr; //!< mapped address
29+
void *addr = nullptr; //!< mapped address
2530
};
2631

2732
//! modbus lib storage object

0 commit comments

Comments
 (0)