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