Hi all,
Attempting to create heavy traffic with M54418TWR CAN interface, S socket is
used to write and read consecutively in a while loop. Therefor I have no
problem creating the socket and communicating between the can1 I/F and a
second device, but the program reset by itself after a while.
CODE:
*while(numofmsg)
{
nbytes = write(can_socket, &tx_frame, sizeof(struct can_frame));
numofmsg--;
// recv()
nbytes = recv(can_socket, &rx_frame, sizeof(struct can_frame),
MSG_DONTWAIT );
// ...
}
*
Is there some coding rules or prevention when doing something like that?
It is also hardware dependent, so I should check that also.
target: ( Freescale 54418TWR );
Linux version 2.6.29 (gcc version 4.4.1 (Sourcery G++ Lite 4.4-54) ) #49 Wed
Aug 10 15:50:50 EDT 2011
thanks,
Francois
P.S.
socket creation code
// create socket
if ((can_socket = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
int err_num = errno;
if(verbose)fprintf(stderr, "CAN_Open_Socket() socket() %d",
err_num);
return -1; // error socket
}
// bind to specific address
strcpy(ifr.ifr_name, "can1" );
ioctl(can_socket, SIOCGIFINDEX, &ifr);
addr.can_family = AF_CAN;
addr.can_ifindex = ifr.ifr_ifindex;
// bind
if (bind(can_socket, (struct sockaddr*) &addr, sizeof(addr)) != 0) {
int err_num = errno;
if(verbose)fprintf(stderr,"CAN_Open_Socket() bind() %d", err_num);
return -1; // error socket
}
_______________________________________________
Socketcan-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-users