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

Add payload lenght on CAN messages #298

Merged
merged 11 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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 include/uxr/client/profile/transport/can/can_transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extern "C"
#include <uxr/client/visibility.h>
#include <uxr/client/transport.h>

#define UXR_CONFIG_CAN_TRANSPORT_MTU 64
#define UXR_CONFIG_CAN_TRANSPORT_MTU 63

typedef struct uxrCANTransport
{
Expand Down
10 changes: 6 additions & 4 deletions src/c/profile/transport/can/can_transport_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ size_t uxr_write_can_data_platform(

if (0 < poll_rv)
{
memcpy(&frame.data[0], buf, len);
memcpy(&frame.data[1], buf, len);
frame.data[0] = (uint8_t) len;

ssize_t bytes_sent = write(poll_fd_write_.fd, &frame, CANFD_MTU);

if (-1 != bytes_sent)
Expand Down Expand Up @@ -117,10 +119,10 @@ size_t uxr_read_can_data_platform(
{
ssize_t bytes_received = read(platform->poll_fd.fd, &frame, CANFD_MTU);

if (-1 != bytes_received)
if (-1 != bytes_received && frame.data[0] < CANFD_MTU)
{
memcpy(buf, &frame.data[0], frame.len);
rv = (size_t)frame.len;
memcpy(buf, &frame.data[1], frame.data[0]);
rv = (size_t) frame.data[0];
*errcode = 0;
}
else
Expand Down