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

Feat/v3.0.0 #24

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
109 changes: 109 additions & 0 deletions .github/workflows/example_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#!/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

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


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 in os.listdir(exampledir):
example_path = join(exampledir, example)
cmd = "platformio run -d " + example_path
if (exists(join(example_path, "platformio.ini"))):
pool.apply_async(
compile_example, args=(cmd, example, 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 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;
}
}
}
31 changes: 19 additions & 12 deletions Apps/Blinker_app/blinker.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
#ifndef BOOTLOADER_H
#define BOOTLOADER_H

#ifdef __cplusplus
extern "C"
{
#endif
#include "luos_engine.h"

/*******************************************************************************
* Definitions
******************************************************************************/
/*******************************************************************************
* Definitions
******************************************************************************/

/*******************************************************************************
* Variables
******************************************************************************/
/*******************************************************************************
* Variables
******************************************************************************/

/*******************************************************************************
* Function
******************************************************************************/
void Blinker_Init(void);
void Blinker_Loop(void);
/*******************************************************************************
* Function
******************************************************************************/
void Blinker_Init(void);
void Blinker_Loop(void);

#endif /* LED_H */
#ifdef __cplusplus
}
#endif
#endif /* LED_H */
9 changes: 6 additions & 3 deletions Arduino/lib/Led/led.c → Arduino/lib/Led/led.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/*******************************************************************************
* Function
******************************************************************************/
static void Led_MsgHandler(service_t *service, msg_t *msg);
static void Led_MsgHandler(service_t *service, const msg_t *msg);

/******************************************************************************
* @brief init must be call in project init
Expand All @@ -28,7 +28,10 @@ void Led_Init(void)
{
pinMode(LED_BUILTIN, OUTPUT);

revision_t revision = {.major = 1, .minor = 0, .build = 0};
revision_t revision;
revision.major = 1;
revision.minor = 0;
revision.build = 0;
Luos_CreateService(Led_MsgHandler, STATE_TYPE, "led", revision);
}
/******************************************************************************
Expand All @@ -43,7 +46,7 @@ void Led_Loop(void) {}
* @param Msg receive
* @return None
******************************************************************************/
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
11 changes: 6 additions & 5 deletions Arduino/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,19 @@ build_flags =
-O1
-include node_config.h
-D LUOSHAL=ATSAMD21_ARDUINO
-D ROBUSHAL=ATSAMD21_ARDUINO
-D GATEFORMAT=TinyJSON
-D PIPEMODE=SERIAL
-D PIPEHAL=ARDUINO
lib_deps =
luos_engine@^2.9.2
luos/luos_engine@^3.0.0
luos/robus_network
Led
Blinker_App
Pipe
Gate
Inspector
luos/Pipe
luos/Gate
lib_extra_dirs =
$PROJECT_DIR/../Apps
../Apps
lib


Expand Down
13 changes: 3 additions & 10 deletions Arduino/src/Arduino.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
#include <Arduino.h>

#ifdef __cplusplus
extern "C"
{
#endif

#include "luos_engine.h"
#include "led.h"
#include "blinker.h"
#include "pipe.h"
#include "gate.h"

#ifdef __cplusplus
}
#endif
#include "robus_network.h"

/******************************************************************************
* @brief Setup ardiuno
Expand All @@ -23,6 +14,7 @@ extern "C"
void setup()
{
Luos_Init();
Robus_Init();
Led_Init();
Pipe_Init();
Gate_Init();
Expand All @@ -36,6 +28,7 @@ void setup()
void loop()
{
Luos_Loop();
Robus_Loop();
Led_Loop();
Pipe_Loop();
Gate_Loop();
Expand Down
10 changes: 5 additions & 5 deletions ESP32-DevKit/lib/Led/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set(srcs "led.c")
set(srcs "led")

set(inc ".")
set(inc ".")

idf_component_register( SRCS ${srcs}
INCLUDE_DIRS ${inc}
REQUIRES luos_engine led_strip)
idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${inc}
REQUIRES luos_engine)
8 changes: 4 additions & 4 deletions ESP32-DevKit/lib/Led/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ https://github.com/Luos-io/examples/blob/master/LICENSE)
[![](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Unleash%20electronic%20devices%20as%20microservices%20thanks%20to%20Luos&https://luos.io&via=Luos_io&hashtags=embeddedsystems,electronics,microservices,api)
[![](https://img.shields.io/badge/LinkedIn-Share-0077B5?style=social&logo=linkedin)](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fgithub.com%2Fluos-io)

# Button driver
Driver for using a push button in your projects with Luos.
# Led driver
Driver for using a led in your projects with Luos.

# Linked project
This driver is linked to the [Button project](../../Projects/button).
This driver is linked to the [led project](../../Projects/led).

[![](https://img.shields.io/discourse/topics?server=https%3A%2F%2Fcommunity.luos.io&logo=Discourse)](https://community.luos.io)
[![](https://img.shields.io/badge/Luos-Documentation-34A3B4)](https://docs.luos.io)
[![](https://img.shields.io/badge/Luos-Documentation-34A3B4)](https://www.luos.io/docs/)
[![](https://img.shields.io/badge/LinkedIn-Follow%20us-0077B5?style=flat&logo=linkedin)](https://www.linkedin.com/company/luos)
10 changes: 5 additions & 5 deletions ESP32-DevKit/lib/Led/led.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/******************************************************************************
* @file led
* @brief driver example a simple led
* @file button
* @brief driver example a simple button
* @author Luos
* @version 0.0.0
******************************************************************************/
#ifndef LED_H
#define LED_H
#ifndef BUTTON_H
#define BUTTON_H

#include "luos_engine.h"
/*******************************************************************************
Expand All @@ -22,4 +22,4 @@
void Led_Init(void);
void Led_Loop(void);

#endif /* LED_H */
#endif /* BUTTON_H */
8 changes: 4 additions & 4 deletions ESP32-DevKit/lib/Led/library.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "led",
"keywords": "robus,network,microservice,luos,operating system,os,embedded,communication,container,ST",
"description": "a simple button driver",
"keywords": "robus,network,microservice,luos,operating system,os,embedded,communication,service,ST",
"description": "a simple led driver",
"version": "1.0.0",
"authors": {
"name": "Luos",
"url": "https://luos.io"
},
"licence": "MIT",
"dependencies": {
"luos/luos_engine": "^2.9.0"
"luos_engine": "^3.0.0"
}
}
}
Loading
Loading