]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/src/write.c
Added support for Unicontrols PCI CAN card.
[lincan.git] / lincan / src / write.c
index 1760bc2fdba740085e9b4f876414dfe4771010c7..e3809b0ebe90e393a1bf5efef9a812d9f831f6a1 100644 (file)
@@ -53,8 +53,10 @@ ssize_t can_write(struct file *file, const char *buffer, size_t length, loff_t *
 
        /* Prepare first message */
        copy_from_user(&msg_buff, buffer, sizeof(struct canmsg_t));
 
        /* Prepare first message */
        copy_from_user(&msg_buff, buffer, sizeof(struct canmsg_t));
-       /* Automatic selection of extended format if "extended" set and ID>2047 */
-       if (extended) if (msg_buff.id & ~0x7ffl ) msg_buff.flags |= MSG_EXT;
+
+       /* Automatic selection of extended format if ID>2047 */
+       if (msg_buff.id & ~0x7ffl & MSG_ID_MASK ) msg_buff.flags |= MSG_EXT;
+       /* has been dependent on "extended" option */
 
        /* If the output buffer is full, return immediately in case O_NONBLOCK
         * has been specified or loop until space becomes available.
 
        /* If the output buffer is full, return immediately in case O_NONBLOCK
         * has been specified or loop until space becomes available.
@@ -89,8 +91,11 @@ ssize_t can_write(struct file *file, const char *buffer, size_t length, loff_t *
                bytes_to_copy -= sizeof(struct canmsg_t);
                /* Prepare first message */
                copy_from_user(&msg_buff, buffer, sizeof(struct canmsg_t));
                bytes_to_copy -= sizeof(struct canmsg_t);
                /* Prepare first message */
                copy_from_user(&msg_buff, buffer, sizeof(struct canmsg_t));
-               /* Automatic selection of extended format if "extended" set and ID>2047 */
-               if (extended) if (msg_buff.id & ~0x7ffl ) msg_buff.flags |= MSG_EXT;
+
+               /* Automatic selection of extended format if ID>2047 */
+               if (msg_buff.id & ~0x7ffl & MSG_ID_MASK ) msg_buff.flags |= MSG_EXT;
+               /* has been dependent on "extended" option */
+
                /* Get slot */
                if(canque_get_inslot4id(qends, &qedge, &slot, 
                        0, msg_buff.id, 0) < 0) break;
                /* Get slot */
                if(canque_get_inslot4id(qends, &qedge, &slot, 
                        0, msg_buff.id, 0) < 0) break;