Set the message filter
#include <sys/can_dcmd.h> #define CAN_DEVCTL_SET_MFILTER __DIOT(_DCMD_MISC, CAN_CMD_CODE + 3, uint32_t)
| Argument | Value |
|---|---|
| filedes | A file descriptor that you obtained by opening the device. This must be for a receive mailbox (e.g., /dev/can1/rx2). |
| dcmd | CAN_DEVCTL_SET_MFILTER |
| dev_data_ptr | A pointer to a uint32_t |
| n_bytes | sizeof(uint32_t) |
| dev_info_ptr | NULL |
This command sets the message filter, which is a mask that specifies which bits in the message IDs to ignore. The default mask is 0x0, so no bits are ignored.
The new message filter.
None.
int ret;
uint32_t val;
if( (fd = open( "/dev/can1/rx2", O_RDWR)) == -1 )
{
printf("open of %s failed \n", devname);
exit(EXIT_FAILURE);
}
/* Set val to the new filter. */
val = strtoul(optarg, NULL, 0);
if(EOK != (ret = devctl(fd, CAN_DEVCTL_SET_MFILTER, &val, sizeof(val), NULL)))
{
fprintf(stderr, "devctl CAN_DEVCTL_SET_MFILTER: %s\n", strerror(ret));
}