Skip to content
Snippets Groups Projects
Commit 5aa91b6f authored by Lorenz Meier's avatar Lorenz Meier
Browse files

Updated MPU test to new driver model

parent c6eff9eb
No related branches found
No related tags found
No related merge requests found
......@@ -94,7 +94,7 @@ struct {
{"bma180", "/dev/bma180", bma180},
{"hmc5883l", "/dev/hmc5883l", hmc5883l},
{"ms5611", "/dev/ms5611", ms5611},
{"mpu6000", "/dev/mpu6000", mpu6000},
{"mpu6000", "/dev/accel", mpu6000},
// {"lis331", "/dev/lis331", lis331},
{NULL, NULL, NULL}
};
......@@ -334,10 +334,10 @@ mpu6000(int argc, char *argv[])
int16_t buf[6] = { -1, 0, -1, 0, -1, 0};
int ret;
fd = open("/dev/mpu6000", O_RDONLY);
fd = open("/dev/accel", O_RDONLY);
if (fd < 0) {
printf("\tMPU-6000: open fail\n");
printf("\tMPU-6000: open fail, run <mpu6000 start> first.\n");
return ERROR;
}
......@@ -347,26 +347,26 @@ mpu6000(int argc, char *argv[])
/* read data - expect samples */
ret = read(fd, buf, sizeof(buf));
if (ret != sizeof(buf)) {
if (ret < 3) {
printf("\tMPU-6000: read1 fail (%d)\n", ret);
return ERROR;
} else {
printf("\tMPU-6000 values: acc: x:%d\ty:%d\tz:%d\tgyro: r:%d\tp:%d\ty:%d\n", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
printf("\tMPU-6000 values: acc: x:%d\ty:%d\tz:%d");//\tgyro: r:%d\tp:%d\ty:%d\n", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
}
/* wait at least 10ms, sensor should have data after no more than 2ms */
usleep(100000);
// /* wait at least 10ms, sensor should have data after no more than 2ms */
// usleep(100000);
ret = read(fd, buf, sizeof(buf));
// ret = read(fd, buf, sizeof(buf));
if (ret != sizeof(buf)) {
printf("\tMPU-6000: read2 fail (%d)\n", ret);
return ERROR;
// if (ret != sizeof(buf)) {
// printf("\tMPU-6000: read2 fail (%d)\n", ret);
// return ERROR;
} else {
printf("\tMPU-6000 values: acc: x:%d\ty:%d\tz:%d\tgyro: r:%d\tp:%d\ty:%d\n", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
}
// } else {
// printf("\tMPU-6000 values: acc: x:%d\ty:%d\tz:%d\tgyro: r:%d\tp:%d\ty:%d\n", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
// }
/* XXX more tests here */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment