Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ list(APPEND _deps "microcdr\;${_microcdr_version}")
###############################################################################
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
if(NOT UCLIENT_SUPERBUILD)
project(microxrcedds_client VERSION "2.4.0" LANGUAGES C)
project(microxrcedds_client VERSION "2.4.2" LANGUAGES C)
else()
project(uclient_superbuild NONE)
include(${PROJECT_SOURCE_DIR}/cmake/SuperBuild.cmake)
Expand Down
2 changes: 1 addition & 1 deletion examples/PublishHelloWorldCAN/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <stdlib.h> //atoi

#define STREAM_HISTORY 8
#define BUFFER_SIZE UXR_CONFIG_CAN_TRANSPORT_MTU* STREAM_HISTORY
#define BUFFER_SIZE UXR_CAN_TRANSPORT_MTU* STREAM_HISTORY

int main(
int args,
Expand Down
5 changes: 3 additions & 2 deletions include/uxr/client/profile/transport/can/can_transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ extern "C"
#include <uxr/client/visibility.h>
#include <uxr/client/transport.h>

#define UXR_CONFIG_CAN_TRANSPORT_MTU 63
/* For CAN-FD, MTU is fixed value */
#define UXR_CAN_TRANSPORT_MTU 63

typedef struct uxrCANTransport
{
uint8_t buffer[UXR_CONFIG_CAN_TRANSPORT_MTU];
uint8_t buffer[UXR_CAN_TRANSPORT_MTU];
uxrCommunication comm;
struct uxrCANPlatform platform;
} uxrCANTransport;
Expand Down
12 changes: 6 additions & 6 deletions src/c/core/session/stream/output_reliable_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ bool uxr_prepare_reliable_buffer_to_write(
uint8_t* buffer = uxr_get_reliable_buffer(&stream->base, seq_num);
size_t buffer_size = uxr_get_reliable_buffer_size(&stream->base, seq_num);

uint16_t available_block_size = (uint16_t)(buffer_capacity - (uint16_t)(stream->offset + SUBHEADER_SIZE));
size_t remaining_blocks = get_available_free_slots(stream);

// Aligment required for inserting an XRCE subheader
buffer_size += ucdr_alignment(buffer_size, 4);

Expand Down Expand Up @@ -95,7 +98,7 @@ bool uxr_prepare_reliable_buffer_to_write(
}
}
/* Check if the message fit in a fragmented message */
else
else if (length <= available_block_size * remaining_blocks)
{
/* Check if the current buffer free space is too small */
if (buffer_size + (size_t)SUBHEADER_SIZE >= buffer_capacity)
Expand All @@ -105,13 +108,10 @@ bool uxr_prepare_reliable_buffer_to_write(
buffer_size = uxr_get_reliable_buffer_size(&stream->base, seq_num);
}

size_t remaining_blocks = get_available_free_slots(stream);

uint16_t available_block_size = (uint16_t)(buffer_capacity - (uint16_t)(stream->offset + SUBHEADER_SIZE));
uint16_t first_fragment_size = (uint16_t)(buffer_capacity - (uint16_t)(buffer_size + SUBHEADER_SIZE));
size_t remaining_size = length - first_fragment_size;
size_t last_fragment_size;
uint16_t necessary_complete_blocks;
size_t last_fragment_size = 0;
uint16_t necessary_complete_blocks = 0;
if (0 == (remaining_size % available_block_size))
{
last_fragment_size = available_block_size;
Expand Down
2 changes: 1 addition & 1 deletion src/c/profile/transport/can/can_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ bool uxr_init_can_transport(
transport->comm.send_msg = send_can_msg;
transport->comm.recv_msg = recv_can_msg;
transport->comm.comm_error = get_can_error;
transport->comm.mtu = UXR_CONFIG_CAN_TRANSPORT_MTU;
transport->comm.mtu = UXR_CAN_TRANSPORT_MTU;
UXR_INIT_LOCK(&transport->comm.mutex);
rv = true;
}
Expand Down
19 changes: 19 additions & 0 deletions src/c/util/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@
#include "task.h"
#endif /* ifdef WIN32 */

// PX4
#if defined(__PX4_NUTTX) || defined(__PX4_POSIX) || defined(UCLIENT_PLATFORM_NUTTX) || defined(UCLIENT_PLATFORM_POSIX)

#ifdef __cplusplus
# define __BEGIN_DECLS extern "C" {
# define __END_DECLS }
#else
# define __BEGIN_DECLS
# define __END_DECLS
#endif

#define __EXPORT __attribute__ ((visibility ("default")))
#include <drivers/drv_hrt.h>

#endif // PX4

//==================================================================
// PUBLIC
//==================================================================
Expand Down Expand Up @@ -55,6 +71,9 @@ int64_t uxr_nanos(
struct timespec ts;
z_impl_clock_gettime(CLOCK_REALTIME, &ts);
return (((int64_t)ts.tv_sec) * 1000000000) + ts.tv_nsec;
#elif defined(__PX4_NUTTX) || defined(__PX4_POSIX) || defined(UCLIENT_PLATFORM_NUTTX) || defined(UCLIENT_PLATFORM_POSIX)

return (int64_t)(hrt_absolute_time() * 1000);
#else
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
Expand Down