]> rtime.felk.cvut.cz Git - lincan.git/blob - lincan/utils/sendburst.c
084a4b2674e95f123f2ec6245a44c89b7d301de8
[lincan.git] / lincan / utils / sendburst.c
1 #include <stdio.h>
2 #include <fcntl.h>
3 #include <unistd.h>
4 #include <sys/types.h>
5 #include <sys/stat.h>
6
7
8 #include "../include/can.h"
9
10 int main(void)
11         {
12         struct canmsg_t sendmsg={0,0,5,0,8,{1,2,3,4,5,6,7,8}};
13         int fd, ret,i,j;
14
15         if ((fd=open("/dev/can0",O_RDWR)) < 0 ) 
16                 {
17                 perror("open");
18                 printf("Error opening /dev/can0\n");
19                 exit(1);
20                 }
21         j=0;
22         while (1)
23                 {
24                 for(i=0;i<10;i++)
25                         {
26                         sendmsg.data[0]=i;
27                         sendmsg.data[1]=j;
28                         if ((ret=write(fd,&sendmsg,sizeof(struct canmsg_t))) < 0)
29                           {
30                                 perror("write");
31                                 printf("Error sending message\n");
32                                 break;
33                                 }
34                         }
35                 printf("Sent block of 10 messages #: %u\n",j);
36                 j++;
37                 usleep(500000);
38                 }
39         close(fd);
40         return 0;
41         }
42
43