#include #include #include #include #include #include #include #include #include #include #include #include int main(int argc, char **argv) { int fd; int res = 0; char buf[256]; if (argc != 5) { printf("set_led takes 4 arguments\n"); return 1; } /* Open the Device with non-blocking reads. In real life, don't use a hard coded path; use libudev instead. */ fd = open("/dev/hidraw2", O_RDWR|O_NONBLOCK); if (fd < 0) { perror("Unable to open device"); return 1; } memset(buf, 0x0, sizeof(buf)); if (argv[1][0] == '1') buf[2] = 0xff; if (argv[2][0] == '1') buf[3] = 0xff; if (argv[3][0] == '1') buf[4] = 0xff; if (argv[4][0] == '1') buf[5] = 0xff; /* Send a Report to the Device */ buf[0] = 0x00; /* Report Number */ buf[1] = 0x00; /* Report ID */ /*buf[2] = 0x00; Buzzer 1 */ /*buf[3] = 0x00; Buzzer 2 */ /*buf[4] = 0x00; Buzzer 3 */ /*buf[5] = 0x00; 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; }