Skip to content

Commit

Permalink
fix: fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
YarikRevich committed Apr 8, 2024
1 parent 93e3cb9 commit 496686e
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 21 deletions.
23 changes: 23 additions & 0 deletions Docs/Examples/high-level-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
```plantuml
title
High-level design of "light-detector"
end title
actor "Client"
component "Board control plain" {
entity "ProtocolBuffers"
node "Scheduler"
node "State"
node "Device driver"
[Client] <--> [ProtocolBuffers]: " Send requests"
[ProtocolBuffers] --> [Scheduler]: " Schedule task"
[Scheduler] --> [Device driver]: " Retrieve ongoing data"
[Scheduler] --> [Device driver]: " Retrieve metadata information"
[Scheduler] --> [Device driver]: " Set options"
[Scheduler] --> [State]: " Update state"
```
Binary file added Docs/Examples/high-level-design.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 1 addition & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,4 @@ endif
generate: ## Generate ProtocolBuffers files(used mainly for development)
@protoc -I./Resources/Proto/Container --pyi_out=./Scripts/cli/src/proto Content/data.proto Content/info.proto Content/settings.proto request.proto response.proto
@protoc -I./Resources/Proto/Container --python_out=./Scripts/cli/src/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

.PHONY: build
build: ## Build the IOC project

.PHONY: all
all: generate build
@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
16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,25 @@

## General Information

A driver-like application, which allows to communicate with TSL2591X light sensor with the help of CLI, based on STM32L476RG embedded system.
A driver-like application, which allows to communicate with **TSL2591X** light sensor, based on **STM32L476RG** embedded system.

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.

![](./Docs/Examples/high-level-design.png)

## Setup

All setup related operations are processed via **Makefile** placed in the root directory.

First of all connect your board to the serial port.

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
```
In order to build **IOC** project it's required to **CubeMX** to generate **ELF** upload it with the help of
**STM Programmer**.

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:
> If **ProtocolBuffers** files need to be regenerated it's required to execute the following command:
```shell
make generate
```
Expand All @@ -36,5 +34,3 @@ make generate
### CLI

Detailed documentation can be found [here](./Scripts/cli/README.md)

# Use cases
108 changes: 105 additions & 3 deletions Scripts/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ make install

# Use cases

Most of the commands given below require **baud rate**. It is important to be the exact-supported value,
otherwise requests will be ignored(in the given examples baud rate is equal to **9600**).

## Get available devices

The example below shows how to retrieve a set of all available devices, which can be used to perform other operations.
```shell
$ light-detector-cli get_available_devices
Expand All @@ -44,10 +49,14 @@ $ light-detector-cli get_available_devices
]
```

## Get info

The examples below show all the possible ways to retrieve metadata information from the board. Baud rate is important to be the exact-supported value,
otherwise requests will be ignored.
otherwise requests will be ignored(in the given examples baud rate is equal to **9600**).

The next example shows how to the value of gain metadata information from the board.
### Gain

The next example shows how to retrieve the value of gain metadata information from the board.
```shell
$ light-detector-cli get_info --device="/dev/cu.usbmodem1203" --baud_rate="9600" --type="gain"

Expand All @@ -64,7 +73,9 @@ Available **gain** values:
* 32 - high
* 48 - max

The next example shows how to the value of integral time metadata information from the board.
### Integral time

The next example shows how to retrieve the value of integral time metadata information from the board.
```shell
$ light-detector-cli get_info --device="/dev/cu.usbmodem1203" --baud_rate="9600" --type="integral_time"

Expand All @@ -82,3 +93,94 @@ Available **integral time** values:
* 3 - 400ms
* 4 - 500ms
* 5 - 600ms

### Processed requests

The next example shows how to retrieve the value of processed requests(amount of successful incoming requests, different from nonce) metadata information from the board.
```shell
$ light-detector-cli get_info --device="/dev/cu.usbmodem1203" --baud_rate="9600" --type="processed_requests"

instance(RetrievedInfoDto):
data_type: <InfoTypeCompound.PROCESSED_REQUESTS: 'ProcessedRequests'>,
device_id: 1,
nonce: 6,
value: 20
```

### Device available

The next example shows how to retrieve the value of device available metadata information from the board.
```shell
$ light-detector-cli get_info --device="/dev/cu.usbmodem1203" --baud_rate="9600" --type="device_available"

instance(RetrievedInfoDto):
data_type: <InfoTypeCompound.DEVICE_AVAILABLE: 'DeviceAvailable'>,
device_id: 1,
nonce: 7,
value: 1
```

Available **device available** values:
* 1 - device available
* 0 - device is not available

## Get data

The examples below show all the possible ways to retrieve data information from the board.

```shell
$ light-detector-cli get_data --device="/dev/cu.usbmodem1203" --baud_rate="9600" --type="raw"

[
instance(RetrievedDataDto):
data_type: <DataTypeCompound.RAW: 'Raw'>,
device_id: 1,
nonce: 4,
value: 121
]
```

In the same way other types of data can be retrieved, all the available data types are given below:
* raw
* full
* infrared
* visible

It's also possible to have a series of measurements, in order to archive that it's important to add **series** parameter.

```shell
$ light-detector-cli get_data --device="/dev/cu.usbmodem1203" --baud_rate="9600" --type="raw" --series=4

[
instance(RetrievedDataDto):
data_type: <DataTypeCompound.RAW: 'Raw'>,
device_id: 1,
nonce: 26,
value: 51
instance(RetrievedDataDto):
data_type: <DataTypeCompound.RAW: 'Raw'>,
device_id: 1,
nonce: 27,
value: 80
instance(RetrievedDataDto):
data_type: <DataTypeCompound.RAW: 'Raw'>,
device_id: 1,
nonce: 28,
value: 97
instance(RetrievedDataDto):
data_type: <DataTypeCompound.RAW: 'Raw'>,
device_id: 1,
nonce: 29,
value: 41
]
```

Having a series of measurements it becomes possible to create a diagram to more easily observe output changes. In
order to do that it's needed to add **export**(describes a location of output diagram file) and **figure**(describes a type of the diagram)
parameters.

```shell
$ light-detector-cli get_data --device="/dev/cu.usbmodem1203" --baud_rate="9600" --type="raw" --series=4 --export="./output" --figure="plot"

...
```
2 changes: 1 addition & 1 deletion Scripts/cli/src/command/get_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def handle(device: str, baud_rate: int, type: str, series: int, export: str, gen
print_output(data)
logging.info("Data has been successfully retrieved.")

if is_export_valid(export):
if series > 1 and is_export_valid(export):
visualizer = Visualizer(export, data)

match figure:
Expand Down
5 changes: 5 additions & 0 deletions Scripts/cli/src/visualizer/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
class Visualizer:
"""Represents visualizer used to create figures from the given values."""

# Represents 'scatter' type of plot.
SCATTER_FIGURE = "scatter"

# Represents 'bar' type of plot.
BAR_FIGURE = "bar"

# Represents 'plot' type of plot.
PLOT_FIGURE = "plot"

# Represents a path where generated visualization will be saved.
Expand Down

0 comments on commit 496686e

Please sign in to comment.