EBADMSG error for new 8.6.0 peak driver

This forum covers PCAN-Linux and Linux development issues concerning our products
Post Reply
icegood
Posts: 1
Joined: Mon 24. Sep 2018, 16:07

EBADMSG error for new 8.6.0 peak driver

Post by icegood » Tue 25. Sep 2018, 10:36

Our code for J1939 device via can interface became broken after library update from 8.5.1 to 8.6.0.
In particular, procedure pcanfd_send_msg from driver code
was in 8.5.1:

Code: Select all

	switch (pf->type) {

	case PCANFD_TYPE_CANFD_MSG:

		/* accept such messages for CAN-FD capable devices only */
		if ((dev->init_settings.flags & PCANFD_INIT_FD) &&
				(pf->data_len <= PCANFD_MAXDATALEN))
			break;

	case PCANFD_TYPE_CAN20_MSG:
		if (pf->data_len <= 8)
			break;
	default:
		pr_err(DEVICE_NAME
			": trying to send invalid msg (type=%xh len=%d)\n",
			pf->type, pf->data_len);
		return -EBADMSG;
	}
now in 8.6.0:

Code: Select all

switch (ptx->msg.type) {

	case PCANFD_TYPE_CANFD_MSG:

		/* accept such messages for CAN-FD capable devices only */
		if ((dev->init_settings.flags & PCANFD_INIT_FD) &&
				(ptx->msg.data_len <= PCANFD_MAXDATALEN))
			break;

		pr_err(DEVICE_NAME
			": trying to send invalid CAN FD msg (len=%d)\n",
			ptx->msg.data_len);

		return -EBADMSG;

	case PCANFD_TYPE_CAN20_MSG:
		if (ptx->msg.data_len <= PCAN_MAXDATALEN)
			break;
	default:
		pr_err(DEVICE_NAME
			": trying to send invalid msg (type=%xh len=%d)\n",
			ptx->msg.type, ptx->msg.data_len);

		return -EBADMSG;
	}
Before code for PCANFD_TYPE_CANFD_MSG type and missing PCANFD_INIT_FD in dev->init_settings.flags and len <= 8 worked well as it processed by 'case PCANFD_TYPE_CAN20_MSG'. Now it doesn't work anymore as it explicitly returned in 'case PCANFD_TYPE_CANFD_MSG'. how should we fix it? Should we have PCANFD_INIT_FD flag set all time?

User avatar
S.Grosjean
Software Development
Software Development
Posts: 357
Joined: Wed 4. Jul 2012, 17:02

Re: EBADMSG error for new 8.6.0 peak driver

Post by S.Grosjean » Tue 25. Sep 2018, 13:51

Hello,

v8.5.1 was actually more permissive: you could send PCANFD_TYPE_CANFD_MSG even if you didn't use any CAN-FD adapter.

With 8.6.0, as far as you don't use CAN FD, your application should use PCANFD_TYPE_CAN20_MSG rather than PCANFD_TYPE_CANFD_MSG.

Using PCANFD_TYPE_CANFD_MSG could lead to set/clear internal CAN-FD options while the PC CAN interface had not been initialized for.
— Stéphane

Post Reply