Skip to content

Commit 0333c40

Browse files
Merge pull request #32 from NikolasK-source/main
update to v1.5.2
2 parents 4eebfdd + 08f3642 commit 0333c40

13 files changed

+2001
-643
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.5.0)
7+
project(Modbus_TCP_client_shm LANGUAGES CXX VERSION 1.5.2)
88

99
# settings
1010
set(Target "modbus-tcp-client-shm") # Executable name (without file extension!)

LICENSE

Lines changed: 674 additions & 21 deletions
Large diffs are not rendered by default.

src/Modbus_TCP_Client_poll.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* 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.
3+
* This program is free software. You can redistribute it and/or modify it under the terms of the GPLv3 License.
44
*/
55

66
#include "Modbus_TCP_Client_poll.hpp"
@@ -198,6 +198,8 @@ void Client_Poll::set_debug(bool debug) {
198198
const std::string error_msg = modbus_strerror(errno);
199199
throw std::runtime_error("failed to enable modbus debugging mode: " + error_msg);
200200
}
201+
202+
this->debug = debug;
201203
}
202204

203205
struct timeout_t {
@@ -222,7 +224,7 @@ void Client_Poll::set_byte_timeout(double timeout) {
222224

223225
if (ret != 0) {
224226
const std::string error_msg = modbus_strerror(errno);
225-
throw std::runtime_error("modbus_receive failed: " + error_msg + ' ' + std::to_string(errno));
227+
throw std::runtime_error("modbus_set_byte_timeout failed: " + error_msg + ' ' + std::to_string(errno));
226228
}
227229
}
228230

@@ -232,7 +234,7 @@ void Client_Poll::set_response_timeout(double timeout) {
232234

233235
if (ret != 0) {
234236
const std::string error_msg = modbus_strerror(errno);
235-
throw std::runtime_error("modbus_receive failed: " + error_msg + ' ' + std::to_string(errno));
237+
throw std::runtime_error("modbus_set_response_timeout failed: " + error_msg + ' ' + std::to_string(errno));
236238
}
237239
}
238240

@@ -380,6 +382,7 @@ Client_Poll::run_t Client_Poll::run(int signal_fd, bool reconnect, int timeout)
380382

381383
uint8_t query[MODBUS_TCP_MAX_ADU_LENGTH];
382384
int rc = modbus_receive(modbus, query);
385+
if (debug) std::cout.flush();
383386

384387
if (rc > 0) {
385388
const auto CLIENT_ID = query[6];
@@ -409,6 +412,7 @@ Client_Poll::run_t Client_Poll::run(int signal_fd, bool reconnect, int timeout)
409412

410413
int ret = modbus_reply(modbus, query, rc, mapping);
411414
if (semaphore && semaphore->is_acquired()) semaphore->post();
415+
if (debug) std::cout.flush();
412416

413417
if (ret == -1) {
414418
std::cerr << Print_Time::iso << " ERROR: modbus_reply failed: " << modbus_strerror(errno)

src/Modbus_TCP_Client_poll.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* 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.
3+
* This program is free software. You can redistribute it and/or modify it under the terms of the GPLv3 License.
44
*/
55
#pragma once
66

@@ -28,6 +28,8 @@ class Client_Poll {
2828
const std::size_t max_clients;
2929
std::vector<struct pollfd> poll_fds;
3030

31+
bool debug = false; //!< modbus debugging enabled
32+
3133
modbus_t *modbus; //!< modbus object (see libmodbus library)
3234
modbus_mapping_t
3335
*mappings[MAX_CLIENT_IDS]; //!< modbus data objects (one per possible client id) (see libmodbus library)

src/Print_Time.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* 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.
3+
* This program is free software. You can redistribute it and/or modify it under the terms of the GPLv3 License.
44
*/
55

66
#include "Print_Time.hpp"

src/Print_Time.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* 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.
3+
* This program is free software. You can redistribute it and/or modify it under the terms of the GPLv3 License.
44
*/
55

66
#pragma once

src/license.cpp

Lines changed: 1299 additions & 606 deletions
Large diffs are not rendered by default.

src/license.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* 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.
3+
* This program is free software. You can redistribute it and/or modify it under the terms of the GPLv3 License.
44
*/
55

66
#pragma once
@@ -11,4 +11,4 @@
1111
* \brief print licences
1212
* @param o output stream used to print licenses
1313
*/
14-
void print_licenses(std::ostream &o);
14+
void print_licenses(std::ostream &o, bool full);

src/main.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* 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.
3+
* This program is free software. You can redistribute it and/or modify it under the terms of the GPLv3 License.
44
*/
55

66
#include <atomic>
@@ -176,7 +176,8 @@ int main(int argc, char **argv) {
176176
cxxopts::value<std::string>()->default_value("0640"));
177177
options.add_options()("h,help", "print usage");
178178
options.add_options()("version", "print version information");
179-
options.add_options()("license", "show licences");
179+
options.add_options()("license", "show licences (short)");
180+
options.add_options()("license-full", "show licences (full license text)");
180181

181182
// parse arguments
182183
cxxopts::ParseResult args;
@@ -221,7 +222,12 @@ int main(int argc, char **argv) {
221222

222223
// print licenses
223224
if (args.count("license")) {
224-
print_licenses(std::cout);
225+
print_licenses(std::cout, false);
226+
return EX_OK;
227+
}
228+
229+
if (args.count("license-full")) {
230+
print_licenses(std::cout, true);
225231
return EX_OK;
226232
}
227233

src/modbus_shm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* 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.
3+
* This program is free software. You can redistribute it and/or modify it under the terms of the GPLv3 License.
44
*/
55

66
#include "modbus_shm.hpp"

0 commit comments

Comments
 (0)