due_can icon indicating copy to clipboard operation
due_can copied to clipboard

Can0.available() return 0 all the time

Open Bozili opened this issue 6 years ago • 1 comments
trafficstars

In the example of CAN_SendingTest I just put some println and It seems that the function Can0.available() isn't working (return 0 all the time), the sending frames works (returning 1), and I don't have any idea why is available() not working...Is there some trick?? Are there some connections missed?

Bozili avatar Apr 16 '19 14:04 Bozili

Which version of the library do you use? In older versions this code was included:

int CANRaw::available()
{
	int val;
	if (rx_avail())
	{
		val = rx_buffer_head - rx_buffer_tail;
		//Now, because this is a cyclic buffer it is possible that the ordering was reversed
		//So, handle that case
		if (val < 0) val += SIZE_RX_BUFFER;
	}
	else return 0;
}

which missed a return statement in the condition.

tfeldmann avatar Mar 31 '20 15:03 tfeldmann