Skip to content

Commit 3e48187

Browse files
author
JeromeGalan
authored
Merge pull request #139 from Luos-io/rc_2.1.0
Rc 2.1.0
2 parents 2e28b4f + e8338ff commit 3e48187

21 files changed

+896
-48
lines changed

Profiles/State/profile_state.c

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "profile_state.h"
22

3+
#include "timestamp.h"
34
/******************************************************************************
45
* @brief function converting Luos messages into data and reverse.
56
* @param service the target service
@@ -23,6 +24,14 @@ void ProfileState_Handler(service_t *service, msg_t *msg)
2324
pub_msg.header.target = msg->header.source;
2425
pub_msg.header.size = sizeof(bool);
2526
memcpy(&pub_msg.data, &profile_state->state, sizeof(bool));
27+
28+
// if data are timestamped, create a dedicated luos message to handle it
29+
if (Timestamp_GetToken(&profile_state->state))
30+
{
31+
Timestamp_EncodeMsg(&pub_msg, &profile_state->state);
32+
}
33+
34+
// send message on the network
2635
Luos_SendMsg(service, &pub_msg);
2736
}
2837
break;

Robus/inc/config.h

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
#define NBR_PORT 2
4545
#endif
4646

47+
// Tab of byte. + 2 for overlap ID because aligned to byte
48+
#define MASK_SIZE ((MAX_SERVICE_NUMBER / 8) + 2)
49+
4750
/*******************************************************************************
4851
* Variables
4952
******************************************************************************/

Robus/inc/context.h

+16
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
/*******************************************************************************
1616
* Definitions
1717
******************************************************************************/
18+
19+
typedef struct
20+
{
21+
network_state_t state;
22+
bool timeout_run;
23+
uint32_t timeout;
24+
} network_lock_t;
25+
1826
typedef struct
1927
{
2028

@@ -27,7 +35,15 @@ typedef struct
2735
// Low level service management
2836
ll_service_t ll_service_table[MAX_SERVICE_NUMBER]; /*!< Low level Service table. */
2937
uint16_t ll_service_number; /*!< Low level Service number. */
38+
uint8_t IDMask[MASK_SIZE];
39+
uint16_t ShiftMask;
40+
41+
// network management
42+
network_lock_t node_connected;
3043

44+
uint8_t filter_state;
45+
uint16_t filter_id;
46+
uint8_t verbose;
3147
} context_t;
3248

3349
/*******************************************************************************

Robus/inc/robus.h

+12
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,17 @@
88
#define _ROBUS_H_
99

1010
#include <stdint.h>
11+
#include <stdbool.h>
1112
#include "robus_struct.h"
1213
/*******************************************************************************
1314
* Definitions
1415
******************************************************************************/
16+
typedef enum
17+
{
18+
NETWORK_LINK_DOWN,
19+
NETWORK_LINK_CONNECTING,
20+
NETWORK_LINK_UP
21+
} network_state_t;
1522

1623
/*******************************************************************************
1724
* Variables
@@ -28,5 +35,10 @@ error_return_t Robus_SendMsg(ll_service_t *ll_service, msg_t *msg);
2835
uint16_t Robus_TopologyDetection(ll_service_t *ll_service);
2936
node_t *Robus_GetNode(void);
3037
void Robus_Flush(void);
38+
void Robus_ShiftMaskCalculation(uint16_t ID, uint16_t ServiceNumber);
39+
void Robus_SetNodeDetected(network_state_t);
40+
network_state_t Robus_IsNodeDetected(void);
41+
void Robus_SetFilterState(uint8_t state, ll_service_t *service);
42+
void Robus_SetVerboseMode(uint8_t mode);
3143

3244
#endif /* _ROBUS_H_ */

Robus/inc/robus_struct.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,13 @@ typedef enum
148148
{
149149
// protocol level command
150150
WRITE_NODE_ID, /*!< Get and save a new given node ID. */
151-
RESET_DETECTION, /*!< Reset detection*/
151+
START_DETECTION, /*!< Start a detection*/
152+
END_DETECTION, /*!< Detect the end of a detection*/
152153
SET_BAUDRATE, /*!< Set Robus baudrate*/
153154
ASSERT, /*!< Node Assert message (only broadcast with a source as a node */
154-
ROBUS_PROTOCOL_NB,
155+
156+
/*!< Compatibility area*/
157+
ROBUS_PROTOCOL_NB = 13,
155158
} robus_cmd_t;
156159

157160
typedef void (*RX_CB)(ll_service_t *ll_service, msg_t *msg);

Robus/inc/timestamp.h

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/******************************************************************************
2+
* @file timestamp feature
3+
* @brief time stamp data
4+
* @author Luos
5+
* @version 0.0.0
6+
******************************************************************************/
7+
#ifndef _TIMESTAMP_H_
8+
#define _TIMESTAMP_H_
9+
10+
#include "stdint.h"
11+
#include "stdbool.h"
12+
#include "config.h"
13+
#include "service_structs.h"
14+
/*******************************************************************************
15+
* Definitions
16+
******************************************************************************/
17+
typedef struct timestamp_token
18+
{
19+
uint64_t timestamp;
20+
void *target;
21+
struct timestamp_token *next;
22+
} timestamp_token_t;
23+
24+
/*******************************************************************************
25+
* Variables
26+
******************************************************************************/
27+
28+
/*******************************************************************************
29+
* Function
30+
******************************************************************************/
31+
32+
// functions to use on data to time stamp
33+
void Timestamp_Tag(timestamp_token_t *token, void *target);
34+
timestamp_token_t *Timestamp_GetToken(void *target);
35+
36+
// functions to use on luos messages
37+
bool Timestamp_IsTimestampMsg(msg_t *msg);
38+
void Timestamp_TagMsg(msg_t *msg);
39+
void Timestamp_EncodeMsg(msg_t *msg, void *target);
40+
void Timestamp_DecodeMsg(msg_t *msg, uint64_t *timestamp);
41+
42+
#endif /* _TIMESTAMP_H_ */

Robus/inc/transmission.h

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ typedef struct
3434
/*******************************************************************************
3535
* Function
3636
******************************************************************************/
37+
uint16_t ll_crc_compute(uint8_t *, uint16_t, uint16_t);
3738
void Transmit_SendAck(void);
3839
void Transmit_Process(void);
3940
void Transmit_End(void);

Robus/src/msg_alloc.c

+10
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,16 @@ void MsgAlloc_Init(memory_stats_t *memory_stats)
165165
{
166166
mem_stat = memory_stats;
167167
}
168+
ctx.ShiftMask = 0;
169+
for (uint16_t i = 0; i < MASK_SIZE; i++)
170+
{
171+
ctx.IDMask[i] = 0;
172+
}
173+
// Filter State
174+
ctx.filter_id = 0;
175+
ctx.filter_state = true;
176+
// Verbose
177+
ctx.verbose = LOCALHOST;
168178
// Reset have been made
169179
reset_needed = false;
170180
}

0 commit comments

Comments
 (0)