|
用的是tq2440开发板,用自带的adc测试程序能打开设备,我把这段程序放到Qt程序中,发现在虚拟机中能代开设备,但是移植到板子上就无法打开任何一个设备,open函数的返回值总是-1,这到底是怎么回事?
double SamplingThread::value(double timeStamp) const
{
fd = ::open("/dev/adc", 0);
if(fd<0)
{
const double x = timeStamp;
const double v = fd*100;
return v;
}
else
{
char buffer[30];
int len ;
len = ::read(fd, buffer, sizeof buffer -1);
if(len>0)
{
buffer[len] = '\0';
const double x = timeStamp;
const double v = buffer[0]*100+buffer[1]*10+buffer[2];
return v;
}
else
{
const double x = timeStamp;
const double v = 100;
return v;
}
::close(fd);
}
}
大家帮帮忙吧 |
|