refactor: make modbus controller cross-platform and improve locking

- Added cross-platform file locking using msvcrt (Windows) and fcntl (Unix).
- Switched to pathlib for robust path management and automatic directory creation.
- Updated is_host_reachable to support Windows ping syntax.
- Added atexit handler to ensure lock file descriptors are closed properly.

NOTE: Verified on Linux (LMDE 7). Windows compatibility implemented but not yet tested.
This commit is contained in:
2026-04-10 15:27:23 +03:00
parent c3825ff105
commit d6e9ac13d1
3 changed files with 52 additions and 24 deletions
+2 -2
View File
@@ -7,5 +7,5 @@ timeout = 1 # Timeout value in seconds
max_channel = 7 # Maximum number of channels of the Modbus device model (7 - 0-7, as 8 channels summary)
[paths]
lock_file = /tmp/modbus_controller.lock
log_file = /tmp/modbus_controller.log
lock_file = modbus_controller.lock
log_file = modbus_logs/modbus_controller.log