?? obcantest.c
字號:
#include <stdio.h>#include <stdlib.h>#include <fcntl.h>#include "can.h"#include <memory.h>int main(){int c0,c1;struct canmsg_t cd,cs;int cts = 10;c0=open("/dev/can0",O_RDWR);c1=open("/dev/can1",O_RDWR);if(c0<0||c1<0){ printf("error open can dev\n"); exit(0);}cs.length=8;cs.id=0;cs.data[0]=0;cs.data[1]=1;cs.data[2]=2;cs.data[3]=3;while( cts-- ){ memset(&cd,0,sizeof(cd)); write(c0,&cs,sizeof(cs)); usleep(1); read(c1,&cd,1); if(cd.data[0]!=0||cd.data[1]!=1||cd.data[2]!=2||cd.data[3]!=3) { printf("error in can\n"); exit(0); }}close(c1);close(c0);printf("can test passed\n");exit(1);return 1;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -