?? can.cpp
字號:
////-------------------------------------------------------------------------------------////this is the complement of the class can#include"can.h"#include<string.h>Can::Can() //this connects the signals and slots in this class{ connect(&reader,SIGNAL(sig_cmd(int)),this,SIGNAL(sig_cmd(int)));}int Can::init() //here should be some problem to solve about can dev init{ reader.init(); reader.start();}typedef union{ long cmd; unsigned char c[sizeof(long)];}ucmd;void Can::write_cmd(int cmd,char to){ printf("can get cmd %x \n",cmd); ucmd ccmd; CanData candy; memset(&candy,0,sizeof(CanData));////////////!!!!!!!!!!!!!!!!!!!!!!!! candy.id = 0x123; ////////!!!!!!!!!!!!!!!!!!!!!! candy.data[0] = 0; candy.data[0] |= MODULE; candy.data[1] |= to; candy.dlc = 8; /////////////////////////!!!!!!!!!!!!!!!!!!!!!!!!!!!! ucmd cccmd; ccmd.cmd = cmd; int i; for(i=0;i<4;i++) { candy.data[i+2] = ccmd.c[i]; } for(i=0;i<4;i++) cccmd.c[i]=candy.data[i+2]; printf("can sent cmd %x \n",cccmd.cmd); int n =write(reader.can_fd,&candy,sizeof(candy));}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -