CAN: Define IOCTL commands that manage filters
This commit is contained in:
parent
9a347f135a
commit
36d4559ee8
2
arch
2
arch
@ -1 +1 @@
|
||||
Subproject commit 5faba88c51c916a2ce8a465cf1be3d9ebd83dc62
|
||||
Subproject commit 478948e2fd0c1621bce15195c6f207df4156fbe6
|
@ -97,7 +97,7 @@ static int can_xmit(FAR struct can_dev_s *dev);
|
||||
static ssize_t can_write(FAR struct file *filep,
|
||||
FAR const char *buffer, size_t buflen);
|
||||
static inline ssize_t can_rtrread(FAR struct can_dev_s *dev,
|
||||
FAR struct canioctl_rtr_s *rtr);
|
||||
FAR struct canioc_rtr_s *rtr);
|
||||
static int can_ioctl(FAR struct file *filep, int cmd,
|
||||
unsigned long arg);
|
||||
|
||||
@ -604,7 +604,7 @@ return_with_irqdisabled:
|
||||
****************************************************************************/
|
||||
|
||||
static inline ssize_t can_rtrread(FAR struct can_dev_s *dev,
|
||||
FAR struct canioctl_rtr_s *rtr)
|
||||
FAR struct canioc_rtr_s *rtr)
|
||||
{
|
||||
FAR struct can_rtrwait_s *wait = NULL;
|
||||
irqstate_t flags;
|
||||
@ -663,19 +663,19 @@ static int can_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
/* CANIOCTL_RTR: Send the remote transmission request and wait for the
|
||||
* response. Argument is a reference to struct canioctl_rtr_s
|
||||
/* CANIOC_RTR: Send the remote transmission request and wait for the
|
||||
* response. Argument is a reference to struct canioc_rtr_s
|
||||
* (casting to uintptr_t first eliminates complaints on some
|
||||
* architectures where the sizeof long is different from the size of
|
||||
* a pointer).
|
||||
*/
|
||||
|
||||
case CANIOCTL_RTR:
|
||||
ret = can_rtrread(dev, (struct canioctl_rtr_s*)((uintptr_t)arg));
|
||||
case CANIOC_RTR:
|
||||
ret = can_rtrread(dev, (struct canioc_rtr_s*)((uintptr_t)arg));
|
||||
break;
|
||||
|
||||
/* Not a "built-in" ioctl command.. perhaps it is unique to this
|
||||
* device driver.
|
||||
* lower-half, device driver.
|
||||
*/
|
||||
|
||||
default:
|
||||
|
@ -1,7 +1,7 @@
|
||||
/************************************************************************************
|
||||
* include/nuttx/can.h
|
||||
*
|
||||
* Copyright (C) 2008, 2009, 2011-2012 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2008, 2009, 2011-2012, 2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -49,6 +49,7 @@
|
||||
#include <semaphore.h>
|
||||
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
|
||||
#ifdef CONFIG_CAN
|
||||
|
||||
@ -109,18 +110,56 @@
|
||||
|
||||
#define CAN_MSGLEN(nbytes) (sizeof(struct can_msg_s) - CAN_MAXDATALEN + (nbytes))
|
||||
|
||||
/* Built-in ioctl commands
|
||||
/* Built-in ioctl commands support by the upper half driver.
|
||||
*
|
||||
* CANIOCTL_RTR: Send the remote transmission request and wait for the response.
|
||||
* CANIOC_RTR:
|
||||
* Description: Send the remote transmission request and wait for the response.
|
||||
* Argument: A reference to struct canioc_rtr_s
|
||||
*
|
||||
* Ioctl commands that may or may not be supported by the lower half driver.
|
||||
*
|
||||
* CANIOC_ADD_STDFILTER:
|
||||
* Description: Add an address filter for a standard 11 bit address.
|
||||
* Argument: A reference to struct canioc_stdfilter_s
|
||||
* Returned Value: A non-negative filter ID is returned on success.
|
||||
* Otherwise -1 (ERROR) is returned with the errno
|
||||
* variable set to indicate the nature of the error.
|
||||
*
|
||||
* CANIOC_ADD_EXTFILTER:
|
||||
* Description: Add an address filter for a extended 28 bit address.
|
||||
* Argument: A reference to struct canioc_extfilter_s
|
||||
* Returned Value: A non-negative filter ID is returned on success.
|
||||
* Otherwise -1 (ERROR) is returned with the errno
|
||||
* variable set to indicate the nature of the error.
|
||||
*
|
||||
* CANIOC_DEL_STDFILTER:
|
||||
* Description: Remove an address filter for a standard 11 bit address.
|
||||
* Argument: The filter index previously returned by the
|
||||
* CANIOC_ADD_STDFILTER command
|
||||
* Returned Value: Zero (OK) is returned on success. Otherwise -1 (ERROR)
|
||||
* is returned with the errno variable set to indicate the
|
||||
* nature of the error.
|
||||
*
|
||||
* CANIOC_DEL_EXTFILTER:
|
||||
* Description: Remove an address filter for a standard 28 bit address.
|
||||
* Argument: The filter index previously returned by the
|
||||
* CANIOC_ADD_EXTFILTER command
|
||||
* Returned Value: Zero (OK) is returned on success. Otherwise -1 (ERROR)
|
||||
* is returned with the errno variable set to indicate the
|
||||
* nature of the error.
|
||||
*/
|
||||
|
||||
#define CANIOCTL_RTR 1 /* Argument is a reference to struct canioctl_rtr_s */
|
||||
#define CANIOC_RTR _CANIOC(1)
|
||||
#define CANIOC_ADD_STDFILTER _CANIOC(2)
|
||||
#define CANIOC_ADD_EXTFILTER _CANIOC(3)
|
||||
#define CANIOC_DEL_STDFILTER _CANIOC(4)
|
||||
#define CANIOC_DEL_EXTFILTER _CANIOC(5)
|
||||
|
||||
/* CANIOCTL_USER: Device specific ioctl calls can be supported with cmds greater
|
||||
/* CANIOC_USER: Device specific ioctl calls can be supported with cmds greater
|
||||
* than this value
|
||||
*/
|
||||
|
||||
#define CANIOCTL_USER 2
|
||||
#define CANIOC_USER _CANIOC(6)
|
||||
|
||||
/************************************************************************************
|
||||
* Public Types
|
||||
@ -158,7 +197,7 @@
|
||||
#ifdef CONFIG_CAN_EXTID
|
||||
struct can_hdr_s
|
||||
{
|
||||
uint32_t ch_id; /* 11- or 29-bit ID (3-bits unsed) */
|
||||
uint32_t ch_id; /* 11- or 29-bit ID (3-bits unused) */
|
||||
uint8_t ch_dlc : 4; /* 4-bit DLC */
|
||||
uint8_t ch_rtr : 1; /* RTR indication */
|
||||
uint8_t ch_extid : 1; /* Extended ID indication */
|
||||
@ -296,12 +335,26 @@ struct can_dev_s
|
||||
|
||||
/* Structures used with ioctl calls */
|
||||
|
||||
struct canioctl_rtr_s
|
||||
struct canioc_rtr_s
|
||||
{
|
||||
uint16_t ci_id; /* The 11-bit ID to use in the RTR message */
|
||||
FAR struct can_msg_s *ci_msg; /* The location to return the RTR response */
|
||||
};
|
||||
|
||||
#ifdef CONFIG_CAN_EXTID
|
||||
struct canioc_extfilter_s
|
||||
{
|
||||
uint32_t xf_id; /* 28-bit ID (4-bits unused) */
|
||||
uint32_t xf_mask; /* 28-bit address mask (4-bits unused) */
|
||||
};
|
||||
#else
|
||||
struct canioc_stdfilter_s
|
||||
{
|
||||
uint16_t sf_id; /* 11-bit ID (5-bits unused) */
|
||||
uint16_t sf_mask; /* 11-bit address mask (5-bits unused) */
|
||||
};
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Public Data
|
||||
************************************************************************************/
|
||||
|
@ -76,7 +76,8 @@
|
||||
#define _PIPEBASE (0x1700) /* FIFO/pipe ioctl commands */
|
||||
#define _RTCBASE (0x1800) /* RTC ioctl commands */
|
||||
#define _RELAYBASE (0x1900) /* Relay devices ioctl commands */
|
||||
#define _BOARDBASE (0x1a00) /* boardctl commands */
|
||||
#define _CANBASE (0x1a00) /* CAN ioctl commands */
|
||||
#define _BOARDBASE (0x1b00) /* boardctl ioctl commands */
|
||||
|
||||
/* Macros used to manage ioctl commands */
|
||||
|
||||
@ -348,6 +349,12 @@
|
||||
#define _RELAYIOCVALID(c) (_IOC_TYPE(c)==_RELAYBASE)
|
||||
#define _RELAYIOC(nr) _IOC(_RELAYBASE,nr)
|
||||
|
||||
/* CAN driver ioctl definitions *********************************************/
|
||||
/* (see nuttx/can.h */
|
||||
|
||||
#define _CANIOCVALID(c) (_IOC_TYPE(c)==_CANBASE)
|
||||
#define _CANIOC(nr) _IOC(_CANBASE,nr)
|
||||
|
||||
/* boardctl() command definitions *******************************************/
|
||||
|
||||
#define _BOARDIOCVALID(c) (_IOC_TYPE(c)==_BOARDBASE)
|
||||
|
Loading…
Reference in New Issue
Block a user