-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Moin,

Ravi Kumar Madhuranthakam wrote:

> I am using socket CAN with Atmel 9263 board , And CAN Messages
> Extended ID is truncated when I send message using PCAN USB- analyzer
> . I am using read and write calls for message sending and receiving
> in the board.

So you have a problem in receiving can frames with an extended ID. Which
kernel are you using? I suggest to use at least the driver that comes
with the current 2.6.32-rcX.

> I am not using any filters and using CAN_RAW .
> Anybody has idea on this issue ?

You might want to display the incoming CAN frames with the candumo utility.

> My Code looks like this
> 
> #include <sys/types.h>
> #include <sys/socket.h>
> #include <sys/ioctl.h>
> #include <net/if.h>
> 
> #include <linux/can.h>
> #include <linux/can/raw.h>
> #include <string.h>
> 
> /* At time of writing, these constants are not defined in the headers */
> #ifndef PF_CAN
> #define PF_CAN 29
> #endif
> 
> #ifndef AF_CAN
> #define AF_CAN PF_CAN
> #endif
> 
> /* ... */
> 
> /* Somewhere in your app */
> 
>    /* Create the socket */
>    int skt = socket( PF_CAN, SOCK_RAW, CAN_RAW );
> 
>    /* Locate the interface you wish to use */
>    struct ifreq ifr;
>    strcpy(ifr.ifr_name, "can0");
>    ioctl(skt, SIOCGIFINDEX, &ifr); /* ifr.ifr_ifindex gets filled
>                                   * with that device's index */
> 
>    /* Select that CAN interface, and bind the socket to it. */
>    struct sockaddr_can addr;
>    addr.can_family = AF_CAN;
>    addr.can_ifindex = ifr.ifr_ifindex;
>    bind( skt, (struct sockaddr*)&addr, sizeof(addr) );
> 
>    /* Send a message to the CAN bus */
>    struct can_frame frame;
>    frame.can_id = 0x123;
>    strcpy( &frame.data, "foo" );
>    frame.can_dlc = strlen( &frame.data );
>    int bytes_sent = write( skt, &frame, sizeof(frame) );
> 
>    /* Read a message back from the CAN bus */
>    int bytes_read = read( skt, &frame, sizeof(frame) );

the code looks fine so far.

Cheers, Marc

- --
Pengutronix e.K.                         | Marc Kleine-Budde           |
Linux Solutions for Science and Industry | Phone: +49-231-2826-924     |
Vertretung West/Dortmund                 | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686         | http://www.pengutronix.de   |
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAksWGmcACgkQjTAFq1RaXHPfUwCeP0TWiwhua4JUvA2ghSrW9YAD
kFkAnRRb/2oLLtIqU4se9lmcW4jxwwE8
=QiDC
-----END PGP SIGNATURE-----
_______________________________________________
Socketcan-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-users

Reply via email to