Skip to content

Commit

Permalink
Fix: add a function to sized luos_sendstreaming
Browse files Browse the repository at this point in the history
  • Loading branch information
Salem-Tho committed Jan 13, 2022
1 parent 3e48187 commit 052ca6c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions inc/luos.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ error_return_t Luos_ReadFromService(service_t *service, int16_t id, msg_t **retu
void Luos_SendData(service_t *service, msg_t *msg, void *bin_data, uint16_t size);
error_return_t Luos_ReceiveData(service_t *service, msg_t *msg, void *bin_data);
void Luos_SendStreaming(service_t *service, msg_t *msg, streaming_channel_t *stream);
void Luos_SendStreamingSize(service_t *service, msg_t *msg, streaming_channel_t *stream, uint32_t max_size);
error_return_t Luos_ReceiveStreaming(service_t *service, msg_t *msg, streaming_channel_t *stream);
void Luos_SendBaudrate(service_t *service, uint32_t baudrate);
void Luos_SetExternId(service_t *service, target_mode_t target_mode, uint16_t target, uint16_t newid);
Expand Down
21 changes: 19 additions & 2 deletions src/luos.c
Original file line number Diff line number Diff line change
Expand Up @@ -809,8 +809,25 @@ error_return_t Luos_ReceiveData(service_t *service, msg_t *msg, void *bin_data)
void Luos_SendStreaming(service_t *service, msg_t *msg, streaming_channel_t *stream)
{
// Compute number of message needed to send available datas on ring buffer
int msg_number = 1;
int data_size = Stream_GetAvailableSampleNB(stream);
Luos_SendStreamingSize(service, msg, stream, Stream_GetAvailableSampleNB(stream));
}
/******************************************************************************
* @brief Send a number of datas of a streaming channel
* @param Service who send
* @param Message to send
* @param streaming channel pointer
* @param max_size maximum sample to send
* @return None
******************************************************************************/
void Luos_SendStreamingSize(service_t *service, msg_t *msg, streaming_channel_t *stream, uint32_t max_size)
{
// Compute number of message needed to send available datas on ring buffer
int msg_number = 1;
int data_size = Stream_GetAvailableSampleNB(stream);
if (data_size > max_size)
{
data_size = max_size;
}
const int max_data_msg_size = (MAX_DATA_MSG_SIZE / stream->data_size);
if (data_size > max_data_msg_size)
{
Expand Down

0 comments on commit 052ca6c

Please sign in to comment.