]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/src/ioctl.c
Separated normal read and RTR assisted read transfer.
[lincan.git] / lincan / src / ioctl.c
index 4cf3ca5249535d90552fbc27fbc8d68cf8508137..63aaea10188e1495f1024a8787c60d916d82b38a 100644 (file)
@@ -4,7 +4,7 @@
  * Rewritten for new CAN queues by Pavel Pisa - OCERA team member
  * email:pisa@cmp.felk.cvut.cz
  * This software is released under the GPL-License.
- * Version lincan-0.2  9 Jul 2003
+ * Version lincan-0.3  17 Jun 2004
  */
 
 #include "../include/can.h"
@@ -20,7 +20,7 @@ int can_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned
        unsigned btr0=0, btr1=0;
        struct canuser_t *canuser = (struct canuser_t*)(file->private_data);
        struct msgobj_t *obj;
-       struct chip_t *chip;
+       struct canchip_t *chip;
        struct canque_ends_t *qends;
        
        if(!canuser || (canuser->magic != CAN_USER_MAGIC)){
@@ -66,21 +66,6 @@ int can_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned
                        break;
                }
                case CONF_FILTER: {
-                   #if 0
-                       if (!strcmp(chip->chip_type,"i82527")) {
-                       
-                               unsigned char id1, id0;
-                               id1 = (unsigned char) (arg << 5);
-                               id0 = (unsigned char) (arg >> 3);
-
-                               DEBUGMSG("configuring ID=%lx in message object:"
-                                       " %02x, %02x\n", arg, id0, id1);
-                               can_write_reg(chip,id1,MSG_OFFSET(obj->object) +
-                                                               iMSGID1);
-                               can_write_reg(chip,id0,MSG_OFFSET(obj->object) +
-                                                               iMSGID0);
-                       }
-                   #endif
 
                        /* In- and output buffer re-initialization */
                        
@@ -99,6 +84,16 @@ int can_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned
                        }
                        break;
                }
+               
+               case CANRTR_READ: {
+                       int ret;
+                       struct canmsg_t rtr_msg;
+                       
+                       copy_from_user(&rtr_msg, (void*)arg, sizeof(struct canmsg_t));
+                       ret = can_ioctl_remote_read(canuser, &rtr_msg, rtr_msg.id, 0);
+                       if(ret<0) return ret;
+                       copy_to_user((void*)arg, &rtr_msg, sizeof(struct canmsg_t));
+               }
 
                case CONF_BAUD: {
                        channel = arg & 0xff;
@@ -111,6 +106,25 @@ int can_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned
                        }
                        break;
                }
+               
+               case CONF_BAUDPARAMS: {
+                       struct can_baudparams_t params;
+                       copy_from_user(&params, (void*)arg, sizeof(struct can_baudparams_t));
+                       if(params.flags == -1) params.flags = 0;
+                       if(params.baudrate == -1) params.baudrate = chip->baudrate;
+                       if(params.sjw == -1) params.sjw = 0;
+                       if(params.sample_pt == -1) params.sample_pt = 75;
+                       i=chip->chipspecops->baud_rate(chip, params.baudrate, chip->clock, params.sjw,
+                                                        params.sample_pt, params.flags);
+                       if(i>=0) chip->baudrate = params.baudrate;
+                       else {
+                               CANMSG("Error setting baud parameters\n");
+                               return -1;
+                       }
+                       break;
+               }
+
+
                default: {
                        CANMSG("Not a valid ioctl command\n");
                        return -EINVAL;