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

fix previously received data remains #18

Conversation

a-higuchi
Copy link
Contributor

@a-higuchi a-higuchi commented Sep 5, 2022

Relate #17

Description

If the DLC(Data Length Code) is less than 8, the previously received data remains in the "data" field of the topic sent by ros2_socketcan.

When supporting multiple types of HW with the same CAN-ID but different DLCs(*see below for further details), unintended behavior may occur if garbage is included in the reception result of can_receiver.

*Description about "CAN-ID but different DLCs".
For example, there are two HWs, HW1 and HW2, and the specification of HW1's CAN-ID: 100h is as follows.

  • HW1(DLC=1)
CAN-ID DLC data1 data2 data3 data4 data5 data6 data7 data8
100h 1 lamp1 on - - - - - - -

In contrast to the above, if the HW2 CAN-ID: 100h specification is as follows, a malfunction may occur if the previously received data remains in the "data" field.

  • HW2(DLC=2)
CAN-ID DLC data1 data2 data3 data4 data5 data6 data7 data8
100h 2 lamp1 on/off lamp2 on/off - - - - - -

Current problem

The data length for memcopy was the DLC value in SocketCanReceiver::receive.
As a result, when receiving data with a DLC length of less than 8, the data after the DLC data length was not initialized, and the previously received data remained in the buffer.

Countermeasures

Fixed data length to memcopy to be the size of the data field.

Review Procedure

I have confirmed that the unused data fields have been initialized by the steps described in the issue.

  • Make sure the description is valid.
  • Make sure that what is described in the description matches the implementation.

@a-higuchi a-higuchi force-pushed the fix-previously-received-data-remains branch from f736d90 to 213d45b Compare September 6, 2022 04:43
Copy link

@yn-mrse yn-mrse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@JWhitleyWork
Copy link
Collaborator

Sorry, I didn't realize I was still a maintiner on this project!

@JWhitleyWork JWhitleyWork merged commit 17d0b35 into autowarefoundation:main Oct 3, 2022
@mitsudome-r
Copy link
Member

@JWhitleyWork Thanks for taking a look at this. Since you are no longer an AWF employee, I have removed you from the maintainer for now and assigned others from AWF. If you still wish to continue as a maintainer, please let me know.

@JWhitleyWork
Copy link
Collaborator

@mitsudome-r Yes, I would appreciate staying as a maintainer. I'm fine collaborating with the AWF but I'm still actively using and developing this project and am willing to help review PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants