diff --git a/src/examples/chiller_example.py b/src/examples/chiller_example.py index 9c0a3a3aa4d68babc44b63e6828524d9084ef161..af21bf262dacb5996eaa8b45ab8bcb06f5c4610b 100644 --- a/src/examples/chiller_example.py +++ b/src/examples/chiller_example.py @@ -1,3 +1,4 @@ +import labRemote from labRemote import chiller, com import time @@ -51,6 +52,12 @@ if __name__ == "__main__" : parser.add_argument("-t", "--temperature", default = 15, type = float, help = "Set the target temperature of the chiller (degrees Celsius)" ) + parser.add_argument("-d", "--debug", action = "count", default = 0, + help = "Enable more verbose printout" + ) args = parser.parse_args() + for _ in range(args.debug) + labRemote.incrDebug() + chiller_example(args.port, args.baud, args.temperature) diff --git a/src/examples/control_powersupply_example.py b/src/examples/control_powersupply_example.py index 53c4ebad80deca9b45bca2d656087879bca012f5..55e12a6d192742aecda5fcab12f11240be871eeb 100644 --- a/src/examples/control_powersupply_example.py +++ b/src/examples/control_powersupply_example.py @@ -1,3 +1,4 @@ +import labRemote from labRemote import ps, ec from argparse import ArgumentParser @@ -71,8 +72,14 @@ if __name__ == "__main__": parser.add_argument("channel-name", type = str, help = "Powersupply channel to control" ) + parser.add_argument("-d", "--debug", action = "count", default = 0, + help = "Enable more verbose printout" + ) args = parser.parse_args() + for _ in range(args.debug) : + labRemote.incrDebug() + config = Path(args.config_file) if not config.exists() or not config.is_file() : logger.error(f"Provided configuration file \"{args.config_file}\" could not be found") diff --git a/src/examples/datasink_example.py b/src/examples/datasink_example.py index 3b285c5ca85c125b58faef97372693cc594bdd58..193491ee978fc79af211032723a553a773878943 100644 --- a/src/examples/datasink_example.py +++ b/src/examples/datasink_example.py @@ -1,3 +1,4 @@ +import labRemote from labRemote import ec from datetime import datetime @@ -52,8 +53,14 @@ if __name__ == "__main__": parser.add_argument("stream-name", type = str, help = "Name of the datastream to use" ) + parser.add_argument("-d", "--debug", action = "count", default = 0, + help = "Enable more verbose printout" + ) args = parser.parse_args() + for _ in range(args.debug) : + labRemote.incrDebug() + config_path = Path(args.config_file) if not config_path.exists() or not config_path.is_file() : logger.error(f"Provided configuration file \"{args.config_file}\" could not be found") diff --git a/src/examples/devcomuino_example.py b/src/examples/devcomuino_example.py index bf1812a123661a996a28d77788ef1789ce6c83d6..cf31fa78189c05cad9f8c72a9e7a7ff1d96d409c 100644 --- a/src/examples/devcomuino_example.py +++ b/src/examples/devcomuino_example.py @@ -1,3 +1,4 @@ +import labRemote from labRemote import com from argparse import ArgumentParser @@ -87,6 +88,12 @@ if __name__ == "__main__" : parser.add_argument("-b", "--baud", default = 9600, type = int, help = "Baud rate for USB communication with the connected Arduino device" ) + parser.add_argument("-d", "--debug", action = "count", default = 0, + help = "Enable more verbose printout messages from labRemote" + ) args = parser.parse_args() + for _ in range(args.debug) : + args.incrDebug() + devcomuino_example(args.port, args.baud) diff --git a/src/examples/ntc_example.py b/src/examples/ntc_example.py index 9195349bfe70f63361c1ed5cefa6e0a6bb411088..246f8899c8c4e5a6ffe2b4732fb7598f390d4917 100644 --- a/src/examples/ntc_example.py +++ b/src/examples/ntc_example.py @@ -1,3 +1,4 @@ +import labRemote from labRemote import devcom, com import time @@ -71,5 +72,13 @@ if __name__ == "__main__": parser.add_argument("pin", type = str, help = "Pin on the sensor to sample from" ) + parser.add_argument("-d", "--debug", action = "count", default = 0, + help = "Enable more verbose printout from labRemote" + ) + args = parser.parse_args() + + for _ in range(args.debug) : + labRemote.incrDebug() + ntc_example(args.device_port, args.pin) diff --git a/src/examples/temp_hum_monitor_example.py b/src/examples/temp_hum_monitor_example.py index 339adefa86b06a0d70c41c300239983f9a0851c7..73ee24f6e5789f30e33848688bdb1f282e791b6f 100644 --- a/src/examples/temp_hum_monitor_example.py +++ b/src/examples/temp_hum_monitor_example.py @@ -1,3 +1,4 @@ +import labRemote from labRemote import devcom from argparse import ArgumentParser @@ -13,7 +14,13 @@ def temp_hum_monitor_example() : if __name__ == "__main__" : parser = ArgumentParser(description = "Example of performing continous monitoring of several climate sensors, using data streams") - parser.parse_args() + parser.add_argument("-d", "--debug", action = "count", default = 0, + help = "Enable more verbose printout of labRemote messages" + ) + + args = parser.parse_args() + for _ in range(args.debug) : + labRemote.incrDebug() ## ## first check that the FTDI support has been enabled in the current labRemote build diff --git a/src/labRemote/__init__.py b/src/labRemote/__init__.py index 19ffed33442d437226e32bbe2cec569cbb454c28..44de9e7363bce7cf057176269fdefa7333bb8b35 100644 --- a/src/labRemote/__init__.py +++ b/src/labRemote/__init__.py @@ -1,2 +1,3 @@ from ._labRemote import com, ec, ps, datasink, devcom, chiller -__all__ = ['com', 'ec', 'ps', 'datasink', 'devcom', 'chiller'] +from ._labRemote import incrDebug +__all__ = ['com', 'ec', 'ps', 'datasink', 'devcom', 'chiller', 'incrDebug'] diff --git a/src/labRemote/module.cpp b/src/labRemote/module.cpp index 63bd0f4c70cf763e23e6b8745a1f5ca91713c727..e9e26ac5fbdd17887593ec589611b6e0413f52fc 100644 --- a/src/labRemote/module.cpp +++ b/src/labRemote/module.cpp @@ -1,3 +1,5 @@ +#include "Logger.h" + #include <pybind11/pybind11.h> namespace py = pybind11; @@ -27,4 +29,6 @@ PYBIND11_MODULE(_labRemote, m) { py::module chiller = m.def_submodule("chiller"); register_chiller(chiller); + + m.def("incrDebug", &logIt::incrDebug); } diff --git a/src/tools/powersupply.py b/src/tools/powersupply.py index 5f08eb2f4475170ddc36419d59b404e33c1a4c64..613887209a34ec50aa0f48a418b74584e8cac8cf 100644 --- a/src/tools/powersupply.py +++ b/src/tools/powersupply.py @@ -181,6 +181,7 @@ if __name__ == "__main__": if args.debug: logger.setLevel(logging.DEBUG) + labRemote.incrDebug() logging.debug("Debug mode is on")