Skip to content

Commit 2c9b158

Browse files
author
Nicolas Rabault
authored
Merge pull request #63 from Luos-io/assert
Add assertion management, fix #62
2 parents 5596447 + 7efbf74 commit 2c9b158

14 files changed

+215
-105
lines changed

.github/workflows/build.yml

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: Build
22

33
on:
4-
pull_request:
54
push:
65
branches:
76
- master

.github/workflows/dev-build.yml

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches-ignore:
66
- master
7+
78

89
jobs:
910

@@ -45,6 +46,8 @@ jobs:
4546
# Save branch name
4647
branch_name=$(git branch --show-current)
4748
origine_branch_name="origin/${branch_name}"
49+
echo current branch name is ${branch_name}
50+
4851
# Step back and get dependancies
4952
cd ..
5053
@@ -55,6 +58,8 @@ jobs:
5558
then
5659
echo A dependant branch have been found on LuosHAL
5760
git checkout $branch_name
61+
else
62+
echo use master branch on LuosHAL
5863
fi
5964
cd ..
6065
@@ -65,6 +70,8 @@ jobs:
6570
then
6671
echo A dependant branch have been found on Examples
6772
git checkout $branch_name
73+
else
74+
echo use master branch on Examples
6875
fi
6976
cd ..
7077

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.DS_Store
22
**/.DS_Store
3+
*.icloud
4+
**/*.icloud
35
.vscode/

Robus/src/msg_alloc.c

+3-10
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include "config.h"
4747
#include "msg_alloc.h"
4848
#include "luos_hal.h"
49+
#include "luos_utils.h"
4950

5051
/*******************************************************************************
5152
* Definitions
@@ -412,11 +413,7 @@ static inline error_return_t MsgAlloc_ClearMsgSpace(void *from, void *to)
412413
******************************************************************************/
413414
static inline void MsgAlloc_ClearMsgTask(void)
414415
{
415-
if (msg_tasks_stack_id > MAX_MSG_NB)
416-
{
417-
while (1)
418-
;
419-
}
416+
LUOS_ASSERT(msg_tasks_stack_id <= MAX_MSG_NB);
420417
for (uint16_t rm = 0; rm < msg_tasks_stack_id; rm++)
421418
{
422419
msg_tasks[rm] = msg_tasks[rm + 1];
@@ -466,11 +463,7 @@ void MsgAlloc_UsedMsgEnd(void)
466463
******************************************************************************/
467464
static inline void MsgAlloc_ClearLuosTask(uint16_t luos_task_id)
468465
{
469-
if ((luos_task_id > luos_tasks_stack_id) || (luos_tasks_stack_id > MAX_MSG_NB))
470-
{
471-
while (1)
472-
;
473-
}
466+
LUOS_ASSERT((luos_task_id <= luos_tasks_stack_id) || (luos_tasks_stack_id <= MAX_MSG_NB));
474467
for (uint16_t rm = luos_task_id; rm < luos_tasks_stack_id; rm++)
475468
{
476469
luos_tasks[rm] = luos_tasks[rm + 1];

Robus/src/robus.c

+3-7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "context.h"
1515
#include "luos_hal.h"
1616
#include "msg_alloc.h"
17+
#include "luos_utils.h"
1718

1819
/*******************************************************************************
1920
* Definitions
@@ -287,12 +288,7 @@ uint16_t Robus_TopologyDetection(ll_container_t *ll_container)
287288
if (Robus_DetectNextNodes(ll_container) == FAILED)
288289
{
289290
// check the number of retry we made
290-
if (redetect_nb > 4)
291-
{
292-
// Too many retry just, there is no hope too succeed.
293-
while (1)
294-
;
295-
}
291+
LUOS_ASSERT((redetect_nb <= 4));
296292
// Detection fail, restart it
297293
redetect_nb++;
298294
goto redetect;
@@ -464,4 +460,4 @@ static error_return_t Robus_MsgHandler(msg_t *input)
464460
node_t *Robus_GetNode(void)
465461
{
466462
return (node_t *)&ctx.node;
467-
}
463+
}

inc/container_structs.h

+17-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@
1414
/*******************************************************************************
1515
* Definitions
1616
******************************************************************************/
17+
/* store informations about luos stats
18+
* please refer to the documentation
19+
*/
20+
typedef struct __attribute__((__packed__))
21+
{
22+
union
23+
{
24+
struct __attribute__((__packed__))
25+
{
26+
memory_stats_t memory;
27+
uint8_t max_loop_time_ms;
28+
};
29+
uint8_t unmap[sizeof(memory_stats_t) + 1]; /*!< streamable form. */
30+
};
31+
} luos_stats_t;
1732
/* This structure is used to create containers version
1833
* please refer to the documentation
1934
*/
@@ -70,7 +85,8 @@ typedef struct __attribute__((__packed__)) container_t
7085
uint8_t alias[MAX_ALIAS_SIZE]; /*!< container alias. */
7186
timed_update_t auto_refresh; /*!< container auto refresh context. */
7287
revision_t revision; /*!< container firmware version. */
73-
container_stats_t statistic;
88+
luos_stats_t *node_statistics; /*!< Node level statistics. */
89+
container_stats_t statistics; /*!< container level statistics. */
7490
} container_t;
7591

7692
typedef void (*CONT_CB)(container_t *container, msg_t *msg);

inc/luos.h

+3-15
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#ifndef LUOS_H
88
#define LUOS_H
99

10+
#include "luos_utils.h"
1011
#include "luos_list.h"
1112
#include "container_structs.h"
1213
#include "routing_table.h"
@@ -18,22 +19,9 @@
1819
******************************************************************************/
1920

2021
/******************************************************************************
21-
* @struct luos_stats_t
22-
* @brief store informations about luos stats
22+
* @struct general_stats_t
23+
* @brief format all datas to be sent trough msg
2324
******************************************************************************/
24-
typedef struct __attribute__((__packed__))
25-
{
26-
union
27-
{
28-
struct __attribute__((__packed__))
29-
{
30-
memory_stats_t memory;
31-
uint8_t max_loop_time_ms;
32-
};
33-
uint8_t unmap[sizeof(memory_stats_t) + 1]; /*!< streamable form. */
34-
};
35-
} luos_stats_t;
36-
3725
typedef struct __attribute__((__packed__))
3826
{
3927
union

inc/luos_utils.h

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/******************************************************************************
2+
* @file luos utils
3+
* @brief some tools used to debug
4+
* @author Luos
5+
* @version 0.0.0
6+
******************************************************************************/
7+
#ifndef LUOS_UTILS_H
8+
#define LUOS_UTILS_H
9+
10+
#include <stdint.h>
11+
/*******************************************************************************
12+
* Definitions
13+
******************************************************************************/
14+
15+
#define LUOS_ASSERTION
16+
17+
#ifdef LUOS_ASSERTION
18+
#define LUOS_ASSERT(expr) \
19+
if (!(expr)) \
20+
Luos_assert(__FILE__, __LINE__)
21+
#else
22+
#define LUOS_ASSERT(expr)
23+
#endif
24+
25+
/* This structure is used to manage node assertion informations
26+
*/
27+
typedef struct __attribute__((__packed__))
28+
{
29+
union
30+
{
31+
struct __attribute__((__packed__))
32+
{
33+
uint32_t line;
34+
char file[100];
35+
};
36+
uint8_t unmap[100 + sizeof(uint32_t)];
37+
};
38+
} luos_assert_t;
39+
40+
/*******************************************************************************
41+
* Variables
42+
******************************************************************************/
43+
44+
/*******************************************************************************
45+
* Function
46+
******************************************************************************/
47+
48+
void Luos_assert(char *file, uint32_t line);
49+
50+
#endif /* LUOS_UTILS_H */

inc/routing_table.h

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ void RoutingTB_ComputeRoutingTableEntryNB(void);
7575
void RoutingTB_DetectContainers(container_t *container);
7676
void RoutingTB_ConvertNodeToRoutingTable(routing_table_t *entry, node_t *node);
7777
void RoutingTB_ConvertContainerToRoutingTable(routing_table_t *entry, container_t *container);
78+
void RoutingTB_RemoveNode(uint16_t nodeid);
7879
void RoutingTB_RemoveOnRoutingTable(uint16_t id);
7980
void RoutingTB_Erase(void);
8081
routing_table_t *RoutingTB_Get(void);

library.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "Luos",
33
"keywords": "robus,network,microservice,luos,operating system,os,embedded,communication,module,ST",
44
"description": "Luos turns your embedded system into modules like microservices architecture does it in software.",
5-
"version": "1.0.1",
5+
"version": "1.1.0",
66
"authors": {
77
"name": "Luos",
88
"url": "https://luos.io"

0 commit comments

Comments
 (0)