7 #include "../include/can.h"
14 char specialfile[MAXL+1]="/dev/can0", buf[MAXL+1];
15 struct canmsg_t message;
17 printf("\nThis program allows you to send a stream of Can messages.\n");
18 printf("Please answer the following questions:\n\n");
21 message.flags |= MSG_EXT; //hard code EXT for now
23 printf("From wich device file would you like to send the message?\n");
26 fgets(buf,MAXL,stdin);
27 buf[strcspn(buf,"\n")]='\0';
29 strncpy(specialfile,buf,MAXL);
30 specialfile[MAXL]='\0';
31 printf("Enter the starting Message ID ");
32 scanf("%lx",&message.id);
33 printf("Enter the Message Length ");
34 scanf("%d",&message.length);
35 for (i=0; i<message.length; i++) {
36 printf("Enter data byte [%d] ",i);
37 scanf("%x",(int *)&message.data[i]);
40 fd=open(specialfile,O_RDWR);
42 printf("Error opening %s\n",specialfile);
48 message.flags = MSG_EXT;
52 bits += 8*(4+message.length);
53 memcpy(message.data,&bits,sizeof(bits));
54 ret=write(fd, &message, sizeof(struct canmsg_t));
56 printf("Error sending message from %s\n",specialfile);
60 printf("Error closing %s\n",specialfile);