Norman -
See code below... HTH.
BTW: Maybe you have to adapt the
path to /sys/devices/platform/omap/tsc/ain1 on BBB
You can compile the code with:
gcc -Wall fastadcin.c -o fastadcin
and run it with
./fastadcin > /tmp/temp
on your BBB
And can you give me a feedback how long the code takes on your BBB, a
actually have only a BBwhite. (eg by sharing
tail /tmp/temp)
on my BBwhite it takes 6.340149s
Regards
Dieter
----------8<--------
/*
Adapted from
https://bwgz57.wordpress.com/2012/04/01/beaglebone-how-hot-is-it/
*/
#include <sys/time.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h> /*O_RDONLY*/
#include <unistd.h> /*read*/
int main (int argc, char *argv[])
{
struct timeval tv;
double time_in_mill, starttime, sttime_ms;
int fd[8], ret;
/* in Bash: cat /sys/devices/platform/omap/tsc/ain1 */
int j, i, value;
char buffer[1024];
for (j=0;j<8;j++){
sprintf (buffer, "/sys/devices/platform/omap/tsc/ain%d", j+1);
// printf("%s\n",buffer);
fd[j] = open(buffer, O_RDONLY);
}
gettimeofday(&tv, NULL);
starttime = (double)(tv.tv_sec) ;
sttime_ms = (double)(tv.tv_usec) / 1000000 ;
for (i=0;i<10000;i++){
gettimeofday(&tv, NULL);
time_in_mill = (double)(tv.tv_sec) - starttime;// * 1000 +
(tv.tv_usec) / 1000 ;
time_in_mill = time_in_mill + (double)(tv.tv_usec) /
1000000 - sttime_ms;
printf("%f\t", time_in_mill);
for (j=0;j<8;j++){
ret = read(fd[j], buffer, sizeof(buffer));
if (ret == -1) {
printf("Error reading device\n");
}
else{
buffer[ret] = NULL;
value = atoi(buffer);
lseek(fd[j], 0, 0);
printf("%f\t", (double)value*1.8/4095);
}
}
printf("\n");
}
for (j=0;j<8;j++){
close(fd[j]);
}
exit (0);
}
----------8<--------