typedef unsigned short channel_t;
/* CAN ioctl functions */
+#define CAN_DRV_QUERY _IO(CAN_IOC_MAGIC, 0)
+#define CAN_DRV_QRY_BRANCH 0 /* returns driver branch value - "LINC" for LinCAN driver */
+#define CAN_DRV_QRY_VERSION 1 /* returns driver version as (major<<16) | (minor<<8) | patch */
+#define CAN_DRV_QRY_MSGFORMAT 2 /* format of canmsg_t structure */
+
#define CMD_START _IOW(CAN_IOC_MAGIC, 1, channel_t)
#define CMD_STOP _IOW(CAN_IOC_MAGIC, 2, channel_t)
//#define CMD_RESET 3
/* Device name as it will appear in /proc/devices */
#define DEVICE_NAME "can"
-/* Version of the driver reported by */
-
+/* Branch of the driver */
+#define CAN_DRV_BRANCH (('L'<<24)|('I'<<16)|('N'<<8)|'C')
+
+/* Version of the driver */
+#define CAN_DRV_VER_MAJOR 0
+#define CAN_DRV_VER_MINOR 2
+#define CAN_DRV_VER_PATCH 1
+#define CAN_DRV_VER ((CAN_DRV_VER_MAJOR<<16) | (CAN_DRV_VER_MINOR<<8) | CAN_DRV_VER_PATCH)
/* Default driver major number, see /usr/src/linux/Documentation/devices.txt */
#define CAN_MAJOR 91
*/
int can_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg);
+int can_ioctl_query(struct canuser_t *canuser, unsigned long what);
devcommon.c can_devrtl.c setup.c finish.c irq.c boardlist.c \
sja1000p.c sja1000.c i82527.c \
open.c close.c read.c write.c ioctl.c select.c fasync.c \
- proc.c $(lincan_cards_SOURCES) $(lincan_rtl_SOURCES)
+ proc.c ioctl_query.c $(lincan_cards_SOURCES) $(lincan_rtl_SOURCES)
endif #CONFIG_OC_LINCAN
setup.o finish.o irq.o boardlist.o \
sja1000p.o sja1000.o i82527.o \
open.o proc.o close.o write.o read.o \
- ioctl.o select.o fasync.o
+ ioctl.o ioctl_query.o select.o fasync.o
# Objects with exported symbols (-DEXPORT_SYMTAB)
OX_OBJS =
# Module objects
}
switch (cmd) {
+ case CAN_DRV_QUERY: {
+ return can_ioctl_query(canuser, arg);
+ }
case STAT: {
for (i=0x0; i<0x100; i++)
CANMSG("0x%x is 0x%x\n",i,can_read_reg(chip,i));
#include "../include/main.h"
#include <rtl_posixio.h>
+#include "../include/ioctl.h"
#include "../include/can_iortl.h"
}
switch (cmd) {
+ case CAN_DRV_QUERY: {
+ return can_ioctl_query(canuser, arg);
+ }
case STAT: {
for (i=0x0; i<0x100; i++)
CANMSG("0x%x is 0x%x\n",i,can_read_reg(chip,i));
int canfilt_fl;
+int query_fl;
+
int can_wait_sec = 5;
char *can_dev_name = "/dev/can0";
printf(" -f, --flags <num> CAN filter flags\n");
printf(" -w, --wait <num> number of seconds to wait in select call\n");
printf(" -p, --prefix <str> string prefix for output\n");
+ printf(" -q, --query query driver features\n");
printf(" -V, --version show version\n");
printf(" -h, --help this usage screen\n");
}
{ "flags", 1, 0, 'f' },
{ "wait", 1, 0, 'w' },
{ "prefix",1, 0, 'p' },
+ { "query" ,0 ,0, 'q' },
{ "version",0,0, 'V' },
{ "help", 0, 0, 'h' },
{ 0, 0, 0, 0}
struct sigaction act;
- while ((opt = getopt_long(argc, argv, "d:m:i:f:w:p:Vh",
+ while ((opt = getopt_long(argc, argv, "d:m:i:f:w:p:qVh",
&long_opts[0], NULL)) != EOF) switch (opt) {
case 'd':
can_dev_name=optarg;
case 'p':
prt_prefix_in = optarg;
break;
+ case 'q':
+ query_fl=1;
+ break;
case 'V':
fputs("LinCAN utilities v0.2\n", stdout);
exit(0);
exit(1);
}
+ if (query_fl) {
+ n=ioctl(fd, CAN_DRV_QUERY, CAN_DRV_QRY_BRANCH);
+ printf("CAN driver branch: %c%c%c%c\n",(n>>24)&0xff,(n>>16)&0xff,(n>>8)&0xff,n&0xff);
+ n=ioctl(fd, CAN_DRV_QUERY, CAN_DRV_QRY_VERSION);
+ printf("CAN driver version: %d.%d.%d\n",(n>>16)&0xff,(n>>8)&0xff,n&0xff);
+ n=ioctl(fd, CAN_DRV_QUERY, CAN_DRV_QRY_MSGFORMAT);
+ printf("CAN message format: %08x\n",n);
+ close(fd);
+ return 0;
+ }
+
if (canfilt_fl) {
ret = ioctl(fd, CANQUE_FILTER, &canfilt);
if(ret<0) {