?? test.c
字號:
/* This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 2007, 2010 fengGuojin(fgjnew@163.com) */#include <sys/types.h>#include <unistd.h>#include <fcntl.h>#include <linux/rtc.h>#include <linux/ioctl.h>#include <stdio.h>#include <stdlib.h>#define COUNT (100)int main(void){ int fd; int i,result; unsigned char buf[COUNT]; for(i=0;i<COUNT;i++) buf[i] = 0x00; fd=open("/dev/spd",O_RDWR); if(fd==-1) { perror(" #### i2c test device open failed #### \n"); return -1; } //printf(" open /dev/spd successfully\n");/* while(chr != '9'){ chr = getchar(); if(chr != 10) printf("%x ",chr); } getchar();*/ result = read(fd,&buf,COUNT); if(result < 0) { perror(" #### read data form smbus failed #### \n"); goto out; } for(i=0; i<COUNT;i++) { printf(" buf[%d]=%2x",i,buf[i]); if(i%5 == 0) printf("\n"); } printf("\n");out: close(fd); return result;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -