]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/utils/sendburst.c
The original version of Arnaud Westenberg Linux CAN-bus driver
[lincan.git] / lincan / utils / sendburst.c
diff --git a/lincan/utils/sendburst.c b/lincan/utils/sendburst.c
new file mode 100644 (file)
index 0000000..084a4b2
--- /dev/null
@@ -0,0 +1,43 @@
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+
+#include "../include/can.h"
+
+int main(void)
+       {
+       struct canmsg_t sendmsg={0,0,5,0,8,{1,2,3,4,5,6,7,8}};
+       int fd, ret,i,j;
+
+       if ((fd=open("/dev/can0",O_RDWR)) < 0 ) 
+               {
+               perror("open");
+               printf("Error opening /dev/can0\n");
+               exit(1);
+               }
+       j=0;
+       while (1)
+               {
+               for(i=0;i<10;i++)
+                       {
+                       sendmsg.data[0]=i;
+                       sendmsg.data[1]=j;
+                       if ((ret=write(fd,&sendmsg,sizeof(struct canmsg_t))) < 0)
+                         {
+                               perror("write");
+                               printf("Error sending message\n");
+                               break;
+                               }
+                       }
+               printf("Sent block of 10 messages #: %u\n",j);
+               j++;
+               usleep(500000);
+               }
+       close(fd);
+       return 0;
+       }
+
+