|
问题见红色注释
驱动中的函数:(驱动肯定没问题的,是教程上自带的)
static ssize_t s3c2440_18b20_read(struct file *filp, char *buf, size_t len, loff_t *off)
{
DS18B20PRO();
*buf=sdata; //温度值
//printk("%d\n",xiaoshu);
//printk("%d\n",sdata);
return 1;
}
测试函数:
{fd = open("/dev/18b20", 0);
if(fd < 0)
{
perror("Can't open /dev/18b20 \n");
exit(1);
}
printf("open ds18b20 success \n");
t= new QTimer(this);
connect(t, SIGNAL(timeout()),this , SLOT(readTem()));
t->start(1);// 问题:当延时增大时,温度传感器就不灵了,用烟头烤,读出的温度都不变。只有延时为1时才有变化????
}
void Tem::readTem()
{
char tmp;
read(fd, &tmp , sizeof(char));
printf("tmp is dd %d\n",tmp);//问题出来了,这里的tmp偶尔会很大???
}
|
|