RE: IBM HDAPS things are looking up (was: Re: [Hdaps-devel] Re: [ltp] IBM HDAPS Someone interested? (Accelerometer))

Alejandro Bonilla
2005-07-07T14:41:39Z

Jens,

Thanks for this util. :-) It will make things easier for us and do part of
the Job we are looking for. I will post this script in the hdaps.sf.net for
people if it's ok with you.

Thanks again,

.Alejandro

> > #include <stdio.h>
> > #include <unistd.h>
> > #include <fcntl.h>
> > #include <string.h>
> > #include <sys/ioctl.h>
> > #include <linux/hdreg.h>
> >
> > int main(int argc, char *argv[])
> > {
> > unsigned char buf[8];
> > int fd;
> >
> > if (argc < 2) {
> > printf("%s <dev>\n", argv[0]);
> > return 1;
> > }
> >
> > fd = open(argv[1], O_RDONLY);
> > if (fd == -1) {
> > perror("open");
> > return 1;
> > }
> >
> > memset(buf, 0, sizeof(buf));
> > buf[0] = 0xe1;
> > buf[1] = 0x44;
> > buf[3] = 0x4c;
> > buf[4] = 0x4e;
> > buf[5] = 0x55;
> >
> > if (ioctl(fd, HDIO_DRIVE_TASK, buf)) {
> > perror("ioctl");
> > return 1;
> > }
> >
> > if (buf[3] == 0xc4)
> > printf("head parked\n");
> > else
> > printf("head not parked %x\n", buf[3]);
> >
> > close(fd);
> > return 0;
> > }