]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/utils/rxtx.c
Correction of message data entry in rxtx and send utilities.
[lincan.git] / lincan / utils / rxtx.c
index 5fe75eb0cafd36f91c96b685d8fd8c91719715db..62c64a0e43241e7fb15a4b8bea21c2cfdd3fbc94 100644 (file)
@@ -10,6 +10,7 @@
 int main(void)
 {
        int i=0, fd=0, ret=0, count=0;
+       int msglen;
        char loop=0;
        char ch, transmission[MAXL+1], specialfile[MAXL+1]="/dev/can0", emptystring[MAXL+1]="", buf[MAXL+1];
        char remote[MAXL+1];
@@ -58,10 +59,13 @@ int main(void)
                if(message.id>=(1<<11))
                  message.flags |= MSG_EXT;
                printf("Enter the Message Length ");
-               scanf("%d",&message.length);
+               scanf("%d",&msglen);
+               message.length=msglen;
                for (i=0; i<message.length; i++) {
+                       int val;
                        printf("Enter data byte [%d] ",i);
-                       scanf("%x",(int *)&message.data[i]);
+                       scanf("%x",&val);
+                       message.data[i]=val;
                }
        }       
        if (*transmission=='r') {
@@ -109,7 +113,12 @@ int main(void)
                                printf("Id      : %lx\n",message.id);
                                printf("length  : %d\n",message.length);
                                printf("flags   : 0x%02x\n", message.flags);
+                               #ifdef CAN_MSG_VERSION_2
+                               printf("time    : %lds %ldusec\n", message.timestamp.tv_sec,
+                                       message.timestamp.tv_usec);
+                               #else /* CAN_MSG_VERSION_2 */
                                printf("time    : %ld\n", message.timestamp);
+                               #endif /* CAN_MSG_VERSION_2 */
                                for (i=0; i<message.length; i++)
                                        printf("data%d  : %02x\n",i,
                                                        message.data[i]);