Merge pull request #7714 from OTAkeys/pr/conn_can_raw_fix
conn_can: fix conn_can_raw_send and improve doc
This commit is contained in:
commit
52d08ca565
@ -153,12 +153,11 @@ int conn_can_raw_send(conn_can_raw_t *conn, const struct can_frame *frame, int f
|
|||||||
int timeout = 5;
|
int timeout = 5;
|
||||||
while (1) {
|
while (1) {
|
||||||
mbox_get(&conn->mbox, &msg);
|
mbox_get(&conn->mbox, &msg);
|
||||||
|
xtimer_remove(&timer);
|
||||||
switch (msg.type) {
|
switch (msg.type) {
|
||||||
case CAN_MSG_TX_ERROR:
|
case CAN_MSG_TX_ERROR:
|
||||||
xtimer_remove(&timer);
|
|
||||||
return -EIO;
|
return -EIO;
|
||||||
case CAN_MSG_TX_CONFIRMATION:
|
case CAN_MSG_TX_CONFIRMATION:
|
||||||
xtimer_remove(&timer);
|
|
||||||
if ((int)msg.content.value == handle) {
|
if ((int)msg.content.value == handle) {
|
||||||
DEBUG("conn_can_raw_send: frame sent correctly\n");
|
DEBUG("conn_can_raw_send: frame sent correctly\n");
|
||||||
return 0;
|
return 0;
|
||||||
@ -170,6 +169,7 @@ int conn_can_raw_send(conn_can_raw_t *conn, const struct can_frame *frame, int f
|
|||||||
break;
|
break;
|
||||||
case _TIMEOUT_TX_MSG_TYPE:
|
case _TIMEOUT_TX_MSG_TYPE:
|
||||||
DEBUG("conn_can_raw_send: timeout\n");
|
DEBUG("conn_can_raw_send: timeout\n");
|
||||||
|
raw_can_abort(conn->ifnum, handle);
|
||||||
return -ETIMEDOUT;
|
return -ETIMEDOUT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -178,6 +178,7 @@ int conn_can_raw_send(conn_can_raw_t *conn, const struct can_frame *frame, int f
|
|||||||
if (!timeout--) {
|
if (!timeout--) {
|
||||||
return -EINTR;
|
return -EINTR;
|
||||||
}
|
}
|
||||||
|
xtimer_set(&timer, CONN_CAN_RAW_TIMEOUT_TX_CONF);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,6 +72,8 @@ typedef struct conn_can_raw {
|
|||||||
* @param[in] ifnum can device Interface
|
* @param[in] ifnum can device Interface
|
||||||
* @param[in] flags conn flags to set (CONN_CAN_RECVONLY)
|
* @param[in] flags conn flags to set (CONN_CAN_RECVONLY)
|
||||||
*
|
*
|
||||||
|
* @post @p filter must remain allocated until @p conn is closed
|
||||||
|
*
|
||||||
* @return 0 if socket was successfully connected
|
* @return 0 if socket was successfully connected
|
||||||
* @return any other negative number in case of an error
|
* @return any other negative number in case of an error
|
||||||
*/
|
*/
|
||||||
@ -123,6 +125,10 @@ int conn_can_raw_send(conn_can_raw_t *conn, const struct can_frame *frame, int f
|
|||||||
* @param[in] filter list of filters to set
|
* @param[in] filter list of filters to set
|
||||||
* @param[in] count number of filters in @p filter
|
* @param[in] count number of filters in @p filter
|
||||||
*
|
*
|
||||||
|
* @pre previously set filters must be allocated until the end of the call
|
||||||
|
* @post @p filter must remain allocated until @p conn is closed or
|
||||||
|
* conn_can_raw_set_filter() is called
|
||||||
|
*
|
||||||
* @return 0 if can filters were successfully set
|
* @return 0 if can filters were successfully set
|
||||||
* @return any other negative number in case of an error
|
* @return any other negative number in case of an error
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user