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

Any kind of network support, fix #428 #435

Merged
merged 150 commits into from
Sep 19, 2023
Merged
Changes from 1 commit
Commits
Show all changes
150 commits
Select commit Hold shift + click to select a range
edcda13
Add the IO folder and source compilation.
nicolas-rabault Apr 3, 2023
c03ace3
Move msg_alloc from Robus to IO
nicolas-rabault Mar 23, 2023
090de1a
Move topic pub/sub management from Robus to IO
nicolas-rabault Mar 23, 2023
525651c
Create filter and luos_io files
Salem-Tho Jan 5, 2023
7496508
Add an engine level configuration file
Salem-Tho Jan 5, 2023
f5fcbc2
Rename and move the robus `config.h` file into `robus_config.h`
nicolas-rabault Mar 23, 2023
5ee1459
Move struct and configurations from Robus to IO
nicolas-rabault Mar 23, 2023
a1ebc8c
Move public timestamp functions into public Luos_engine.h
nicolas-rabault Mar 30, 2023
48d530e
Add an error in case of inclusion of luos.h
nicolas-rabault Mar 23, 2023
f752b60
Clean luos_engine.h and remove unused `Luos_SetExternId`
nicolas-rabault Mar 23, 2023
be861f9
Group all topic things on a pub_sub.c file on engine/core
nicolas-rabault Mar 28, 2023
fbba385
Group all streaming functions on streaming.c/.h
nicolas-rabault Mar 31, 2023
35ab161
Update Timestamp functions API
nicolas-rabault Mar 30, 2023
31b3cdd
Move general_stats_t from luos_engine.h to service_structs.h
nicolas-rabault Mar 28, 2023
7704b7a
Remove useless node_state_t struct
nicolas-rabault Mar 28, 2023
2b3338c
Remove dynamic baudrate management
nicolas-rabault Mar 28, 2023
0053566
Group all node functions on a node.c.h
nicolas-rabault Mar 31, 2023
c6bf09c
Create a script to compile all examples as fast as possible
nicolas-rabault Mar 31, 2023
f44d0bc
Make inspector use local Pipe during compilation
nicolas-rabault Mar 31, 2023
b45d472
Remove filters disableabilty and verbose mode.
nicolas-rabault Mar 31, 2023
938eb48
Group all filter functions in a filter file
nicolas-rabault Mar 31, 2023
9d6e04f
Remove all context usage on msg_alloc
nicolas-rabault Apr 3, 2023
7a41ddd
Create Service files
nicolas-rabault Apr 4, 2023
49619b9
Group all services function into service file.
nicolas-rabault Apr 6, 2023
358549d
Update .gitignore
nicolas-rabault Apr 4, 2023
ae237a6
Remove useless Luos_EmptyNode() function
nicolas-rabault Apr 4, 2023
8147a44
Small code improvement
nicolas-rabault Apr 4, 2023
664d284
Add type filtering on filter file
nicolas-rabault Apr 4, 2023
6812c05
Remove the redundant ll_service_number from robus context
nicolas-rabault Apr 4, 2023
000575a
Remove useless baudrate variable
nicolas-rabault Apr 4, 2023
07b8b3e
Move ll_service_t into Service_t, only one struct remain now.
nicolas-rabault Apr 5, 2023
9e1e024
Move robus init and loop things into IO
nicolas-rabault Apr 6, 2023
8944f80
Move topology management to LuosIO
nicolas-rabault Apr 6, 2023
7534573
Create a phy.h/c files defining phy structs
nicolas-rabault Apr 6, 2023
ab2035e
Move back rx and tx init into robus
nicolas-rabault Apr 6, 2023
dce8765
Manage phy instantiation
nicolas-rabault Apr 6, 2023
e3825c7
Move reception filtering into filter except for Robus exceptions
nicolas-rabault Apr 11, 2023
e4b83ff
Fix timestamp msg reception computation
nicolas-rabault Apr 11, 2023
f7439b1
Reshape reception and almost completely shortcut msg_tasks
nicolas-rabault Apr 12, 2023
b245d60
Assert if buffer full only on RX. TX can wait to load the buffer agai…
nicolas-rabault Apr 14, 2023
43a42b5
Fix addressing generation at detection start.
nicolas-rabault Apr 17, 2023
5f118f3
Fix double detection process occurring at the same time, fix #229
nicolas-rabault Apr 17, 2023
083b3b6
Fix collision management
nicolas-rabault Apr 18, 2023
5619724
[Gate] Add a small check if a service is excluded during detection.
nicolas-rabault Apr 18, 2023
b279fdf
Remove verbose mode
nicolas-rabault Apr 17, 2023
107c9a2
Do not allow RX dropping during reception
nicolas-rabault Apr 18, 2023
2d2ae1d
Fix data dropping occurring during re-init
nicolas-rabault Apr 18, 2023
a0ec64c
Fix multi-node detection
nicolas-rabault Apr 19, 2023
5c1a2c5
RX CRC optimization
nicolas-rabault Apr 19, 2023
2f3a122
Improve RX/TX comment on Robus
nicolas-rabault Apr 19, 2023
aaa6e43
Remove useless compiled files on SAMD21XPLAINED example
nicolas-rabault Apr 26, 2023
1e817d2
Move CRC_SIZE definition from Alloc to robus config
nicolas-rabault Apr 19, 2023
b9144c2
Engine TX is passed to LuosIO RX normal process
nicolas-rabault Apr 18, 2023
6a8f4c7
Improve unit tests organization
nicolas-rabault May 3, 2023
efd61c8
Add filter unit test
nicolas-rabault May 3, 2023
2610c1c
Add luos_phy unit test
nicolas-rabault May 3, 2023
1863887
Add luos_io unit test
nicolas-rabault May 5, 2023
a34d44d
Improve UNIT_TEST_RUN macro to correctly manage function name passing…
nicolas-rabault May 5, 2023
24753d3
Improve pub_sub unit tests
nicolas-rabault May 5, 2023
04aa844
Remove useless main.h Od tests files
nicolas-rabault May 29, 2023
fafe882
Improve timestamp unit tests
nicolas-rabault May 31, 2023
2062564
Improve routing table unit tests
nicolas-rabault May 31, 2023
df9d4a3
Add streaming unit test
nicolas-rabault May 31, 2023
1953b65
Add service unit test
nicolas-rabault Jun 1, 2023
02b1f2a
Add node unit test
nicolas-rabault Jun 1, 2023
b157634
Remove unused Luos_SetFilterState function
nicolas-rabault Jun 1, 2023
91cbec5
Fix some warnings
nicolas-rabault Jun 5, 2023
da5e7be
Move compilation error using `example_build.py` to err.log file
nicolas-rabault Jun 5, 2023
9c053e4
Fix some windows unit_test compilation optimization mistakes
nicolas-rabault Jun 6, 2023
c82d9c6
Improve luos_engine unit test
nicolas-rabault Jun 6, 2023
6405a1b
Exclude some test for windows because it fail to execute it
nicolas-rabault Jun 6, 2023
e9910d0
Enable test coverage report
nicolas-rabault Jun 5, 2023
51f8a9f
Minor code cleanup.
nicolas-rabault Jun 9, 2023
15819d3
Fix a missing node init in case of detection start message reception
nicolas-rabault Jun 9, 2023
2566b11
[Gate]Update data_manager to avoid to avoid hazardous function access…
nicolas-rabault Jun 9, 2023
a435647
Secure job removal
nicolas-rabault Jun 9, 2023
5eebf1d
Fix a memory leak in case of dead target
nicolas-rabault Jun 9, 2023
4399fb0
Separate allocation and referencing of the allocation avoiding memory…
nicolas-rabault Jun 9, 2023
89fc79d
Move data_ptr in alloc if there is no space for at least a header.
nicolas-rabault Jun 12, 2023
ba1cce5
Secure job.phy_data initialization avoiding data-race during the crea…
nicolas-rabault Jun 12, 2023
eb234a4
Avoid potential job removal when system have been reseted during a tr…
nicolas-rabault Jun 12, 2023
8b3d34a
Fix phy_data protection
nicolas-rabault Jun 12, 2023
4621de7
Avoid assert in case of corrupted message reception. Properly trash it.
nicolas-rabault Jun 12, 2023
5032229
Fix daisy chained detection infinite loop due to msg_dispatch recursi…
nicolas-rabault Jun 12, 2023
b63d8c3
!fix corrupted messages
nicolas-rabault Jun 12, 2023
c174d48
Modify job management to avoid any job pointer movement allowing to s…
nicolas-rabault Jun 13, 2023
2000d4b
Clear auto-refresh when we clear service IDs.
nicolas-rabault Jun 13, 2023
4323a23
Modify aloc slots management avoiding pointer movement and limiting I…
nicolas-rabault Jun 15, 2023
89ba9a0
Secure detection start occuring durring a transmission
nicolas-rabault Jun 16, 2023
db15778
Secure job and alloc slot management from dataraces and reduce IRQ of…
nicolas-rabault Jun 16, 2023
db96274
bootloader cleanup
nicolas-rabault Jun 16, 2023
ae73554
Separate Robus and Update detection allowing up to 254 phy with 254 p…
nicolas-rabault Jun 20, 2023
713ff72
Simplify bootloader to make it a standard service and be less intrica…
nicolas-rabault Jun 26, 2023
dbf29d9
Rename `bootloader_core` into `luos_bootloader`
nicolas-rabault Jun 26, 2023
baaa76a
Fix some typo
nicolas-rabault Jul 4, 2023
5f7044a
Change IRQ management allowing phy to reference specific IRQ manageme…
nicolas-rabault Jul 4, 2023
5973869
Make Robus an independant package
nicolas-rabault Jul 4, 2023
dc6f258
Modify master detection to be non-blocking. This allows networks to m…
nicolas-rabault Jul 5, 2023
8c7a6de
Add a Pure Arduino Luos HAL
nicolas-rabault Jul 10, 2023
ca15742
Secure Pipe using Serial for STM32G4 clock configuration
nicolas-rabault Jul 13, 2023
c1f8950
Optimize freeRTOS example to fit in RAM
nicolas-rabault Jul 17, 2023
0718163
Create a serial_network
nicolas-rabault Jul 4, 2023
c3ddb9b
OK serial test with Native gate and L0 button
nicolas-rabault Jul 7, 2023
5a721da
OK serial test with native gate and G474 and G431 button
nicolas-rabault Jul 11, 2023
d60e27e
OK serial test with Native gate and STM32L4 button
nicolas-rabault Jul 11, 2023
60f86af
OK serial test with Native gate and STM32F4 button
nicolas-rabault Jul 11, 2023
418b417
OK serial test with Native gate and Arduino button and led, fix #440
nicolas-rabault Jul 10, 2023
c4c7094
Improve Luos configuration parameters
nicolas-rabault Jul 18, 2023
e74f10a
Hide uselees routing function to users
nicolas-rabault Jul 18, 2023
80100f4
Improve Robus configuration flags naming
nicolas-rabault Jul 19, 2023
9815418
Add a serial_hal_config.h file
nicolas-rabault Jul 19, 2023
6ed4ed2
Improve luos_phy.h public interface and adapt robus and Serial
nicolas-rabault Jul 19, 2023
54d2280
!fix multi-phy
nicolas-rabault Aug 28, 2023
2383731
Improve C++ compatibility by making it natively compilable in a C++ env
nicolas-rabault Aug 28, 2023
1a0bf00
Remove networks from coverage, networks are very difficult to unit te…
nicolas-rabault Aug 2, 2023
085e496
Fix format
nicolas-rabault Aug 2, 2023
07c4998
Remove Inspector because we don't maintain it anymore.
nicolas-rabault Aug 3, 2023
9bac6bf
Make a clean BAUDRATE configuration for networks
nicolas-rabault Aug 28, 2023
8d2b30e
Improve native timestamping precision
nicolas-rabault Aug 4, 2023
c641f20
Enable multi-phy capabilities
nicolas-rabault Aug 11, 2023
45d11d1
Add a print for native assert
nicolas-rabault Aug 25, 2023
288875b
Add a trace print on Gate segfault to catch it one day perhaps.
nicolas-rabault Aug 25, 2023
b4034ba
Improve ST Serial reception by removing RX IRQ and improve function n…
nicolas-rabault Aug 25, 2023
1dae135
Remove telemetry
nicolas-rabault Aug 25, 2023
db34245
Manage multi-message in one Serial burst
nicolas-rabault Aug 25, 2023
a9af943
Allow synchronized nodes to manage timestamping without any different…
nicolas-rabault Aug 25, 2023
e25326c
[OD] rename the `_private` var into `raw` to explicitely allow users …
nicolas-rabault Aug 28, 2023
1e96760
Fix some OD warnings on `Controller_motor` example
nicolas-rabault Aug 28, 2023
82001f8
Add a user_context pointer on services and apply it on DXL example
nicolas-rabault Aug 28, 2023
1802b42
Fix Serial HAL for Native on Linux and windows, fix #442
nicolas-rabault Aug 29, 2023
f0de043
Improve compilation messaging presentation
nicolas-rabault Aug 31, 2023
38bc651
Remove some useless reset on detetion and increase some timing allowi…
nicolas-rabault Aug 31, 2023
e98e990
Fix the detection flag init
nicolas-rabault Aug 31, 2023
44c03ff
Fix and remove deprecated unit test
nicolas-rabault Aug 31, 2023
3174317
Fix some code format
nicolas-rabault Aug 31, 2023
43c9a08
Fix a typo
nicolas-rabault Sep 5, 2023
c152eaa
Secure Robus initialization by setting Callback before enabling the h…
nicolas-rabault Sep 5, 2023
7b83495
[Gate] Allow user to put custom conversion on project lib
nicolas-rabault Sep 5, 2023
c36ddac
Fix assert infinite re-entrance on Gate
nicolas-rabault Sep 11, 2023
bf0ac48
Avoid asserts appening sometime during the reset_detection
nicolas-rabault Sep 11, 2023
31943f2
Clean Native Serial HAL
nicolas-rabault Sep 11, 2023
85c0800
Secure potential RX segfault if the RX buffer is smaller than the rec…
nicolas-rabault Sep 11, 2023
6f958b4
Fix Gate compilation on windows
nicolas-rabault Sep 12, 2023
7fb6737
Fix a small datarace on RX
nicolas-rabault Sep 12, 2023
b32fa7c
Improve serial Loop on ST MCU
nicolas-rabault Sep 12, 2023
3c3e8ce
Fix Serial
nicolas-rabault Sep 12, 2023
23428f6
Fix Native Gate node_config
nicolas-rabault Sep 12, 2023
25f9ee3
Fix a Robus reception byte count mistake making big messages potentia…
nicolas-rabault Sep 14, 2023
a74df88
[SERIAL] Fix STM HAL DMA received size computation datarace in case o…
nicolas-rabault Sep 14, 2023
bd5778f
[SERIAL] Secure messy RX interpretation
nicolas-rabault Sep 14, 2023
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
Prev Previous commit
Next Next commit
Improve luos_phy.h public interface and adapt robus and Serial
  • Loading branch information
nicolas-rabault committed Sep 18, 2023
commit 6ed4ed211494f575ef10f202868da02be917daaf
3 changes: 2 additions & 1 deletion engine/IO/inc/_luos_phy.h
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ void Phy_ResetAll(void);
bool Phy_Busy(void);
void Phy_Loop(void);
luos_phy_t *Phy_Get(uint8_t id, JOB_CB job_cb, RUN_TOPO run_topo, RESET_PHY reset_phy);
error_return_t Phy_FindNextNode(void); // Use it to find the next node as a master.
error_return_t Phy_FindNextNode(void); // Use it to find the next node as a master.
phy_job_t *Phy_GetNextJob(luos_phy_t *phy_ptr, phy_job_t *job); // Use it to get the next job to send.

#endif /* _PRIVATE_LUOS_PHY_H_ */
20 changes: 11 additions & 9 deletions engine/IO/inc/luos_phy.h
Original file line number Diff line number Diff line change
@@ -27,25 +27,27 @@ void Phy_SetIrqStateFunciton(IRQ_STATE irq_state); // Use it to reference your p
void Phy_SetIrqState(bool state); // Use it to globally enable/disable all the phy irq.

// Phy creation
luos_phy_t *Phy_Create(JOB_CB phy_cb, RUN_TOPO run_topo, RESET_PHY reset_phy); // Use it to reference your phy to Luos.
luos_phy_t *Phy_Create(JOB_CB job_cb, RUN_TOPO run_topo, RESET_PHY reset_phy); // Use it to reference your phy to Luos.

// Topology management
void Phy_FindNextNodeJob(void); // Use it to find the next node that need to be detected accross phys.
void Phy_Topologysource(luos_phy_t *phy_ptr, uint8_t port_id); // The phy will call this function when a new node is detected on a specific port.
void Phy_TopologyNext(void); // Use it to find the next node that need to be detected accross phys.
void Phy_TopologySource(luos_phy_t *phy_ptr, uint8_t port_id); // The phy will call this function when a new node is detected on a specific port.
void Phy_TopologyDone(luos_phy_t *phy_ptr); // The phy will call this function when all its port detection are done.

// Rx management
void Phy_ComputeHeader(luos_phy_t *phy_ptr); // After receiving the first 7 bytes (the header) call this function to compute how you should manage the incoming message.
void Phy_ValidMsg(luos_phy_t *phy_ptr); // After receiving as much valid bytes as phy_ptr.rx_size, call this function to validate the message.
void Phy_ResetMsg(luos_phy_t *phy_ptr); // Call this function to reset the rx process.

// Tx management
time_luos_t Phy_ComputeTimestamp(phy_job_t *job);
uint16_t Phy_GetNodeId(void);
time_luos_t Phy_ComputeMsgTimestamp(phy_job_t *job); // Use it to compute the timestamp of the message to send.
time_luos_t Phy_GetTimestamp(void); // Use it to get the current timestamp.
uint16_t Phy_GetNodeId(void); // Use it to get your current node id. (This can be used to compute priority or controled latency avoiding infinite collision condition)

// Job management
void Phy_DeadTargetSpotted(luos_phy_t *phy_ptr, phy_job_t *job); // If some messages failed to be sent, call this function to consider the target as dead
phy_job_t *Phy_GetJob(luos_phy_t *phy_ptr); // Use it to get the first job to send.
phy_job_t *Phy_GetNextJob(luos_phy_t *phy_ptr, phy_job_t *job); // Use it to get the next job to send.
void Phy_RmJob(luos_phy_t *phy_ptr, phy_job_t *job); // Use it to remove a job from your phy job list when it's done.
void Phy_FailedJob(luos_phy_t *phy_ptr, phy_job_t *job); // If some messages failed to be sent, call this function to consider the target as dead
phy_job_t *Phy_GetJob(luos_phy_t *phy_ptr); // Use it to get the first job to send.
void Phy_RmJob(luos_phy_t *phy_ptr, phy_job_t *job); // Use it to remove a job from your phy job list when it's done.
uint16_t Phy_GetJobNumber(luos_phy_t *phy_ptr); // Use it to get the number of job to send.

#endif /* _LUOS_PHY_H_ */
5 changes: 3 additions & 2 deletions engine/IO/inc/struct_phy.h
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
#include <stdint.h>
#include <stdbool.h>
#include "struct_luos.h"
#include "time_luos.h"

/*******************************************************************************
* Definitions
@@ -46,8 +47,8 @@ typedef uint8_t phy_target_t;
typedef struct luos_phy_t
{
// *************** RX information ***************
volatile int64_t rx_timestamp; // Timestamp of the last received message. We will use it to compute the date based on received latency.
uint8_t *rx_buffer_base; // Pointer to the base of the buffer where we will store the begining of received data.
volatile time_luos_t rx_timestamp; // Timestamp of the last received message. We will use it to compute the date based on received latency.
uint8_t *rx_buffer_base; // Pointer to the base of the buffer where we will store the begining of received data.
union
{
volatile uint8_t *rx_data; // Pointer to write received bytes.
2 changes: 1 addition & 1 deletion engine/IO/src/luos_io.c
Original file line number Diff line number Diff line change
@@ -445,7 +445,7 @@ error_return_t LuosIO_ConsumeMsg(const msg_t *input)
Luos_SendMsg(service, &output_msg);
// This message can't be send directly to avoid dispatch re-entrance issue.
// To be able to send this message then run the detection of the other nodes we need to make it later on the LuosIO_Loop, so we put a flag for it.
Phy_FindNextNodeJob();
Phy_TopologyNext();
// This message have been consumed
return SUCCEED;
break;
55 changes: 47 additions & 8 deletions engine/IO/src/luos_phy.c
Original file line number Diff line number Diff line change
@@ -203,7 +203,9 @@ void Phy_Loop(void)

/******************************************************************************
* @brief Instanciate a physical layer
* @param phy_cb callback to call when we want to transmit a message
* @param job_cb callback to call when we want to transmit a message
* @param run_topo callback to call when we want to run the topology detection
* @param reset_phy callback to call when we want to reset the phy
* @return None
******************************************************************************/
luos_phy_t *Phy_Create(JOB_CB job_cb, RUN_TOPO run_topo, RESET_PHY reset_phy)
@@ -259,7 +261,7 @@ void Phy_SetIrqState(bool state)
* @brief save a flag allowing to run a new discovering outside of IRQ (because this function is very long and can't be run in IRQ)
* @return None
******************************************************************************/
_CRITICAL void Phy_FindNextNodeJob(void)
_CRITICAL void Phy_TopologyNext(void)
{
phy_ctx.find_next_node_job = true;
}
@@ -341,7 +343,7 @@ error_return_t Phy_FindNextNode(void)
* @param port_id id of the port detected in the phy
* @return None
******************************************************************************/
void Phy_Topologysource(luos_phy_t *phy_ptr, uint8_t port_id)
void Phy_TopologySource(luos_phy_t *phy_ptr, uint8_t port_id)
{
LUOS_ASSERT((phy_ptr != NULL)
&& (port_id < 0xFF));
@@ -374,7 +376,9 @@ port_t *Phy_GetTopologysource(void)
/******************************************************************************
* @brief return the local physical layer (only used by LuosIO, this function is private)
* @param id of the phy we want
* @param phy_cb callback to call when we want to transmit a message
* @param job_cb callback to call when we want to transmit a message
* @param run_topo callback to call when we want to run a topology detection
* @param reset_phy callback to call when we want to reset the phy
* @return None
******************************************************************************/
luos_phy_t *Phy_Get(uint8_t id, JOB_CB job_cb, RUN_TOPO run_topo, RESET_PHY reset_phy)
@@ -466,7 +470,7 @@ _CRITICAL void Phy_ValidMsg(luos_phy_t *phy_ptr)
uint16_t my_job = phy_ctx.io_job_nb++;
Phy_SetIrqState(true);
// Now copy the data in the job
phy_ctx.io_job[my_job].timestamp = phy_ptr->rx_timestamp;
phy_ctx.io_job[my_job].timestamp = (uint64_t)TimeOD_TimeTo_ns(phy_ptr->rx_timestamp);
phy_ctx.io_job[my_job].alloc_msg = (msg_t *)phy_ptr->rx_data;
phy_ctx.io_job[my_job].phy_filter = phy_ptr->rx_phy_filter;
phy_ctx.io_job[my_job].size = phy_ptr->rx_size;
@@ -477,17 +481,41 @@ _CRITICAL void Phy_ValidMsg(luos_phy_t *phy_ptr)
}
}

/******************************************************************************
* @brief Consider the message as failed and reset the phy
* @param phy_ptr Pointer to the phy concerned by the allocation
* @return None
******************************************************************************/
_CRITICAL void Phy_ResetMsg(luos_phy_t *phy_ptr)
{
phy_ptr->received_data = 0;
phy_ptr->rx_size = 0;
phy_ptr->rx_keep = true;
phy_ptr->rx_alloc_job = false;
phy_ptr->rx_data = phy_ptr->rx_buffer_base;
}

/******************************************************************************
* @brief Compute the timestamp to send with the message
* @param job Pointer to the job concerned by this message
* @return None
******************************************************************************/
time_luos_t Phy_ComputeTimestamp(phy_job_t *job)
time_luos_t Phy_ComputeMsgTimestamp(phy_job_t *job)
{
LUOS_ASSERT((job != NULL) && (job->msg_pt != NULL) && (job->timestamp == true));
return Timestamp_ConvertToLatency(job->msg_pt);
}

/******************************************************************************
* @brief Get the current timestamp
* @param None
* @return Timestamp value
******************************************************************************/
_CRITICAL time_luos_t Phy_GetTimestamp(void)
{
return TimeOD_TimeFrom_ns((double)LuosHAL_GetTimestamp());
}

/******************************************************************************
* @brief return the node id
* @return Node ID value
@@ -625,7 +653,7 @@ static void Phy_Dispatch(void)
* @param job pointer to the job that failed.
* @return None
******************************************************************************/
_CRITICAL void Phy_DeadTargetSpotted(luos_phy_t *phy_ptr, phy_job_t *job)
_CRITICAL void Phy_FailedJob(luos_phy_t *phy_ptr, phy_job_t *job)
{
// A phy failed to send a message, we need to be sure that our node don't try to contact this target again.
LUOS_ASSERT((job != NULL)
@@ -734,7 +762,7 @@ static phy_job_t *Phy_AddJob(luos_phy_t *phy_ptr, phy_job_t *phy_job)
* @param phy_ptr Phy to get the job from
* @return Job pointer
******************************************************************************/
_CRITICAL inline phy_job_t *Phy_GetJob(luos_phy_t *phy_ptr)
inline phy_job_t *Phy_GetJob(luos_phy_t *phy_ptr)
{
LUOS_ASSERT(phy_ptr != NULL);
if (phy_ptr->job_nb == 0)
@@ -841,6 +869,17 @@ _CRITICAL void Phy_RmJob(luos_phy_t *phy_ptr, phy_job_t *job)
}
}

/******************************************************************************
* @brief Get the number of job in the phy queue
* @param phy_ptr Phy to get the job number from
* @return None
******************************************************************************/
inline uint16_t Phy_GetJobNumber(luos_phy_t *phy_ptr)
{
LUOS_ASSERT(phy_ptr != NULL);
return phy_ptr->job_nb;
}

/******************************************************************************
* @brief define is there is something waiting to be sent or not
* @return Succeed if nothing is waiting to be sent
6 changes: 3 additions & 3 deletions network/robus_network/src/port_manager.c
Original file line number Diff line number Diff line change
@@ -90,7 +90,7 @@ _CRITICAL void PortMng_PtpHandler(uint8_t PortNbr)
PortMng_Reset();
}
// Ask Luos_phy to find another node
Phy_FindNextNodeJob();
Phy_TopologyNext();
}
else if (Port_ExpectedState == POKE)
{
@@ -102,7 +102,7 @@ _CRITICAL void PortMng_PtpHandler(uint8_t PortNbr)
ctx.port.activ = PortNbr;
// This port become the topology source of this node
// Notify luos_phy about it
Phy_Topologysource(Robus_GetPhy(), PortNbr);
Phy_TopologySource(Robus_GetPhy(), PortNbr);
}
}
/******************************************************************************
@@ -143,7 +143,7 @@ uint8_t PortMng_PokePort(uint8_t PortNbr)

/******************************************************************************
* @brief being poked so poke next node to
* @param None
* @param portId pointer to the port id
* @return true if a port have been poke else false
******************************************************************************/
error_return_t PortMng_PokeNextPort(uint8_t *portId)
12 changes: 4 additions & 8 deletions network/robus_network/src/reception.c
Original file line number Diff line number Diff line change
@@ -76,12 +76,11 @@ uint16_t crc_val = 0; // CRC value
void Recep_Init(luos_phy_t *phy_robus)
{
LUOS_ASSERT(phy_robus != NULL);
LUOS_ASSERT(phy_robus->rx_alloc_job == false);
// Initialize the reception state machine
ctx.rx.status.unmap = 0;
ctx.rx.callback = Recep_GetHeader;
ctx.rx.status.identifier = 0xF;
phy_robus->rx_timestamp = 0;
phy_robus->rx_timestamp = TimeOD_TimeFrom_s(0.0);
phy_robus->rx_buffer_base = data_rx;
phy_robus->rx_data = data_rx;
phy_robus->rx_keep = true;
@@ -104,7 +103,7 @@ _CRITICAL void Recep_GetHeader(luos_phy_t *phy_robus, volatile uint8_t *data)
// When we catch the first byte we timestamp the msg
// We remove the time of the first byte to get the exact reception date.
// 1 byte is 10 bits and we convert it to nanoseconds
phy_robus->rx_timestamp = LuosHAL_GetTimestamp() - ((uint32_t)10 * (uint32_t)1000000000 / (uint32_t)DEFAULTBAUDRATE);
phy_robus->rx_timestamp = TimeOD_TimeFrom_ns(TimeOD_TimeTo_ns(Phy_GetTimestamp()) - ((uint32_t)10 * (uint32_t)1000000000 / (uint32_t)DEFAULTBAUDRATE));

// Declare Robus as busy
ctx.tx.lock = true;
@@ -281,11 +280,8 @@ _CRITICAL void Recep_Timeout(void)
******************************************************************************/
_CRITICAL void Recep_Reset(void)
{
luos_phy_t *phy_robus = Robus_GetPhy();
phy_robus->received_data = 0;
phy_robus->rx_size = 0;
phy_robus->rx_keep = true;
phy_robus->rx_alloc_job = false;
luos_phy_t *phy_robus = Robus_GetPhy();
Phy_ResetMsg(phy_robus);
crc_val = 0xFFFF;
ctx.rx.status.rx_framing_error = false;
ctx.rx.status.rx_error = false;
3 changes: 2 additions & 1 deletion network/robus_network/src/robus.c
Original file line number Diff line number Diff line change
@@ -112,7 +112,8 @@ void Robus_Reset(luos_phy_t *phy_ptr)

/******************************************************************************
* @brief Find the next neighbour on this phy
* @param None
* @param phy_ptr
* @param portId pointer to the portId of the next node
* @return error_return_t
******************************************************************************/
error_return_t Robus_RunTopology(luos_phy_t *phy_ptr, uint8_t *portId)
6 changes: 3 additions & 3 deletions network/robus_network/src/transmission.c
Original file line number Diff line number Diff line change
@@ -139,7 +139,7 @@ _CRITICAL void Transmit_Process()
if (nbrRetry >= NBR_RETRY)
{
// We failed to transmit this message. We can't allow it, there is an issue on this target.
Phy_DeadTargetSpotted(robus_phy, job);
Phy_FailedJob(robus_phy, job);
nbrRetry = 0;
ctx.tx.collision = false;
// Try to get a new job
@@ -187,7 +187,7 @@ _CRITICAL void Transmit_Process()
{

// Convert date to a sendable timestamp and put it on the encapsulation
jobEncaps->timestamp = Phy_ComputeTimestamp(job);
jobEncaps->timestamp = Phy_ComputeMsgTimestamp(job);

jobEncaps->timestamped_crc = ll_crc_compute(jobEncaps->unmaped, sizeof(time_luos_t), crc_val);
jobEncaps->size = sizeof(time_luos_t) + CRC_SIZE;
@@ -243,7 +243,7 @@ _CRITICAL void Transmit_End(void)
luos_phy_t *robus_phy = Robus_GetPhy();
phy_job_t *job = Phy_GetJob(robus_phy);
// We may had a reset during this transmission, so we need to check if we still have something to transmit
if (robus_phy->job_nb > 0)
if (Phy_GetJobNumber(robus_phy) > 0)
{
job->phy_data = 0;
Phy_RmJob(robus_phy, job);
8 changes: 5 additions & 3 deletions network/serial_network/src/serial_network.c
Original file line number Diff line number Diff line change
@@ -82,7 +82,8 @@ void Serial_Init(void)
Serial_Reset(phy_serial);
SerialHAL_Init(RX_data, SERIAL_RX_BUFFER_SIZE);

phy_serial->rx_timestamp = 0;
phy_serial->rx_timestamp = TimeOD_TimeFrom_s(0.0);
;
phy_serial->rx_buffer_base = RX_data;
phy_serial->rx_data = RX_data; // In our case we don't need to use this pointer because we use DMA to receive complete messages in one time.
phy_serial->rx_keep = true;
@@ -223,7 +224,7 @@ void Serial_Loop(void)
// We receive this ping from a master node
// This port become the topology source of this node
// Notify luos_phy about it
Phy_Topologysource(phy_serial, SerialHAL_GetPort());
Phy_TopologySource(phy_serial, SerialHAL_GetPort());
// The next ping we send will be a deping
next_ping_is_deping = true;
}
@@ -302,7 +303,7 @@ _CRITICAL void Serial_TransmissionEnd(void)
sending = false;
// We transmitted this message, we can remove it then send another one
// We may had a reset during this transmission, so we need to check if we still have something to transmit
if (phy_serial->job_nb > 0)
if (Phy_GetJobNumber(phy_serial) > 0)
{
phy_job_t *job = Phy_GetJob(phy_serial);
job->phy_data = 0;
@@ -377,6 +378,7 @@ _CRITICAL void Serial_ReceptionAdd(uint8_t *data, uint32_t size)
memcpy(RX_data, data + copy_size, size - copy_size);
}
rx_size += size;
LUOS_ASSERT(rx_size < sizeof(RX_data));
if ((wait_reception == true) && (size >= sizeof(SerialHeader_t) + 1))
{
// We received the answer of a topology ping, just indicate that we receive it
Loading