mirror of
https://github.com/apache/nuttx.git
synced 2026-05-22 22:20:01 +08:00
drivers/ctucanfd_pci.c: fix frame reception
Fix frame reception when CANFD is not enabled and there are many message in the RX buffer. The previous implementation assumed that the size of the data in the RX buffer is constant, which is not true. Fortunately, the amount of data in the buffer can be easily read from frame->fmt.rwcnt. Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
This commit is contained in:
committed by
Alan C. Assis
parent
7d9412e325
commit
49ad027c60
@@ -766,11 +766,15 @@ static void ctucanfd_chardev_receive(FAR struct ctucanfd_can_s *priv)
|
||||
|
||||
frame = (struct ctucanfd_frame_s *)&buff;
|
||||
|
||||
for (i = 0; i < sizeof(struct ctucanfd_frame_s) / 4; i++)
|
||||
{
|
||||
/* RX buffer in automatic mode */
|
||||
/* RX buffer in automatic mode */
|
||||
|
||||
buff[i] = ctucanfd_getreg(priv, CTUCANFD_RXDATA);
|
||||
buff[0] = ctucanfd_getreg(priv, CTUCANFD_RXDATA);
|
||||
|
||||
/* Read the rest of data */
|
||||
|
||||
for (i = 0; i < frame->fmt.rwcnt; i++)
|
||||
{
|
||||
buff[i + 1] = ctucanfd_getreg(priv, CTUCANFD_RXDATA);
|
||||
}
|
||||
|
||||
/* Get the DLC */
|
||||
@@ -1369,11 +1373,15 @@ static void ctucanfd_sock_receive(FAR struct ctucanfd_can_s *priv)
|
||||
|
||||
rxframe = (struct ctucanfd_frame_s *)&buff;
|
||||
|
||||
for (i = 0; i < sizeof(struct ctucanfd_frame_s) / 4; i++)
|
||||
{
|
||||
/* RX buffer in automatic mode */
|
||||
/* RX buffer in automatic mode */
|
||||
|
||||
buff[i] = ctucanfd_getreg(priv, CTUCANFD_RXDATA);
|
||||
buff[0] = ctucanfd_getreg(priv, CTUCANFD_RXDATA);
|
||||
|
||||
/* Read the rest of data */
|
||||
|
||||
for (i = 0; i < rxframe->fmt.rwcnt; i++)
|
||||
{
|
||||
buff[i + 1] = ctucanfd_getreg(priv, CTUCANFD_RXDATA);
|
||||
}
|
||||
|
||||
/* CAN 2.0 or CAN FD */
|
||||
|
||||
Reference in New Issue
Block a user