Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task 3, libSMCE console #51

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ target_sources (HostUDD PRIVATE
)


add_library (objSMCE OBJECT)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superfluous change

add_library (objSMCE OBJECT )
configure_coverage (objSMCE)
set_property (TARGET objSMCE PROPERTY CXX_EXTENSIONS Off)
set_property (TARGET objSMCE PROPERTY POSITION_INDEPENDENT_CODE True)
Expand All @@ -153,6 +153,7 @@ target_sources (objSMCE PRIVATE
include/SMCE/SketchConf.hpp
include/SMCE/internal/BoardDeviceSpecification.hpp
)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superfluous change

if (NOT MSVC)
target_compile_options (objSMCE PRIVATE "-Wall" "-Wextra" "-Wpedantic" "-Werror" "-Wcast-align")
else ()
Expand Down
49 changes: 49 additions & 0 deletions client/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#
# client/CMakeLists.txt
# Written by Rylander and Mejborn, Team 1, DAT265.
#
#


cmake_minimum_required (VERSION 3.16)
project (SMCE_client)

find_package (Threads REQUIRED)
find_package (SMCE REQUIRED)

set (SMCE_RES "${PROJECT_BINARY_DIR}/SMCE_Res")

include (FetchContent)
FetchContent_Declare (Termcolor
GIT_REPOSITORY "https://github.com/ikalnytskyi/termcolor"
GIT_TAG "v2.0.0"
GIT_SHALLOW On
GIT_PROGRESS On
)
FetchContent_Declare (Lyra
GIT_REPOSITORY "https://github.com/bfgroup/Lyra"
GIT_TAG "1.5.1"
GIT_SHALLOW On
GIT_PROGRESS On
)
FetchContent_MakeAvailable(Termcolor Lyra)

add_executable (${PROJECT_NAME} SMCE_Client.cpp)
target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/src)
target_sources (${PROJECT_NAME} PRIVATE
src/UartToFile.hpp
src/UartToFile.cpp
)
target_link_libraries (${PROJECT_NAME} PRIVATE SMCE::SMCE termcolor::termcolor bfg::Lyra)
target_include_directories (${PROJECT_NAME} PUBLIC
"${termcolor_SOURCE_DIR}/include/termcolor"
"${lyra_SOURCE_DIR}/include/lyra"
)
Comment on lines +38 to +41
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be incredibly surprised that the termcolor::termcolor and bfg::Lyra targets don't already provide those directories in their interface properties

target_compile_definitions (${PROJECT_NAME} PRIVATE "SMCE_RESOURCES_DIR=\"${SMCE_RES}\"")
file (MAKE_DIRECTORY "${SMCE_RES}")
execute_process (COMMAND "${CMAKE_COMMAND}" -E tar xf "${SMCE_RESOURCES_ARK}"
WORKING_DIRECTORY "${SMCE_RES}")

add_custom_command (TARGET ${PROJECT_NAME} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:SMCE::SMCE>" "$<TARGET_FILE_DIR:SMCE_client>"
)
62 changes: 62 additions & 0 deletions client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# libSMCE command line frontend

Like SMCE, this command line frontend requires a C++20 toolchain.

**IMPORTANT**
As is, SMCE_Client is not guaranteed to work on Windows machines!
Due to a bug that causes the running sketch to crash when sending or reciving messages on uart.


## Build instructions

```shell
cd client
cmake -S . -B build/
cmake --build build/
```

You can now find the executable "SMCE_client" in the `./build` directory.

## Run instructions
```
SMCE_client -f <fqbn> -p <path_to_sketch>
```
where
- FQBN: [Fully Qualified Board Name](https://arduino.github.io/arduino-cli/latest/FAQ/#whats-the-fqbn-string)
Testing has been done with fqbn = arduino:sam:arduino_due_x
- Sketch path: Relative or absolute path to the sketch to run

### Start arguments
-f,--fqbn <fqbn> -> <fqbn> = Fully qualified board name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a note in general, fqbn is basically deprecated, so I would default this parameter

-p,--path <path_to_sketch> -> <path_to_sketch> = Relative or absolute path to the sketch to run
-d,--dir <arduino_root_dir> -> <arduino_root_dir> = Relative or absolute path to desired location of arduino root folder
-s,--SMCE <smce_resource_dir> -> <smce_resource_dir> = Relative or absolute path to SMCE\_RESOURCE folder
-u,--file <write_to_file> -> <write_to_file> = Set to true if uart should write to file (created in the set arduino root folder)

(-s or -- SMCE, can be used if binary is not compiled and already linked to the SMCE_RESOURCE folder for the current computer.)

## Configuration of board

As is, configuring of GPIO pins on the board is done in the source file SMCE_Client.cpp, as seen here:

```
smce::BoardConfig board_conf{
.pins = {0,1},
.gpio_drivers = {
smce::BoardConfig::GpioDrivers{0,
smce::BoardConfig::GpioDrivers::DigitalDriver{true,true},
smce::BoardConfig::GpioDrivers::AnalogDriver{false,false}
},
...
...
}
```
.pins = a list of all a pins on the board.
.gpio_drivers = specifies the drivers for each pin, configured as:
```
smce::BoardConfig::GpioDrivers{<pin>,
smce::BoardConfig::GpioDrivers::DigitalDriver{<read>,<write>},
smce::BoardConfig::GpioDrivers::AnalogDriver{<read>,<write>}
}
```
DigitalDriver and AnalogDriver has two parameters {<read>,<write>}, these are set as true or false depending on what the pin should be able to do.
Loading