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

Vector CAN FD #311

Merged
merged 3 commits into from
May 27, 2018
Merged

Vector CAN FD #311

merged 3 commits into from
May 27, 2018

Conversation

AntonioCohimbra
Copy link
Contributor

@AntonioCohimbra AntonioCohimbra commented May 18, 2018

Closes #300.

Copy link
Collaborator

@christiansandberg christiansandberg left a comment

Choose a reason for hiding this comment

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

Nice to see this being implemented!

vxlapi.XL_INTERFACE_VERSION, vxlapi.XL_BUS_TYPE_CAN)
if fd:
vxlapi.xlOpenPort(self.port_handle, self._app_name, self.mask,
permission_mask, 16000,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why 16000? Can this also be rx_queue_size?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, hardcoded value was taken over from a Vector example. Anyway the Vector documentation gives different ranges for rx_queue_size in case of CAN or CAN-FD. So I will change the default value to be in both ranges and use rx_queue_size in both cases.

Choose a reason for hiding this comment

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

Hello together,

did somebody test the CAN FD ? Is it working?

Thanks

David

self.canFdConf.arbitrationBitRate = ctypes.c_uint(bitrate)
else:
self.canFdConf.arbitrationBitRate = ctypes.c_uint(500000)
self.canFdConf.sjwAbr = ctypes.c_uint(2)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do these need to be different for different bitrates? Should they be parameters that the user can set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By the way: Do you know whether ctypes.c_uint is necessary?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It’s not necessary. The types have already been defined for the struct or the function.

extended_id=bool(msg_id & vxlapi.XL_CAN_EXT_MSG_ID),
is_remote_frame=bool(flags & vxlapi.XL_CAN_RXMSG_FLAG_RTR),
is_error_frame=bool(flags & vxlapi.XL_CAN_RXMSG_FLAG_EF),
is_fd=True,
Copy link
Collaborator

Choose a reason for hiding this comment

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

As I understood it, this should be bool(flags & vxlapi.XL_CAN_RXMSG_FLAG_EDL) since EDL is set for all FD-frames to distinguish them from regular frames. Or what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess I messed up fd for channel and fd per message. You're right!


if self.fd:
if msg.dlc > vxlapi.MAX_MSG_LEN: #extended data length (XL_CAN_RXMSG_FLAG_EDL) not in msg class
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here, shouldn't EDL be set for all FD-frames?


XLcanTxEvent.tagData.canMsg.canId = msg_id
XLcanTxEvent.tagData.canMsg.msgFlags = flags
XLcanTxEvent.tagData.canMsg.dlc = msg.dlc
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use can.util.len2dlc() since I believe this should be the code, not the number of bytes.

else:
if event.tag == vxlapi.XL_CAN_EV_TAG_RX_OK or event.tag == vxlapi.XL_CAN_EV_TAG_TX_OK:
msg_id = event.tagData.canRxOkMsg.canId
dlc = self.map_dlc(event.tagData.canRxOkMsg.dlc)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can use can.util.dlc2len().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will remove the own mapping and use the utils function.

@AntonioCohimbra
Copy link
Contributor Author

Hi, thanks for the review - it's really appreciated! I'll commit the changes soon. I also plan some testing with CANoe and VN1610, but most likely it will take some time...

@hardbyte hardbyte merged commit de59ce5 into hardbyte:develop May 27, 2018
@AntonioCohimbra AntonioCohimbra deleted the Vector_CAN_FD branch June 14, 2018 11:23
@AntonioCohimbra AntonioCohimbra restored the Vector_CAN_FD branch June 14, 2018 12:32
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.

None yet

4 participants