Try to change:
unsigned char buf[9];
to:
unsigned char buf[8];
Editted:
because you " return 8 " in the device side while ' res = hid_read(handle, buf, sizeof(buf))' will return " sizeof(buf) " which is also 8, so the " res " will return negatif value as I knew.
Add your code to show the return value with the printf, so you can be sure what value was returned.
Hope it's right.
unsigned char buf[9];
to:
unsigned char buf[8];
Editted:
because you " return 8 " in the device side while ' res = hid_read(handle, buf, sizeof(buf))' will return " sizeof(buf) " which is also 8, so the " res " will return negatif value as I knew.
Add your code to show the return value with the printf, so you can be sure what value was returned.
Hope it's right.