diff --git a/.gitignore b/.gitignore index a049b91..5a2acee 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,8 @@ Debug/ # IDEA -.idea/ \ No newline at end of file +.idea/ + +# Scripts + +**/env/ \ No newline at end of file diff --git a/Core/External/Proto/Helper/proto_helper.cpp b/Core/External/Proto/Helper/proto_helper.cpp index 188743e..e3e9e83 100644 --- a/Core/External/Proto/Helper/proto_helper.cpp +++ b/Core/External/Proto/Helper/proto_helper.cpp @@ -51,4 +51,29 @@ bool ProtoHelper::is_info_bus_request_content_of_gain_info_type( bool ProtoHelper::is_info_bus_request_content_of_integral_time_info_type( const light_detector::InfoBusRequestContent& content) { return content.infoType() == light_detector::InfoType::IntegralTime; +} + +bool ProtoHelper::is_settings_bus_request_content_of_enable_settings_type( + const light_detector::SettingsBusRequestContent &content) { + return content.settingsType() == light_detector::SettingsType::Enable; +} + +bool ProtoHelper::is_settings_bus_request_content_of_disable_settings_type( + const light_detector::SettingsBusRequestContent &content) { + return content.settingsType() == light_detector::SettingsType::Disable; +} + +bool ProtoHelper::is_settings_bus_request_content_of_reset_settings_type( + const light_detector::SettingsBusRequestContent &content) { + return content.settingsType() == light_detector::SettingsType::Reset; +} + +bool ProtoHelper::is_settings_bus_request_content_of_set_gain_settings_type( + const light_detector::SettingsBusRequestContent &content) { + return content.settingsType() == light_detector::SettingsType::SetGain; +} + +bool ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type( + const light_detector::SettingsBusRequestContent &content) { + return content.settingsType() == light_detector::SettingsType::SetIntegralTime; }; diff --git a/Core/External/Proto/Helper/proto_helper.h b/Core/External/Proto/Helper/proto_helper.h index 01d97cb..f54f74a 100644 --- a/Core/External/Proto/Helper/proto_helper.h +++ b/Core/External/Proto/Helper/proto_helper.h @@ -110,6 +110,58 @@ class ProtoHelper { */ static bool is_info_bus_request_content_of_integral_time_info_type( const light_detector::InfoBusRequestContent& content); + + + + + + + + + /** + * Checks if the given settings bus request content of enable settings type. + * + * @param content - given settings bus request content. + * @return result of the check. + */ + static bool is_settings_bus_request_content_of_enable_settings_type( + const light_detector::SettingsBusRequestContent& content); + + /** + * Checks if the given settings bus request content of disable settings type. + * + * @param content - given settings bus request content. + * @return result of the check. + */ + static bool is_settings_bus_request_content_of_disable_settings_type( + const light_detector::SettingsBusRequestContent& content); + + /** + * Checks if the given settings bus request content of reset settings type. + * + * @param content - given settings bus request content. + * @return result of the check. + */ + static bool is_settings_bus_request_content_of_reset_settings_type( + const light_detector::SettingsBusRequestContent& content); + + /** + * Checks if the given settings bus request content of set gain settings type. + * + * @param content - given settings bus request content. + * @return result of the check. + */ + static bool is_settings_bus_request_content_of_set_gain_settings_type( + const light_detector::SettingsBusRequestContent& content); + + /** + * Checks if the given settings bus request content of set integral time settings type. + * + * @param content - given settings bus request content. + * @return result of the check. + */ + static bool is_settings_bus_request_content_of_set_integral_time_settings_type( + const light_detector::SettingsBusRequestContent& content); }; #endif //LIGHT_DETECTOR_PROTO_HELPER_H diff --git a/Core/External/Scheduler/Handler/scheduler_handler.cpp b/Core/External/Scheduler/Handler/scheduler_handler.cpp index 9aeb1e4..3ac1c23 100644 --- a/Core/External/Scheduler/Handler/scheduler_handler.cpp +++ b/Core/External/Scheduler/Handler/scheduler_handler.cpp @@ -227,5 +227,72 @@ int SchedulerHandler::process_info_bus_request_content_of_integral_time_info_typ int SchedulerHandler::process_settings_bus_request_content_response( const light_detector::RequestContainer &content) { + auto settings_bus_request_content = + ProtoHelper::extract_settings_bus_request_content(content); -} \ No newline at end of file + if (ProtoHelper::is_settings_bus_request_content_of_enable_settings_type( + settings_bus_request_content)) { + + + } else if (ProtoHelper::is_settings_bus_request_content_of_disable_settings_type( + settings_bus_request_content)) { + + + } else if (ProtoHelper::is_settings_bus_request_content_of_reset_settings_type( + settings_bus_request_content)) { + + + } else if (ProtoHelper::is_settings_bus_request_content_of_set_gain_settings_type( + settings_bus_request_content)) { + + + } else if (ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type( + settings_bus_request_content)) { + + + } + + return EXIT_SUCCESS; +} + +int SchedulerHandler::process_settings_bus_request_content_of_enable_settings_type_response( + const light_detector::RequestContainer &content) { + light_detector::ResponseContainer response_container; + + response_container.set_msgId(content.get_msgId()); + + light_detector::SettingsBusResponseContent settings_bus_response_content; + + settings_bus_response_content.set_deviceId(TSL2591X::get_device_id()); + settings_bus_response_content.set_settingsType(light_detector::SettingsType::Enable); + + TSL2591X::enable(); + uint8_t value = TSL2591X::get_integral_time(); + + settings_bus_response_content.set_result(true); + settings_bus_response_content.set_nonce(State::allocate_response_nonce()); + + response_container.set_settingsBus(settings_bus_response_content); + + return ProtoCodec::encode_response_container(response_container); +} + +int SchedulerHandler::process_settings_bus_request_content_of_disable_settings_type_response( + const light_detector::RequestContainer &content) { + return 0; +} + +int SchedulerHandler::process_settings_bus_request_content_of_reset_settings_type_response( + const light_detector::RequestContainer &content) { + return 0; +} + +int SchedulerHandler::process_settings_bus_request_content_of_set_gain_settings_type_response( + const light_detector::RequestContainer &content) { + return 0; +} + +int SchedulerHandler::process_settings_bus_request_content_of_set_integral_time_settings_type_response( + const light_detector::RequestContainer &content) { + return 0; +} diff --git a/Core/External/Scheduler/Handler/scheduler_handler.h b/Core/External/Scheduler/Handler/scheduler_handler.h index 0557632..b35618c 100644 --- a/Core/External/Scheduler/Handler/scheduler_handler.h +++ b/Core/External/Scheduler/Handler/scheduler_handler.h @@ -133,6 +133,51 @@ class SchedulerHandler { * @return status of the settings bus request content response processing. */ static int process_settings_bus_request_content_response(const light_detector::RequestContainer& content); + + /** + * Attempts to process settings bus request content of enable settings type response. + * + * @param content - given settings bus request content. + * @return status of the settings bus request content response processing. + */ + static int process_settings_bus_request_content_of_enable_settings_type_response( + const light_detector::RequestContainer& content); + + /** + * Attempts to process settings bus request content of disable settings type response. + * + * @param content - given settings bus request content. + * @return status of the settings bus request content response processing. + */ + static int process_settings_bus_request_content_of_disable_settings_type_response( + const light_detector::RequestContainer& content); + + /** + * Attempts to process settings bus request content of reset settings type response. + * + * @param content - given settings bus request content. + * @return status of the settings bus request content response processing. + */ + static int process_settings_bus_request_content_of_reset_settings_type_response( + const light_detector::RequestContainer& content); + + /** + * Attempts to process settings bus request content of set gain settings type response. + * + * @param content - given settings bus request content. + * @return status of the settings bus request content response processing. + */ + static int process_settings_bus_request_content_of_set_gain_settings_type_response( + const light_detector::RequestContainer& content); + + /** + * Attempts to process settings bus request content of set integral time settings type response. + * + * @param content - given settings bus request content. + * @return status of the settings bus request content response processing. + */ + static int process_settings_bus_request_content_of_set_integral_time_settings_type_response( + const light_detector::RequestContainer& content); }; #endif //LIGHT_DETECTOR_SCHEDULER_HANDLER_H diff --git a/Makefile b/Makefile index 83f35d1..522b603 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ else endif .PHONY: generate -generate: ## Generate prerequisites +generate: ## Generate ProtocolBuffers files(used mainly for development) @protoc -I./Resources/Proto/Container --python_out=./Scripts/graph/proto Content/data.proto Content/info.proto Content/settings.proto request.proto response.proto @protoc --plugin=/Volumes/Files/embedded/university/techno/project/deps/EmbeddedProto -I./Resources/Proto/Container --eams_out=./Core/External/Proto/Generated Content/data.proto Content/info.proto Content/settings.proto request.proto response.proto diff --git a/README.md b/README.md index 4008c81..ea6d6be 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ A driver-like application, which allows to communicate with TSL2591X light senso Includes following features: * Retrieve latest sensor data(**raw**, **full**, **infrared**, **visible**) * Retrieve meta information from the internal board state -* Modify settings for the light sensor. +* Modify settings for the light sensor. ## Setup @@ -27,4 +27,12 @@ Built **ELF** file is intended to be used for manual upload via **STM Programmer If **ProtocolBuffers** files need to be regenerated it's required to execute the following command: ```shell make generate -``` \ No newline at end of file +``` + +## Scripts + +### CLI + +Detailed documentation can be found [here](./Scripts/cli/README.md) + +# Use cases \ No newline at end of file diff --git a/Resources/Proto/Container/Content/info.proto b/Resources/Proto/Container/Content/info.proto index 466591f..e6e19a5 100644 --- a/Resources/Proto/Container/Content/info.proto +++ b/Resources/Proto/Container/Content/info.proto @@ -8,6 +8,7 @@ package light_detector; enum InfoType { Gain = 0; IntegralTime = 1; + ProcessedRequests = 2; } // Represents info bus request content send from the client to the board. diff --git a/Scripts/graph/__init__.py b/Scripts/__init__.py similarity index 100% rename from Scripts/graph/__init__.py rename to Scripts/__init__.py diff --git a/Scripts/cli/Makefile b/Scripts/cli/Makefile new file mode 100644 index 0000000..8a88950 --- /dev/null +++ b/Scripts/cli/Makefile @@ -0,0 +1,37 @@ +.ONESHELL: + +.PHONY: help +.DEFAULT_GOAL := help +help: + @grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +.PHONY: clean +clean: ## Cleans generated core files +ifneq (,$(wildcard ./Debug)) + @rm -r ./Debug + + @echo "Debug directory has been successfully deleted" +else + @echo "Debug directory does not exist" +endif + +ifneq (,$(wildcard ./Core/Src/main.c)) + @find ./Core/Src -name "*.cpp" | xargs -I {} rm {} + @cd ./Core/Src && \ + for file in *; do \ + mv "$$file" "`echo $$file | sed 's/\.c$$/.cpp/'`"; \ + done + + @echo "*.c files rename operation was performed successfully" +else + @echo "*.c files intented to be renamed don't exist" +endif + +prepare: ## Install prerequisites + pip3 install -r requirements.txt + +install: prepare ## Build and install the application + python3 setup.py install --user + +.PHONY: all +all: install \ No newline at end of file diff --git a/Scripts/cli/README.md b/Scripts/cli/README.md new file mode 100644 index 0000000..0330ccc --- /dev/null +++ b/Scripts/cli/README.md @@ -0,0 +1,39 @@ +# CLI + +[![Build](https://github.com/YarikRevich/ResourceTracker/actions/workflows/build.yml/badge.svg)](https://github.com/YarikRevich/ResourceTracker/actions/workflows/build.yml) +![Linux](https://img.shields.io/badge/Linux-FCC624?style=for-the-badge&logo=linux&logoColor=black) +![MacOS](https://img.shields.io/badge/MacOS-8773f5?style=for-the-badge&logo=macos&logoColor=black) +[![StandWithUkraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md) + +## General Information + +Allows to perform communication with serial connected devices. + +Includes following features: +* Retrieve latest sensor data(**raw**, **full**, **infrared**, **visible**) +* Retrieve meta information from the internal board state +* Modify settings for the light sensor. + +## Setup + +All setup related operations are processed via **Makefile** placed in the root directory. + +In order to build IOC project it's required to execute the following command. It uses **CubeMX CLI** to generate **ELF** upload file: +```shell +make build +``` + +Built **ELF** file is intended to be used for manual upload via **STM Programmer**. + +If **ProtocolBuffers** files need to be regenerated it's required to execute the following command: +```shell +make generate +``` + +## Scripts + +### CLI + +Detailed documentation can be found [here](./Scripts/cli/README.md) + +# Use cases \ No newline at end of file diff --git a/Scripts/cli/__init__.py b/Scripts/cli/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Scripts/graph/proto/Content/data_pb2.py b/Scripts/cli/proto/Content/data_pb2.py similarity index 100% rename from Scripts/graph/proto/Content/data_pb2.py rename to Scripts/cli/proto/Content/data_pb2.py diff --git a/Scripts/graph/proto/Content/info_pb2.py b/Scripts/cli/proto/Content/info_pb2.py similarity index 100% rename from Scripts/graph/proto/Content/info_pb2.py rename to Scripts/cli/proto/Content/info_pb2.py diff --git a/Scripts/graph/proto/Content/settings_pb2.py b/Scripts/cli/proto/Content/settings_pb2.py similarity index 100% rename from Scripts/graph/proto/Content/settings_pb2.py rename to Scripts/cli/proto/Content/settings_pb2.py diff --git a/Scripts/graph/proto/data_pb2.py b/Scripts/cli/proto/data_pb2.py similarity index 100% rename from Scripts/graph/proto/data_pb2.py rename to Scripts/cli/proto/data_pb2.py diff --git a/Scripts/graph/proto/info_pb2.py b/Scripts/cli/proto/info_pb2.py similarity index 100% rename from Scripts/graph/proto/info_pb2.py rename to Scripts/cli/proto/info_pb2.py diff --git a/Scripts/graph/proto/request_pb2.py b/Scripts/cli/proto/request_pb2.py similarity index 100% rename from Scripts/graph/proto/request_pb2.py rename to Scripts/cli/proto/request_pb2.py diff --git a/Scripts/graph/proto/response_pb2.py b/Scripts/cli/proto/response_pb2.py similarity index 100% rename from Scripts/graph/proto/response_pb2.py rename to Scripts/cli/proto/response_pb2.py diff --git a/Scripts/graph/proto/settings_pb2.py b/Scripts/cli/proto/settings_pb2.py similarity index 100% rename from Scripts/graph/proto/settings_pb2.py rename to Scripts/cli/proto/settings_pb2.py diff --git a/Scripts/cli/requirements.txt b/Scripts/cli/requirements.txt new file mode 100644 index 0000000..9ebdcb8 --- /dev/null +++ b/Scripts/cli/requirements.txt @@ -0,0 +1,12 @@ +contourpy==1.2.0 +cycler==0.12.1 +fonttools==4.50.0 +kiwisolver==1.4.5 +matplotlib==3.8.3 +numpy==1.26.4 +packaging==24.0 +pillow==10.3.0 +pyparsing==3.1.2 +pyserial==3.5 +python-dateutil==2.9.0.post0 +six==1.16.0 diff --git a/Scripts/cli/setup.py b/Scripts/cli/setup.py new file mode 100644 index 0000000..9f7b054 --- /dev/null +++ b/Scripts/cli/setup.py @@ -0,0 +1,48 @@ +import io +import os + +from setuptools import find_packages, setup + + +def read(*paths, **kwargs): + """Reads content at the given location.""" + + content = "" + with io.open( + os.path.join(os.path.dirname(__file__), *paths), + encoding=kwargs.get("encoding", "utf8"), + ) as open_file: + content = open_file.read().strip() + return content + + +def read_description() -> str: + """Reads description at the static location.""" + + return read("README.md") + + +def read_requirements() -> list[str]: + """Reads requirements file at the static location.""" + + return [ + line.strip() + for line in read("requirements.txt").split("\n") + if not line.startswith(('"', "#", "-", "git+")) + ] + + +setup( + name="light-sensor-cli", + version="0.0.1", + description="A tool used to allows to perform operations on STM32L476RG board with installed TSL2591X light sensor with the help of serial connection.", + url="https://github.com/YarikRevich/light-detector", + long_description=read_description(), + long_description_content_type="text/markdown", + author="YarikRevich", + packages=find_packages(exclude=["tests", ".github"]), + install_requires=read_requirements(), + entry_points={ + "console_scripts": ["light-sensor-cli = src.cli.__main__:main"] + }, +) diff --git a/Scripts/cli/src/__init__.py b/Scripts/cli/src/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Scripts/cli/src/__main__.py b/Scripts/cli/src/__main__.py new file mode 100644 index 0000000..ddb3d45 --- /dev/null +++ b/Scripts/cli/src/__main__.py @@ -0,0 +1,6 @@ +from cli import main + +if __name__ == "__main__": + """Represents external entrypoint.""" + + main() \ No newline at end of file diff --git a/Scripts/cli/src/__pycache__/__init__.cpython-312.pyc b/Scripts/cli/src/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..d5e435d Binary files /dev/null and b/Scripts/cli/src/__pycache__/__init__.cpython-312.pyc differ diff --git a/Scripts/cli/src/__pycache__/cli.cpython-312.pyc b/Scripts/cli/src/__pycache__/cli.cpython-312.pyc new file mode 100644 index 0000000..aa913d4 Binary files /dev/null and b/Scripts/cli/src/__pycache__/cli.cpython-312.pyc differ diff --git a/Scripts/cli/src/cli.py b/Scripts/cli/src/cli.py new file mode 100644 index 0000000..c3be1a9 --- /dev/null +++ b/Scripts/cli/src/cli.py @@ -0,0 +1,9 @@ +import fire + +from command import BaseCommand + + +def main() -> None: + """Represents internal entrypoint.""" + + fire.Fire(BaseCommand) diff --git a/Scripts/cli/src/command/__init__.py b/Scripts/cli/src/command/__init__.py new file mode 100644 index 0000000..0089b43 --- /dev/null +++ b/Scripts/cli/src/command/__init__.py @@ -0,0 +1 @@ +from .base import BaseCommand \ No newline at end of file diff --git a/Scripts/cli/src/command/__pycache__/__init__.cpython-312.pyc b/Scripts/cli/src/command/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..003b223 Binary files /dev/null and b/Scripts/cli/src/command/__pycache__/__init__.cpython-312.pyc differ diff --git a/Scripts/cli/src/command/__pycache__/base.cpython-312.pyc b/Scripts/cli/src/command/__pycache__/base.cpython-312.pyc new file mode 100644 index 0000000..9e72fe0 Binary files /dev/null and b/Scripts/cli/src/command/__pycache__/base.cpython-312.pyc differ diff --git a/Scripts/cli/src/command/__pycache__/list_available_devices.cpython-312.pyc b/Scripts/cli/src/command/__pycache__/list_available_devices.cpython-312.pyc new file mode 100644 index 0000000..9793b2a Binary files /dev/null and b/Scripts/cli/src/command/__pycache__/list_available_devices.cpython-312.pyc differ diff --git a/Scripts/cli/src/command/base.py b/Scripts/cli/src/command/base.py new file mode 100644 index 0000000..4ea2bc1 --- /dev/null +++ b/Scripts/cli/src/command/base.py @@ -0,0 +1,33 @@ +from serial.tools import list_ports +from serial import Serial + +from .list_available_devices import ListAvailableDevicesCommand + + +class BaseCommand: + """Represents base command handler.""" + + def list_available_devices(self, name="list-available-devices") -> None: + """Lists all the available compatible devices connected to serial ports.""" + + ListAvailableDevicesCommand.handle() + + # """bit rate and bit amount per image""" + # + # + # ser = Serial("COM7", 9600) + # with open("/dev/COM7", "rb") as ser: + # while True: + # bs = ser.read(2048) + # print(repr(bs)) + # + # for entity in list_ports.comports(): + # print(entity.name, entity.device, entity.description, entity.manufacturer) + + # + # def is_connected(self, ): + # """""" + # return 2 * number + + """list available ports + is connected """ diff --git a/Scripts/cli/src/command/get_data_once.py b/Scripts/cli/src/command/get_data_once.py new file mode 100644 index 0000000..e69de29 diff --git a/Scripts/cli/src/command/get_data_series.py b/Scripts/cli/src/command/get_data_series.py new file mode 100644 index 0000000..e69de29 diff --git a/Scripts/cli/src/command/get_info.py b/Scripts/cli/src/command/get_info.py new file mode 100644 index 0000000..4bba785 --- /dev/null +++ b/Scripts/cli/src/command/get_info.py @@ -0,0 +1,7 @@ + +class GetInfoCommand: + """Represents 'list_available_devices' command.""" + + @staticmethod + def handle(): + """Handles the execution of command wrapper.""" \ No newline at end of file diff --git a/Scripts/cli/src/command/list_available_devices.py b/Scripts/cli/src/command/list_available_devices.py new file mode 100644 index 0000000..8bfc0f2 --- /dev/null +++ b/Scripts/cli/src/command/list_available_devices.py @@ -0,0 +1,11 @@ +from dto import AvailableDevicesDto +from tools import print_output + +class ListAvailableDevicesCommand: + """Represents 'list_available_devices' command.""" + + @staticmethod + def handle(): + """Handles the execution of command wrapper.""" + + print_output(AvailableDevicesDto("test")) diff --git a/Scripts/cli/src/command/set_settings.py b/Scripts/cli/src/command/set_settings.py new file mode 100644 index 0000000..e69de29 diff --git a/Scripts/cli/src/compatibility/__init__.py b/Scripts/cli/src/compatibility/__init__.py new file mode 100644 index 0000000..808c41f --- /dev/null +++ b/Scripts/cli/src/compatibility/__init__.py @@ -0,0 +1,2 @@ +from .campatibility import is_manufacturer_allowed +from .campatibility import is_device_allowed \ No newline at end of file diff --git a/Scripts/cli/src/compatibility/campatibility.py b/Scripts/cli/src/compatibility/campatibility.py new file mode 100644 index 0000000..c4d7ea7 --- /dev/null +++ b/Scripts/cli/src/compatibility/campatibility.py @@ -0,0 +1,13 @@ +STM_ELECTRONICS = "STM" + + +def is_manufacturer_allowed(src: str) -> bool: + """Checks if the given manufacturer is among of allowed ones.""" + + return True + + +def is_device_allowed(src: str) -> bool: + """Checks if the given device name is among of allowed ones.""" + + return True diff --git a/Scripts/cli/src/dto/__init__.py b/Scripts/cli/src/dto/__init__.py new file mode 100644 index 0000000..6807779 --- /dev/null +++ b/Scripts/cli/src/dto/__init__.py @@ -0,0 +1 @@ +from .available_devices_dto import AvailableDevicesDto diff --git a/Scripts/cli/src/dto/__pycache__/__init__.cpython-312.pyc b/Scripts/cli/src/dto/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..bb70e03 Binary files /dev/null and b/Scripts/cli/src/dto/__pycache__/__init__.cpython-312.pyc differ diff --git a/Scripts/cli/src/dto/__pycache__/available_devices_dto.cpython-312.pyc b/Scripts/cli/src/dto/__pycache__/available_devices_dto.cpython-312.pyc new file mode 100644 index 0000000..f33b929 Binary files /dev/null and b/Scripts/cli/src/dto/__pycache__/available_devices_dto.cpython-312.pyc differ diff --git a/Scripts/cli/src/dto/available_devices_dto.py b/Scripts/cli/src/dto/available_devices_dto.py new file mode 100644 index 0000000..8173ad2 --- /dev/null +++ b/Scripts/cli/src/dto/available_devices_dto.py @@ -0,0 +1,5 @@ +class AvailableDevicesDto: + """Represents dto used to hold result of 'list_available_devices' command""" + + def __init__(self, src: str): + pass \ No newline at end of file diff --git a/Scripts/cli/src/graph/__init__.py b/Scripts/cli/src/graph/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Scripts/graph/main.py b/Scripts/cli/src/graph/graph.py similarity index 85% rename from Scripts/graph/main.py rename to Scripts/cli/src/graph/graph.py index 1773193..969d6c2 100644 --- a/Scripts/graph/main.py +++ b/Scripts/cli/src/graph/graph.py @@ -1,3 +1,4 @@ + import tkinter from tkinter import Tk @@ -6,12 +7,14 @@ from serial.tools import list_ports + def retrieve_ports() -> list[str]: """Retrieves standardized""" for entity in list_ports.comports(): pass + def render_figure(data: list[str]) -> None: """Renderes figure with the given content""" @@ -31,10 +34,4 @@ def render_figure(data: list[str]) -> None: root.mainloop() -def main() -> None: - """Represents entrypoint""" - - render_figure(retrieve_ports()) - -if __name__ == "__main__": - main() \ No newline at end of file +render_figure(retrieve_ports()) \ No newline at end of file diff --git a/Scripts/cli/src/tools/__init__.py b/Scripts/cli/src/tools/__init__.py new file mode 100644 index 0000000..acac466 --- /dev/null +++ b/Scripts/cli/src/tools/__init__.py @@ -0,0 +1 @@ +from .prettifier import print_output \ No newline at end of file diff --git a/Scripts/cli/src/tools/__pycache__/__init__.cpython-312.pyc b/Scripts/cli/src/tools/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..0da4406 Binary files /dev/null and b/Scripts/cli/src/tools/__pycache__/__init__.cpython-312.pyc differ diff --git a/Scripts/cli/src/tools/__pycache__/prettifier.cpython-312.pyc b/Scripts/cli/src/tools/__pycache__/prettifier.cpython-312.pyc new file mode 100644 index 0000000..fbee290 Binary files /dev/null and b/Scripts/cli/src/tools/__pycache__/prettifier.cpython-312.pyc differ diff --git a/Scripts/cli/src/tools/prettifier.py b/Scripts/cli/src/tools/prettifier.py new file mode 100644 index 0000000..0c7bd95 --- /dev/null +++ b/Scripts/cli/src/tools/prettifier.py @@ -0,0 +1,7 @@ +import pprint + + +def print_output(src: object) -> None: + """Prints given object in a pretty way. Given object is supposed to be a data holder.""" + + pprint.pp(vars(src)) diff --git a/light_detector.ioc b/light_detector.ioc index 3badb6a..bcc6aae 100644 --- a/light_detector.ioc +++ b/light_detector.ioc @@ -43,11 +43,12 @@ Mcu.Pin1=PH0-OSC_IN (PH0) Mcu.Pin2=PH1-OSC_OUT (PH1) Mcu.Pin3=PA2 Mcu.Pin4=PA3 -Mcu.Pin5=PB8 -Mcu.Pin6=PB9 -Mcu.Pin7=VP_SYS_VS_Systick -Mcu.Pin8=VP_TIM16_VS_ClockSourceINT -Mcu.PinsNb=9 +Mcu.Pin5=PA5 +Mcu.Pin6=PB8 +Mcu.Pin7=PB9 +Mcu.Pin8=VP_SYS_VS_Systick +Mcu.Pin9=VP_TIM16_VS_ClockSourceINT +Mcu.PinsNb=10 Mcu.ThirdPartyNb=0 Mcu.UserConstants= Mcu.UserName=STM32L476RGTx @@ -77,6 +78,8 @@ PA2.Signal=USART2_TX PA3.Locked=true PA3.Mode=Asynchronous PA3.Signal=USART2_RX +PA5.Locked=true +PA5.Signal=GPIO_Output PB8.Locked=true PB8.Mode=I2C PB8.Signal=I2C1_SCL