From 4fe6a9e6aec0e5a7a3752002eb4ac2efd5f5d546 Mon Sep 17 00:00:00 2001 From: Rostislav Lisovy Date: Mon, 19 Dec 2011 17:58:32 +0100 Subject: [PATCH] sllin: Enabled sending of RTR CAN frame, when there was LIN header on the bus (in slave mode). --- sllin/sllin.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/sllin/sllin.c b/sllin/sllin.c index baa8203..af309f1 100644 --- a/sllin/sllin.c +++ b/sllin/sllin.c @@ -146,6 +146,8 @@ struct sllin { char id_to_send; /* there is ID to be sent */ char data_to_send; /* there are data to be sent */ char resp_len_known; /* Length of the response is known */ + char header_received;/* In Slave mode, set when header was already + received */ unsigned long flags; /* Flag values/ mode etc */ #define SLF_INUSE 0 /* Channel in use */ @@ -263,6 +265,12 @@ static void sll_bump(struct sllin *sl) sl->rx_cnt - SLLIN_BUFF_DATA - 1); /* without checksum */ } +static void sll_send_rtr(struct sllin *sl) +{ + sllin_send_canfr(sl, (sl->rx_buff[SLLIN_BUFF_ID] & LIN_ID_MASK) | + CAN_RTR_FLAG, NULL, 0); +} + /* * Called by the driver when there's room for more data. If we have * more packets to send, we send them here. @@ -446,6 +454,7 @@ static void sllin_receive_buf(struct tty_struct *tty, } else { sl->rx_cnt = 0; sl->rx_expect = SLLIN_BUFF_ID + 1; + sl->header_received = false; return; } @@ -478,18 +487,20 @@ static void sllin_receive_buf(struct tty_struct *tty, int lin_id; struct sllin_conf_entry *sce; - // sl->rx_buff[sl->rx_cnt] = *cp++; - // if (sl->rx_cnt == (SLLIN_BUFF_ID + 1)) { /* Received whole header */ - // lin_id = sl->rx_buff[sl->rx_cnt] & LIN_ID_MASK; - // sce = &sl->linfr_cache[lin_id]; + sl->rx_buff[sl->rx_cnt] = *cp++; + if ((sl->rx_cnt >= (SLLIN_BUFF_ID + 1)) && + (sl->header_received == false)) { /* Received whole header */ + lin_id = sl->rx_buff[sl->rx_cnt] & LIN_ID_MASK; + sce = &sl->linfr_cache[lin_id]; - // if (sce->frame_fl & LIN_LOC_SLAVE_CACHE) - // sl->rx_expect += sce->dlc; - // else - // sl->rx_expect += 2;//SLLIN_DATA_MAX; + if (sce->frame_fl & LIN_LOC_SLAVE_CACHE) + sl->rx_expect += sce->dlc; + else + sl->rx_expect += 2;//SLLIN_DATA_MAX; - // /* Send RTR frame here */ - // } + sl->header_received = true; + sll_send_rtr(sl); + } if (sl->rx_cnt >= sl->rx_expect && sl->rx_cnt > SLLIN_BUFF_DATA) { sll_bump(sl); -- 2.39.2