Skip to content

Commit

Permalink
Merge pull request #448 from Luos-io/fix/bugs
Browse files Browse the repository at this point in the history
Fix multiple bugs and improve Luos-engine V3
  • Loading branch information
nicolas-rabault authored Nov 7, 2023
2 parents 1fd2aaf + f0ba937 commit 668c4a8
Show file tree
Hide file tree
Showing 45 changed files with 15,604 additions and 2,758 deletions.
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<a href="https://luos.io"><img src="https://uploads-ssl.webflow.com/601a78a2b5d030260a40b7ad/603e0cc45afbb50963aa85f2_Gif%20noir%20rect.gif" alt="Luos logo" title="Luos" align="right" height="100" /></a>
<a href="https://luos.io"><img src="https://uploads-ssl.webflow.com/601a78a2b5d030260a40b7ad/603e0cc45afbb50963aa85f2_Gif%20noir%20rect.gif" alt="Luos logo" title="Luos-engine" align="right" height="100" /></a>

![](https://github.com/Luos-io/luos_engine/actions/workflows/build.yml/badge.svg)
[![](https://img.shields.io/github/license/Luos-io/luos_engine)](https://github.com/Luos-io/luos_engine/blob/master/LICENSE)
Expand All @@ -11,20 +11,28 @@

Version: 3.0.0

# Luos Technology
## The most for the developer​
Luos provides a simple way to think your hardware products as a group of independant features. You can easily manage and share your hardware products' features with your team, external developers, or with the community. Luos is an open-source lightweight library that can be used on any MCU, leading to free and fast multi-electronic-boards products development. Choosing Luos to design a product will help you to develop, debug, validate, monitor, and manage it from the cloud.
# Luos-engine: Empowering Developers
Luos-engine provides a simple and efficient way to manage your hardware products as a collection of independent software features. You can easily create and share these features with your team, external developers, or the wider community. Luos-engine is an open-source lightweight library that can be utilized on any microcontroller or computer, with any network, enabling free and fast development of multi-electronic-board connected products. Choosing Luos-engine for your product design empowers you to develop, debug, validate, monitor, and manage it from anywhere.

## The most for the community​
Most of the embedded developments are made from scratch. By using Luos, you will be able to capitalize on the development you, your company, or the Luos community already did. The re-usability of features encapsulated in Luos services will fasten the time your products reach the market and reassure the robustness and the universality of your applications.
## Benefits for the Community
Many embedded developments start from scratch. By using Luos-engine, you can leverage the work already done by you, your company, or the Luos community. The reusability of features encapsulated in Luos-engine services accelerates the time it takes for your products to reach the market while ensuring the robustness and universality of your applications.

* → Join the [Luos Discord server](http://discord.gg/luos)
* → Join the [Luos subreddit](https://www.reddit.com/r/Luos)
* Join the [Luos Discord server](http://discord.gg/luos) to connect with the community.

## Good practices with Luos
Luos proposes organized and effective development practices, guaranteeing development flexibility and evolutivity of your hardware product, from the idea to the maintenance of the industrialized product fleet.
## Best Practices with Luos-engine
Luos-engine promotes organized and effective development practices, ensuring the scalability, flexibility, and adaptability of your product from the initial idea to maintaining an industrialized fleet.

## Let's do this​

* → Try on your own with the [get started](https://www.luos.io/tutorials/get-started)
* → Consult the full [documentation](https://www.luos.io/docs)










10 changes: 5 additions & 5 deletions engine/IO/src/luos_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ static int LuosIO_StartTopologyDetection(service_t *service)
}

// Reinit our node id
Node_Get()->node_id = 0;
Node_Get()->node_id = DEFAULTID;
memset(luos_phy->nodes, 0, sizeof(luos_phy->nodes));
Node_SetState(LOCAL_DETECTION);
detect_state_machine = 0;
Expand Down Expand Up @@ -429,7 +429,7 @@ error_return_t LuosIO_ConsumeMsg(const msg_t *input)
{
// We didn't received the start detection message
// Reinit our node id
Node_Get()->node_id = 0;
Node_Get()->node_id = DEFAULTID;
memset(luos_phy->nodes, 0, sizeof(luos_phy->nodes));
// A phy have already been detected, so we can't reset everything
// Just reset LuosIO and Phy jobs.
Expand All @@ -445,12 +445,12 @@ error_return_t LuosIO_ConsumeMsg(const msg_t *input)
// Add this node id in the Luos phy filter allowing us to receive node messages
memset(luos_phy->nodes, 0, sizeof(luos_phy->nodes));
Phy_IndexSet(luos_phy->nodes, node_id);
// Also add all node before our node_id in the philter of the source phy
// Also add all node before our node_id in the philter of the source phy allowing next node to reach our parents.
port_t *source_port = Phy_GetTopologysource();
luos_phy_t *source_phy_ptr = Phy_GetPhyFromId(source_port->phy_id);
for (uint16_t i = 0; i < node_id; i++)
for (uint16_t id = 1; id < node_id; id++)
{
Phy_IndexSet(source_phy_ptr->nodes, i);
Phy_IndexSet(source_phy_ptr->nodes, id);
}
// Now we need to send back the input part of the connection data.
port_t *input_port = Phy_GetTopologysource();
Expand Down
22 changes: 13 additions & 9 deletions engine/IO/src/luos_phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ bool Phy_Need(luos_phy_t *phy_ptr, header_t *header)
}
else
{
// If the target is not the phy_ptr, we need to keep this message
// If the target is not for the receiving phy, we need to keep this message
return (!Phy_IndexFilter(phy_ptr->nodes, header->target) && (Node_Get()->node_id != 0));
}
break;
Expand Down Expand Up @@ -702,6 +702,7 @@ _CRITICAL void Phy_ValidMsg(luos_phy_t *phy_ptr)
// Now copy the data in the job
phy_ctx.io_job[my_job].timestamp = phy_ptr->rx_timestamp;
phy_ctx.io_job[my_job].phy_filter = phy_ptr->rx_phy_filter;
phy_ptr->rx_phy_filter = 0;
phy_ctx.io_job[my_job].size = phy_ptr->rx_size;

// Then reset the phy to receive the next message
Expand Down Expand Up @@ -795,15 +796,18 @@ _CRITICAL static void Phy_alloc(luos_phy_t *phy_ptr)
Phy_SetIrqState(true);
return;
}
// Compute the rx_phy_filter
phy_ptr->rx_phy_filter = Phy_ComputeTargets(phy_ptr, (header_t *)phy_ptr->rx_buffer_base);
if (phy_ptr->rx_phy_filter == 0)
{
// We probably have been reseted in the meantime. Just drop the message.
phy_ptr->rx_alloc_job = false;
phy_ptr->rx_keep = false;
Phy_SetIrqState(true);
return;
// Compute the rx_phy_filter
phy_ptr->rx_phy_filter = Phy_ComputeTargets(phy_ptr, (header_t *)phy_ptr->rx_buffer_base);
if (phy_ptr->rx_phy_filter == 0)
{
// We probably have been reseted in the meantime, or the message is corrupted. Just drop it.
phy_ptr->rx_alloc_job = false;
phy_ptr->rx_keep = false;
Phy_SetIrqState(true);
return;
}
}
Phy_SetIrqState(true);
Phy_SetIrqState(false);
Expand Down Expand Up @@ -1214,7 +1218,7 @@ inline bool Phy_IndexFilter(uint8_t *index, uint16_t id)
******************************************************************************/
inline void Phy_IndexSet(uint8_t *index, uint16_t id)
{
LUOS_ASSERT((index != NULL) && (id <= 0x0FFF));
LUOS_ASSERT((index != NULL) && (id <= 0x0FFF) && (id != 0));
uint8_t bit_index = id - 1; // Because 1 represent bit index 0.
index[bit_index / 8] |= 1 << (bit_index % 8);
}
Expand Down
14 changes: 7 additions & 7 deletions engine/core/inc/streaming.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ typedef struct
/*******************************************************************************
* Function
******************************************************************************/
streaming_channel_t Streaming_CreateChannel(const void *ring_buffer, uint16_t ring_buffer_size, uint8_t data_size);
streaming_channel_t Streaming_CreateChannel(const void *ring_buffer, uint32_t ring_buffer_size, uint8_t data_size);
void Streaming_ResetChannel(streaming_channel_t *stream);
uint16_t Streaming_PutSample(streaming_channel_t *stream, const void *data, uint16_t size);
uint16_t Streaming_GetSample(streaming_channel_t *stream, void *data, uint16_t size);
uint16_t Streaming_GetAvailableSampleNB(streaming_channel_t *stream);
uint16_t Streaming_GetAvailableSampleNBUntilEndBuffer(streaming_channel_t *stream);
uint16_t Streaming_AddAvailableSampleNB(streaming_channel_t *stream, uint16_t size);
uint16_t Streaming_RmvAvailableSampleNB(streaming_channel_t *stream, uint16_t size);
uint32_t Streaming_PutSample(streaming_channel_t *stream, const void *data, uint32_t size);
uint32_t Streaming_GetSample(streaming_channel_t *stream, void *data, uint32_t size);
uint32_t Streaming_GetAvailableSampleNB(streaming_channel_t *stream);
uint32_t Streaming_GetAvailableSampleNBUntilEndBuffer(streaming_channel_t *stream);
uint32_t Streaming_AddAvailableSampleNB(streaming_channel_t *stream, uint32_t size);
uint32_t Streaming_RmvAvailableSampleNB(streaming_channel_t *stream, uint32_t size);

#endif /* LUOS_H */
3 changes: 2 additions & 1 deletion engine/core/src/luos_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,11 @@ void Luos_SendData(service_t *service, msg_t *msg, void *bin_data, uint16_t size

// Send message
uint32_t tickstart = Luos_GetSystick();

while (Luos_SendMsg(service, msg) == FAILED)
{
// No more memory space available
// 500ms of timeout after start trying to load our data in memory. Perhaps the buffer is full of RX messages try to increate the buffer size.
// 500ms of timeout after start trying to load our data in memory. Perhaps the buffer is full of RX messages try to increase the buffer size.
LUOS_ASSERT(((volatile uint32_t)Luos_GetSystick() - tickstart) < 500);
}

Expand Down
2 changes: 1 addition & 1 deletion engine/core/src/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void Node_Init(void)
// set node_info value
node_ctx.info.node_info = 0;
#ifdef NO_RTB
node_ctx.node_info |= 1 << 0;
node_ctx.info.node_info |= 1 << 0;
#endif
Node_SetState(NO_DETECTION);
node_ctx.wait_id = false;
Expand Down
Loading

0 comments on commit 668c4a8

Please sign in to comment.