eeprom测试不成功
OK335xD开发板运行测试程序时,出现如图错误时怎么回事? 你是在核心板的ds2460里面写东西吗,这个你只可以读取是不可以写入的 飞凌-peacelove 发表于 2016-8-27 16:56你是在核心板的ds2460里面写东西吗,这个你只可以读取是不可以写入的
#include<sys/types.h>
#include<fcntl.h>
#include<sys/stat.h>
#include<unistd.h>
#include<stdio.h>
#include<string.h>
#include<errno.h>
#include<stdlib.h>
#define BUF_SIZE 256
/* ./eeprom -wforlinx
./eeprom -r*/
int main(int argc, char **argv)
{
int ret = 0;
char arr = {'0'};
char buf = {'0'};
int fd = open("/dev/eeprom", O_RDWR);
if (fd < 0) {
perror("open eeprom device:");
exit(1);
}
if(argc < 2)
{
printf("please input correct argument\n");
exit(1);
}
if(!strcmp(argv,"-w"))
{
if(argc != 3)
{
printf("please input like this : ./eeprom -wforlinx\n");
exit(1);
}
strcpy(arr,argv);
ret = write(fd,arr,strlen(arr));
if(ret < 0)
{
fprintf(stderr,"error eeprom_write: %s\n",strerror(errno));
exit(1);
}
// printf("write ret = %d\n",ret);
// ret = lseek(fd,30,SEEK_SET);
// ret = write(fd,arr,strlen(arr) + 1);
// if(ret < 0)
// {
// fprintf(stderr,"error eeprom_write: %s\n",strerror(errno));
// exit(1);
// }
// printf("write ret = %d\n",ret);
}
if(!strcmp(argv,"-r"))
{
if(argc != 2)
{
printf("please input like this : ./eeprom -r\n");
exit(1);
}
ret =read(fd,buf,BUF_SIZE);
if(ret < 0)
{
fprintf(stderr,"error eeprom_read: %s\n",strerror(errno));
exit(1);
}
printf("the value inbuf is%s\n",buf);
ret = lseek(fd,6,SEEK_SET);
ret =read(fd,buf,BUF_SIZE);
if(ret < 0)
{
fprintf(stderr,"error eeprom_read: %s\n",strerror(errno));
exit(1);
}
printf("lseek to the seventh bytes in buf is %s\n",buf);
}
close(fd);
return 0;
提供的测试代码里面怎么会有写???
而且执行./eeprom -r 命令的时候会出现error eeprom_read: Bad address 您好,目前我们的板子上是没有eeprom的,里边有测试代码,是很久以前的开发板有eeprom,现在已经没有这个了,在现在的板子上是不能做这个测试的。
页:
[1]