Skip to content

Commit d0f2959

Browse files
version 1.0.0
1 parent a06ecb6 commit d0f2959

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

CMakeLists.txt

Lines changed: 5 additions & 3 deletions
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 0.0.1)
7+
project(Modbus_TCP_client_shm LANGUAGES CXX VERSION 1.0.0)
88

99
# settings
1010
set(Target "Modbus_TCP_client_shm") # Executable name (without file extension!)
@@ -24,8 +24,6 @@ option(OPTIMIZE_FOR_ARCHITECTURE "enable optimizations for specified architectur
2424
option(LTO_ENABLED "enable interprocedural and link time optimizations" ON)
2525
option(COMPILER_EXTENSIONS "enable compiler specific C++ extensions" OFF)
2626

27-
28-
2927
# ======================================================================================================================
3028
# ======================================================================================================================
3129

@@ -55,6 +53,10 @@ set_target_properties(${Target} PROPERTIES
5553
CXX_EXTENSIONS ${COMPILER_EXTENSIONS}
5654
)
5755

56+
# project version and name
57+
target_compile_definitions(${Target} PUBLIC "PROJECT_VERSION=\"${CMAKE_PROJECT_VERSION}\"")
58+
target_compile_definitions(${Target} PUBLIC "PROJECT_NAME=\"${CMAKE_PROJECT_NAME}\"")
59+
5860
# options that are valid for gcc and clang
5961
function(commonopts)
6062
# more debugging information

src/main.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ int main(int argc, char **argv) {
8181
("r,reconnect",
8282
"do not terminate if Master disconnects.")
8383
("h,help",
84-
"print usage");
84+
"print usage")
85+
("version",
86+
"print version information");
8587
// clang-format on
8688

8789
// parse arguments
@@ -135,6 +137,12 @@ int main(int argc, char **argv) {
135137
exit(EX_OK);
136138
}
137139

140+
// print usage
141+
if (args.count("version")) {
142+
std::cout << PROJECT_NAME << ' ' << PROJECT_VERSION << std::endl;
143+
exit(EX_OK);
144+
}
145+
138146
// check arguments
139147
if (args["do-registers"].as<std::size_t>() > 0x10000) {
140148
std::cerr << "to many do_registers (maximum: 65536)." << std::endl;

src/modbus_shm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Shm_Mapping::Shm_Mapping(std::size_t nb_bits,
4343
shm_data[AI].name = prefix + "AI";
4444

4545
// create and map shm objects
46-
for (std::size_t i = 0; i < reg_index_t::__SIZE__; ++i) {
46+
for (std::size_t i = 0; i < reg_index_t::REG_COUNT; ++i) {
4747
auto &shm = shm_data[i];
4848

4949
// create shm object
@@ -76,7 +76,7 @@ Shm_Mapping::Shm_Mapping(std::size_t nb_bits,
7676

7777
Shm_Mapping::~Shm_Mapping() {
7878
// unmap and delete shm objects
79-
for (std::size_t i = 0; i < reg_index_t::__SIZE__; ++i) {
79+
for (std::size_t i = 0; i < reg_index_t::REG_COUNT; ++i) {
8080
auto &shm = shm_data[i];
8181
if (shm.addr) {
8282
if (munmap(shm.addr, shm.size)) { perror(("Failed to unmap shared memory '" + shm.name + '\'').c_str()); }

src/modbus_shm.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace shm {
1414
*/
1515
class Shm_Mapping {
1616
private:
17-
enum reg_index_t : std::size_t { DO, DI, AO, AI, __SIZE__ };
17+
enum reg_index_t : std::size_t { DO, DI, AO, AI, REG_COUNT };
1818

1919
//! data for a shared memory object
2020
struct shm_data_t {
@@ -28,7 +28,7 @@ class Shm_Mapping {
2828
modbus_mapping_t mapping {};
2929

3030
//! info for all shared memory objects
31-
std::array<shm_data_t, reg_index_t::__SIZE__> shm_data;
31+
std::array<shm_data_t, reg_index_t::REG_COUNT> shm_data;
3232

3333
public:
3434
/*! \brief creates a new modbus_mapping_t. Like modbus_mapping_new(), but creates shared memory objects to store its

0 commit comments

Comments
 (0)