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

Adapt Trainings to luos engine v3 #6

Merged
merged 3 commits into from
Dec 13, 2023
Merged
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
116 changes: 116 additions & 0 deletions .github/workflows/example_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#!/usr/bin/env python
from os.path import join, realpath, exists
import os
import subprocess
import click
import multiprocessing as mp
import sys
import time
import argparse


exampledir = '.'

# Compute the number of examples
nb_example = 0
compiled_example = None
examples_success = None
examples_failed = None
example_path_list = []

if os.path.isdir(exampledir):
for steps in os.listdir(exampledir):
steps_path = join(realpath(exampledir), steps)
if os.path.isdir(steps_path):
for state in os.listdir(steps_path):
state_path = join(steps_path, state)
if os.path.isdir(state_path):
for example in os.listdir(state_path):
example_path = join(state_path, example)
if (exists(join(example_path, "platformio.ini"))):
# This is a valid example, count it
nb_example += 1
example_path_list.append(example_path)


def init(compiled, success, failed):
''' store the counter for later use '''
global compiled_example
global examples_success
global examples_failed
compiled_example = compiled
examples_success = success
examples_failed = failed


# Example compilation task
OKGREEN = '\r\033[92m'
FAIL = '\r\033[91m'
ENDC = '\033[0m'


def compile_example(cmd, example, clean):
global compiled_example
if clean:
subprocess.call(cmd + " --target clean", shell=True,
stdout=open(os.devnull, 'wb'), stderr=open(os.devnull, 'wb'))
if subprocess.call(cmd, shell=True, stdout=open(os.devnull, 'wb'), stderr=open("err.log", 'wb')):
with compiled_example.get_lock():
compiled_example.value += 1
value = FAIL+"FAILED " + str(example + ENDC)
print(value, flush=True)
with examples_failed.get_lock():
examples_failed.value += 1
else:
with compiled_example.get_lock():
compiled_example.value += 1
value = OKGREEN + "SUCCESS " + \
str(example) + ENDC
print(value, flush=True)
with examples_success.get_lock():
examples_success.value += 1
return True


if __name__ == '__main__':

## Parse arguments ##
parser = argparse.ArgumentParser(description='A command to build them all as fast as possible!\n',
formatter_class=argparse.RawTextHelpFormatter)

# General arguments
parser.add_argument("--clean", action="store_true",
help="Clean all examples before building them")
args = parser.parse_args()

start = time.time()
# Create all example compilation tasks
compiled_example = mp.Value('i', 0)
examples_success = mp.Value('i', 0)
examples_failed = mp.Value('i', 0)
pool = mp.Pool(nb_example, initializer=init, initargs=(compiled_example,
examples_success,
examples_failed,))
click.secho(
"\nBuild result Project name\n------------ ------------")
for example_path in example_path_list:
cmd = "platformio run -d " + example_path
if (exists(join(example_path, "platformio.ini"))):
pool.apply_async(
compile_example, args=(cmd, example_path, args.clean))

pool.close()
while compiled_example.value < nb_example:
# Print a nice loading bar
chars = "/—\|"
for char in chars:
sys.stdout.write(
'\r'+'Building ' + char + ' (' + str(compiled_example.value) + "/" + str(nb_example) + ")")
time.sleep(.1)
sys.stdout.flush()

pool.join()
print("\r--------------------------------------------\nBuild summary\n--------------------------------------------")
print("\t- Success\t\t\t" + str(examples_success.value) + "/" + str(nb_example))
print("\t- Failed\t\t\t" + str(examples_failed.value) + "/" + str(nb_example))
print("\t- Total compilation time\t" + str(time.time() - start) + "s")
6 changes: 3 additions & 3 deletions 1_First_Service/Solution/Apps/Blinker_app/blinker.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ volatile time_luos_t blinktime;
unsigned long my_time; // Used to keep track of time
volatile control_t control_app;

static void Blinker_MsgHandler(service_t *service, msg_t *msg);
static void Blinker_MsgHandler(service_t *service, const msg_t *msg);

void Blinker_Init(void)
{
Expand Down Expand Up @@ -70,7 +70,7 @@ void Blinker_Loop(void)
}
}

static void Blinker_MsgHandler(service_t *service, msg_t *msg)
static void Blinker_MsgHandler(service_t *service, const msg_t *msg)
{
if (msg->header.cmd == CONTROL)
{
Expand All @@ -83,4 +83,4 @@ static void Blinker_MsgHandler(service_t *service, msg_t *msg)
TimeOD_TimeFromMsg((time_luos_t *)&blinktime, msg);
return;
}
}
}
4 changes: 2 additions & 2 deletions 1_First_Service/Solution/Apps/Blinker_app/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
},
"licence": "MIT",
"dependencies": {
"luos/luos_engine": "^2.6.3"
"luos_engine": "^3.0.0"
}
}
}
2 changes: 1 addition & 1 deletion 1_First_Service/Solution/Arduino/lib/Led/led.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "led.h"
#include "Arduino.h"

void Led_MsgHandler(service_t *service, msg_t *msg)
void Led_MsgHandler(service_t *service, const msg_t *msg)
{
if (msg->header.cmd == IO_STATE)
{
Expand Down
6 changes: 5 additions & 1 deletion 1_First_Service/Solution/Arduino/node_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
* # Usage
* This file should be place a the root folder of your project and include
* where build flag preprocessor definitions are define in your IDE
* -include node_config.h
*
-D GATEFORMAT=TinyJSON
-DROBUSHAL=?
-D PIPEMODE=SERIAL
-D PIPEHAL=?
*
* @author Luos
* @version 0.0.0
Expand Down
12 changes: 6 additions & 6 deletions 1_First_Service/Solution/Arduino/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@ lib_ldf_mode =off
build_unflags = -Os
build_flags =
-O1
-include node_config.h
-D LUOSHAL=ATSAMD21_ARDUINO
-D GATEFORMAT=TinyJSON
-D ROBUSHAL=ATSAMD21_ARDUINO
-D PIPEMODE=SERIAL
-D PIPEHAL=ARDUINO
-D LUOSHAL=ATSAMD21_ARDUINO
lib_deps =
luos_engine@^2.6.3
luos/luos_engine@^3.0.0
luos/robus_network
Led
Blinker_App
Pipe
Gate
luos/Pipe
luos/Gate
lib_extra_dirs =
$PROJECT_DIR/../Apps
lib


[env:arduino]
board = mkrzero #mkrzero, mkr1000USB or any SAMD21 based Arduino board
platform_packages = framework-arduino-samd@https://github.com/Luos-io/Arduino_core.git
Expand Down
4 changes: 2 additions & 2 deletions 1_First_Service/Solution/NUCLEO-F072RB/lib/Led/led.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "led.h"
#include "gpio.h"

static void Led_MsgHandler(service_t *service, msg_t *msg);
static void Led_MsgHandler(service_t *service, const msg_t *msg);

void Led_Init(void)
{
Expand All @@ -17,7 +17,7 @@ void Led_Init(void)

void Led_Loop(void) {}

static void Led_MsgHandler(service_t *service, msg_t *msg)
static void Led_MsgHandler(service_t *service, const msg_t *msg)
{
if (msg->header.cmd == IO_STATE)
{
Expand Down
4 changes: 2 additions & 2 deletions 1_First_Service/Solution/NUCLEO-F072RB/lib/Led/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
},
"licence": "MIT",
"dependencies": {
"luos/luos_engine": "^2.6.3"
"luos_engine": "^3.0.0"
}
}
}
6 changes: 5 additions & 1 deletion 1_First_Service/Solution/NUCLEO-F072RB/node_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
* # Usage
* This file should be place a the root folder of your project and include
* where build flag preprocessor definitions are define in your IDE
* -include node_config.h
*
-D GATEFORMAT=TinyJSON
-DROBUSHAL=?
-D PIPEMODE=SERIAL
-D PIPEHAL=?
*
* @author Luos
* @version 0.0.0
Expand Down
15 changes: 8 additions & 7 deletions 1_First_Service/Solution/NUCLEO-F072RB/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,20 @@ lib_ldf_mode =off
build_unflags = -Os
build_flags =
-O1
-include node_config.h
-D GATEFORMAT=TinyJSON
-D ROBUSHAL=STM32F0
-DUSE_HAL_DRIVER
-DUSE_FULL_LL_DRIVER
-DLUOSHAL=STM32F0
-D LUOSHAL=STM32F0
-D GATEFORMAT=TinyJSON
-D PIPEMODE=SERIAL
-D PIPEHAL=NUCLEO-F0
lib_deps =
Luos_engine@^2.9.2
lib_deps =
luos/luos_engine@^3.0.0
luos/robus_network
Led
Blinker_App
Pipe
Gate
luos/Pipe
luos/Gate
lib_extra_dirs =
$PROJECT_DIR/../Apps
lib
Expand Down
4 changes: 2 additions & 2 deletions 1_First_Service/Solution/NUCLEO-F401RE/lib/Led/led.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "led.h"
#include "gpio.h"

static void Led_MsgHandler(service_t *service, msg_t *msg);
static void Led_MsgHandler(service_t *service, const msg_t *msg);

void Led_Init(void)
{
Expand All @@ -17,7 +17,7 @@ void Led_Init(void)

void Led_Loop(void) {}

static void Led_MsgHandler(service_t *service, msg_t *msg)
static void Led_MsgHandler(service_t *service, const msg_t *msg)
{
if (msg->header.cmd == IO_STATE)
{
Expand Down
4 changes: 2 additions & 2 deletions 1_First_Service/Solution/NUCLEO-F401RE/lib/Led/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
},
"licence": "MIT",
"dependencies": {
"luos/luos_engine": "^2.6.3"
"luos_engine": "^3.0.0"
}
}
}
6 changes: 5 additions & 1 deletion 1_First_Service/Solution/NUCLEO-F401RE/node_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
* # Usage
* This file should be place a the root folder of your project and include
* where build flag preprocessor definitions are define in your IDE
* -include node_config.h
*
-D GATEFORMAT=TinyJSON
-DROBUSHAL=?
-D PIPEMODE=SERIAL
-D PIPEHAL=?
*
* @author Luos
* @version 0.0.0
Expand Down
13 changes: 7 additions & 6 deletions 1_First_Service/Solution/NUCLEO-F401RE/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,20 @@ lib_ldf_mode =off
build_unflags = -Os
build_flags =
-O1
-include node_config.h
-D GATEFORMAT=TinyJSON
-D ROBUSHAL=STM32F4
-DUSE_HAL_DRIVER
-DUSE_FULL_LL_DRIVER
-DLUOSHAL=STM32F4
-D LUOSHAL=STM32F4
-D PIPEMODE=SERIAL
-D PIPEHAL=NUCLEO-F4
lib_deps =
Luos_engine@^2.9.2
lib_deps =
luos/luos_engine@^3.0.0
luos/robus_network
Led
Blinker_App
Pipe
Gate
luos/Pipe
luos/Gate
lib_extra_dirs =
$PROJECT_DIR/../Apps
lib
Expand Down
4 changes: 2 additions & 2 deletions 1_First_Service/Solution/NUCLEO-F410RB/lib/Led/led.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "led.h"
#include "gpio.h"

static void Led_MsgHandler(service_t *service, msg_t *msg);
static void Led_MsgHandler(service_t *service, const msg_t *msg);

void Led_Init(void)
{
Expand All @@ -17,7 +17,7 @@ void Led_Init(void)

void Led_Loop(void) {}

static void Led_MsgHandler(service_t *service, msg_t *msg)
static void Led_MsgHandler(service_t *service, const msg_t *msg)
{
if (msg->header.cmd == IO_STATE)
{
Expand Down
4 changes: 2 additions & 2 deletions 1_First_Service/Solution/NUCLEO-F410RB/lib/Led/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
},
"licence": "MIT",
"dependencies": {
"luos/luos_engine": "^2.6.3"
"luos_engine": "^3.0.0"
}
}
}
6 changes: 5 additions & 1 deletion 1_First_Service/Solution/NUCLEO-F410RB/node_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
* # Usage
* This file should be place a the root folder of your project and include
* where build flag preprocessor definitions are define in your IDE
* -include node_config.h
*
-D GATEFORMAT=TinyJSON
-DROBUSHAL=?
-D PIPEMODE=SERIAL
-D PIPEHAL=?
*
* @author Luos
* @version 0.0.0
Expand Down
Loading
Loading