#include #include #include #include #include #include #include #include #include #include #include #include int main(int argc, char **argv) { int fd; int i, res = 0; char buf[256]; /* Open the Device with non-blocking reads. In real life, don't use a hard coded path; use libudev instead. */ fd = open("/dev/hidraw0", O_RDWR|O_NONBLOCK); if (fd < 0) { perror("Unable to open device"); return 1; } memset(buf, 0x0, sizeof(buf)); switch (argv[1][0]) { case '0': break; case '1': buf[2] = 0xff; break; case '2': buf[3] = 0xff; break; case '3': buf[4] = 0xff; break; case '4': buf[5] = 0xff; break; default: printf("Please specify 0 ... 4 as single argument.\n"); } /* Send a Report to the Device */ buf[0] = 0x00; /* Report Number */ buf[1] = 0x00; /* Report ID */ //buf[2] = 0x01; /* Buzzer 1 */ //buf[3] = 0x00; /* Buzzer 2 */ //buf[4] = 0x00; /* Buzzer 3 */ //buf[5] = 0x01; /* Buzzer 4 */ res = write(fd, buf, 6); if (res < 0) { printf("Error: %d\n", errno); perror("write"); } else { //printf("write() wrote %d bytes\n", res); } close(fd); return 0; }