can4--测试can

can测试-refer to ok6410自带例子
//server.c
//server.c
#include <sys/ioctl.h>
#include <net/if.h>
#include <linux/can.h>

#ifndef PF_CAN
#define PF_CAN 29
#endif

#ifndef AF_CAN
#define AF_CAN PF_CAN
#endif

int main()
{
    int s;
    unsigned long nbytes,len;
    struct sockaddr_can addr;
    struct ifreq ifr;
    struct can_frame frame;


    s = socket(PF_CAN,SOCK_RAW,CAN_RAW);
    //取得can0的接口序号到ifr.ifr_ifindex,必须先去取得can0的index,因为bind时用的是addr的index,而不是名字can0
    strcpy(ifr.ifr_name,"can0");
    ioctl(s,SIOCGIFINDEX,&ifr);
    printf("can0 can_ifindex = %x\n",ifr.ifr_ifindex);

    //bind to all enabled can interface
    addr.can_family = AF_CAN;
    //addr.can_ifindex =0;//选择监听所有can接口
    addr.can_ifindex =ifr.ifr_ifindex;//选择监听can0,和网络中监听某个ip类似 server_address.sin_addr.s_addr = inet_addr("127.0.0.1");
    bind(s,(struct sockaddr*)&addr,sizeof(addr));

    struct can_filter rfilter;//过滤
    rfilter.can_id   = 0x123;//选择监听can_frame中标示符是0x123的can帧,不过滤则监听所有。和网络中监听某个端口有点类似 server_address.sin_port = 9734;
    rfilter.can_mask = CAN_SFF_MASK;
    setsockopt(m_can, SOL_CAN_RAW, CAN_RAW_FILTER, &rfilter, sizeof(rfilter));

    nbytes = recvfrom(s,&frame,sizeof(struct can_frame),0,(struct sockaddr *)&addr,&len);
    
    /*get interface name of the received CAN frame*/
    ifr.ifr_ifindex = addr.can_ifindex;
    ioctl(s,SIOCGIFNAME,&ifr);
    printf("Received a CAN frame from interface %s\n",ifr.ifr_name);
    printf("frame message\n"
        "--can_id = %x\n"
        "--can_dlc = %x\n"
        "--data = %s\n",frame.can_id,frame.can_dlc,frame.data);

    return 0;
}
其中,ifreq 
/*
 * Interface request structure used for socket
 * ioctl's.  All interface ioctl's must have parameter
 * definitions which begin with ifr_name.  The
 * remainder may be interface specific.
 */


struct ifreq {
#define IFHWADDRLEN	6
	union
	{
		char	ifrn_name[IFNAMSIZ];		/* if name, e.g. "en0" */
	} ifr_ifrn;
	
	union {
		struct	sockaddr ifru_addr;
		struct	sockaddr ifru_dstaddr;
		struct	sockaddr ifru_broadaddr;
		struct	sockaddr ifru_netmask;
		struct  sockaddr ifru_hwaddr;
		short	ifru_flags;
		int	ifru_ivalue;
		int	ifru_mtu;
		struct  ifmap ifru_map;
		char	ifru_slave[IFNAMSIZ];	/* Just fits the size */
		char	ifru_newname[IFNAMSIZ];
		void __user *	ifru_data;
		struct	if_settings ifru_settings;
	} ifr_ifru;
};

#define ifr_name	ifr_ifrn.ifrn_name	/* interface name 	*/
#define ifr_hwaddr	ifr_ifru.ifru_hwaddr	/* MAC address 		*/
#define	ifr_addr	ifr_ifru.ifru_addr	/* address		*/
#define	ifr_dstaddr	ifr_ifru.ifru_dstaddr	/* other end of p-p lnk	*/
#define	ifr_broadaddr	ifr_ifru.ifru_broadaddr	/* broadcast address	*/
#define	ifr_netmask	ifr_ifru.ifru_netmask	/* interface net mask	*/
#define	ifr_flags	ifr_ifru.ifru_flags	/* flags		*/
#define	ifr_metric	ifr_ifru.ifru_ivalue	/* metric		*/
#define	ifr_mtu		ifr_ifru.ifru_mtu	/* mtu			*/
#define ifr_map		ifr_ifru.ifru_map	/* device map		*/
#define ifr_slave	ifr_ifru.ifru_slave	/* slave device		*/
#define	ifr_data	ifr_ifru.ifru_data	/* for use by interface	*/
#define ifr_ifindex	ifr_ifru.ifru_ivalue	/* interface index	*/
#define ifr_bandwidth	ifr_ifru.ifru_ivalue    /* link bandwidth	*/
#define ifr_qlen	ifr_ifru.ifru_ivalue	/* Queue length 	*/
#define ifr_newname	ifr_ifru.ifru_newname	/* New name		*/
#define ifr_settings	ifr_ifru.ifru_settings	/* Device/proto settings*/



//client.c
#include <sys/ioctl.h>
#include <net/if.h>
#include <linux/can.h>

#ifndef PF_CAN
#define PF_CAN 29
#endif

#ifndef AF_CAN
#define AF_CAN PF_CAN
#endif

int main()
{
	int s;
	unsigned long nbytes;
	struct sockaddr_can addr;
	struct ifreq ifr;
	struct can_frame frame;


	s = socket(PF_CAN,SOCK_RAW,CAN_RAW);
//取得can0的接口序号到ifr.ifr_ifindex
	strcpy((char *)(ifr.ifr_name),"can0");
	ioctl(s,SIOCGIFINDEX,&ifr);
	printf("can0 can_ifindex = %x\n",ifr.ifr_ifindex);


	addr.can_family = AF_CAN;
	addr.can_ifindex = ifr.ifr_ifindex;//选择监听can0
	bind(s,(struct sockaddr*)&addr,sizeof(addr));

	frame.can_id = 0x123;
	strcpy((char *)frame.data,"hello");
	frame.can_dlc = strlen(frame.data);

	printf("Send a CAN frame from interface %s\n",ifr.ifr_name);

	nbytes = sendto(s,&frame,sizeof(struct can_frame),0,(struct sockaddr*)&addr,sizeof(addr));
	
	return 0;
}

源码见

can5--socketcan之mcp251x.c

测试发送
//应用打印
[root@FORLINX6410]# /mnt/client 
can0 can_ifindex = 3
Send a CAN frame from interface can0
//驱动打印
[root@FORLINX6410]#  DBG(drivers/net/can/mcp251x.c, mcp251x_hard_start_xmit(), 631): 从应用层收到发送命令
 DBG(drivers/net/can/mcp251x.c, mcp251x_hard_start_xmit(), 642): 要发送的数据是skb
 DBG(drivers/net/can/mcp251x.c, mcp251x_hard_start_xmit(), 643): 启动发送队列
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 876): 进入发送队列
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 889): 打印skb里的数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 892): priv->tx_skb->data[0]=23//canid
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 892): priv->tx_skb->data[1]=1//canid
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 892): priv->tx_skb->data[2]=0//canid
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 892): priv->tx_skb->data[3]=0//canid
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 892): priv->tx_skb->data[4]=5//长度
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 892): priv->tx_skb->data[5]=4d//未使用
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 892): priv->tx_skb->data[6]=ba//未使用
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 892): priv->tx_skb->data[7]=be//未使用
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 892): priv->tx_skb->data[8]=68//数据0 h
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 892): priv->tx_skb->data[9]=65//数据1 e
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 892): priv->tx_skb->data[10]=6c//数据2 l
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 892): priv->tx_skb->data[11]=6c//数据3 l
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 892): priv->tx_skb->data[12]=6f//数据4 o
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 892): priv->tx_skb->data[13]=0//数据5 随机
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 892): priv->tx_skb->data[14]=f//数据6 随机
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 892): priv->tx_skb->data[15]=40//数据7 随机
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 892): priv->tx_skb->data[16]=3//超范围
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 892): priv->tx_skb->data[17]=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 892): priv->tx_skb->data[18]=28
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 892): priv->tx_skb->data[19]=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 896): 打印can_frame的字段
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 897):  frame->can_id=0x123
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 901):  p=23
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 901):  p=1
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 901):  p=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 901):  p=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 904):  frame->can_dlc=5
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 907):  frame->data[0]=68
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 907):  frame->data[1]=65
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 907):  frame->data[2]=6c
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 907):  frame->data[3]=6c
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 907):  frame->data[4]=6f
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 907):  frame->data[5]=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 907):  frame->data[6]=f
 DBG(drivers/net/can/mcp251x.c, mcp251x_tx_work_handler(), 907):  frame->data[7]=40
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_tx(), 455): 打印是否扩展帧
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_tx(), 464): 是标准帧
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_tx(), 479): 打印送给spi的数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_tx(), 482): buf[0]=40//装载tx缓冲器命令
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_tx(), 482): buf[1]=24//TXBnSIDH--?
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_tx(), 482): buf[2]=60//TXBnSIDL--?
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_tx(), 482): buf[3]=1//TXBnEID8--?
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_tx(), 482): buf[4]=23//TXBnEID0--?
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_tx(), 482): buf[5]=5//TXBnDLC
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_tx(), 482): buf[6]=68//TXBnD0
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_tx(), 482): buf[7]=65//TXBnD1
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_tx(), 482): buf[8]=6c//TXBnD2
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_tx(), 482): buf[9]=6c//TXBnD3
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_tx(), 482): buf[10]=6f//TXBnD4
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_tx(), 482): buf[11]=0//TXBnD5
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_tx(), 482): buf[12]=0//TXBnD6
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_tx(), 482): buf[13]=0//TXBnD7
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 356): 打印spi直接发送的数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[0]=40
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[1]=24
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[2]=60
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[3]=1
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[4]=23
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[5]=5
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[6]=68
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[7]=65
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[8]=6c
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[9]=6c
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[10]=6f
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 362): 打印spi直接收到的数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[0]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[1]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[2]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[3]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[4]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[5]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[6]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[7]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[8]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[9]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[10]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 356):  DBG(drivers/net/can/mcp251x.c, mcp251x_can_irq(), 984): 有中断产生
打印spi直接发送的数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[0]=2//写寄存器命令
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[1]=30//发送缓冲器0控制寄存器
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[2]=8//即1000b,发送缓冲器等待报文发送--用于请求报文发送
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 362): 打印spi直接收到的数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[0]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[1]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[2]=ff
 DBG(drivers/net/can/mcp251x.c, can_irq_work(), 1031): 进入中断下半部
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 356): 打印spi直接发送的数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[0]=3//读寄存器命令
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[1]=2c//中断标志寄存器
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[2]=8//未使用
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[3]=1//未使用
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 362): 打印spi直接收到的数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[0]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[1]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[2]=4//中断标志寄存器的值=0x4=100b,即发送缓冲器0空中断,即buf0发送完成中断
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[3]=0
 DBG(drivers/net/can/mcp251x.c, can_irq_work(), 1049): 中断标志=0x4
 DBG(drivers/net/can/mcp251x.c, can_irq_work(), 1056): 是发送完成中断: 
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 356): 打印spi直接发送的数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[0]=5//位修改指令
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[1]=2c//中断标志寄存器
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[2]=4//掩码
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[3]=0//数据,清零中断标志
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 362): 打印spi直接收到的数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[0]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[1]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[2]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[3]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 356): 打印spi直接发送的数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[0]=3//读寄存器命令
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[1]=2c//中断标志寄存器
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[2]=4
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[3]=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 362): 打印spi直接收到的数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[0]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[1]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[2]=0//中断标志寄存器的值=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[3]=0
 DBG(drivers/net/can/mcp251x.c, can_irq_work(), 1049): 中断标志=0x0
 DBG(drivers/net/can/mcp251x.c, mcp251x_can_irq(), 984): 有中断产生
 DBG(drivers/net/can/mcp251x.c, can_irq_work(), 1031): 进入中断下半部
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 356): 打印spi直接发送的数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[0]=3//读寄存器命令
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[1]=2c//中断标志寄存器
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[2]=4
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[3]=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 362): 打印spi直接收到的数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[0]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[1]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[2]=0//中断标志寄存器的值=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[3]=0
 DBG(drivers/net/can/mcp251x.c, can_irq_work(), 1049): 中断标志=0x0

测试接收,另外一块板子执行client,测试板子执行server进行监听(不执行server也一样,反正只要can总线有数据到达,驱动会自动接收)
//应用打印
[root@FORLINX6410]# /mnt/server 
can0 can_ifindex = 3
Received a CAN frame from interface can0
//驱动打印
[root@FORLINX6410]#  DBG(drivers/net/can/mcp251x.c, mcp251x_can_irq(), 984): 有中断产生
 DBG(drivers/net/can/mcp251x.c, can_irq_work(), 1031): 进入中断下半部
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 356): 打印spi直接发送的数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[0]=3//读寄存命令
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[1]=2c//中断标志寄存器
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[2]=4//未使用
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[3]=0//未使用
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 362): 打印spi直接收到的数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[0]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[1]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[2]=1//中断标志寄存器值是1,即rx0中有新数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[3]=0
 DBG(drivers/net/can/mcp251x.c, can_irq_work(), 1049): 中断标志=0x1
 DBG(drivers/net/can/mcp251x.c, can_irq_work(), 1079): 是接收到数据中断: 
 DBG(drivers/net/can/mcp251x.c, can_irq_work(), 1080): receive buffer0有数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx_frame(), 494): 打印是否是mcp2515
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx_frame(), 505): 是mcp2515
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 356): 打印spi直接发送的数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[0]=90//读rx缓冲器命令
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[1]=2c
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[2]=4
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[3]=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[4]=23
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[5]=5//长度,以下都未用到
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[6]=68
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[7]=65
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[8]=6c
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[9]=6c
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[10]=6f
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[11]=75
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[12]=78
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[13]=2e
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 362): 打印spi直接收到的数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[0]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[1]=24//RXBnSIDH,即0010 0100,<<3=0010 0100 000
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[2]=60//RXBnSIDL,即0110 0000,>>5=011.两者相加=001 0010 0011=0x123  
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[3]=27//RXBnEID8,标准帧未使用
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[4]=52//RXBnEID0,标准帧未使用
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[5]=5//RXBnDLC,长度
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[6]=68//RXBnDM0,h
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[7]=65//RXBnDM1,e
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[8]=6c//RXBnDM2,l
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[9]=6c//RXBnDM3,l
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[10]=6f//RXBnDM4,o
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[11]=fe//RXBnDM5,未使用
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[12]=3d//RXBnDM6,未使用
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[13]=61//RXBnDM7,未使用
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 544): 打印从spi接收到buf里的数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 545):  buf_idx=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 549):  buf[0]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 549):  buf[1]=24
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 549):  buf[2]=60
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 549):  buf[3]=27
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 549):  buf[4]=52
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 549):  buf[5]=5
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 549):  buf[6]=68
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 549):  buf[7]=65
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 549):  buf[8]=6c
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 549):  buf[9]=6c
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 549):  buf[10]=6f
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 549):  buf[11]=fe
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 549):  buf[12]=3d
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 549):  buf[13]=61
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 552): 打印是否是扩展帧
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 570): 是标准帧
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 594): 打印can_frame的字段
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 595):  frame->can_id=0x123
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 599):  p=23
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 599):  p=1
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 599):  p=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 599):  p=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 603):  frame->can_dlc=5
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 607):  frame->data[0]=68
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 607):  frame->data[1]=65
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 607):  frame->data[2]=6c
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 607):  frame->data[3]=6c
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 607):  frame->data[4]=6f
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 607):  frame->data[5]=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 607):  frame->data[6]=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 607):  frame->data[7]=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 612): 打印skb里的数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 615): skb->data[0]=23
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 615): skb->data[1]=1
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 615): skb->data[2]=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 615): skb->data[3]=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 615): skb->data[4]=5
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 615): skb->data[5]=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 615): skb->data[6]=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 615): skb->data[7]=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 615): skb->data[8]=68
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 615): skb->data[9]=65
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 615): skb->data[10]=6c
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 615): skb->data[11]=6c
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 615): skb->data[12]=6f
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 615): skb->data[13]=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 615): skb->data[14]=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 615): skb->data[15]=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 615): skb->data[16]=19
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 615): skb->data[17]=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 615): skb->data[18]=18
 DBG(drivers/net/can/mcp251x.c, mcp251x_hw_rx(), 615): skb->data[19]=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 356): 打印spi直接发送的数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[0]=3//读寄存器命令
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[1]=2c//中断标志寄存器
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[2]=4
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[3]=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 362): 打印spi直接收到的数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[0]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[1]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[2]=0//中断标志寄存器的值=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[3]=0
 DBG(drivers/net/can/mcp251x.c, can_irq_work(), 1049): 中断标志=0x0
 DBG(drivers/net/can/mcp251x.c, mcp251x_can_irq(), 984): 有中断产生
 DBG(drivers/net/can/mcp251x.c, can_irq_work(), 1031): 进入中断下半部
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 356): 打印spi直接发送的数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[0]=3//读寄存器命令
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[1]=2c//中断标志寄存器
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[2]=4
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 359): priv->spi_tx_buf[3]=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 362): 打印spi直接收到的数据
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[0]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[1]=ff
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[2]=0//中断标志寄存器的值=0
 DBG(drivers/net/can/mcp251x.c, mcp251x_spi_trans(), 365): priv->spi_rx_buf[3]=0
 DBG(drivers/net/can/mcp251x.c, can_irq_work(), 1049): 中断标志=0x0



posted on 2012-07-12 12:32  _song  阅读(996)  评论(0编辑  收藏  举报