Add hidraw backend for FreeBSD
FreeBSD support hidraw in Kernel from 13.0. By using libusb only, we can only see the HID device from usb. To address this, we implement hidraw backend for FreeBSD.
Just like Linux use libudev to handle usb specified HID stuff (like Manufacture), we use libusb to handle it.
Sponsored-by: FreeBSD Foundation
Currently, some stuff like the Report Descriptor parser and error registry routine are copied from Linux and I think they are platform independent. Can we create a common directory or hidraw directory in code then put them inside?
Have tested by the hidtest program.
Thanks for @Youw your review:).
Then, What is your opinion about this?
Currently, some stuff like the Report Descriptor parser and error registry routine are copied from Linux and I think they are platform independent. Can we create a common directory or hidraw directory in code then put them inside?
Have tested by the hidtest program.
Thanks for @Youw your review:).
Then, What is your opinion about this?
Currently, some stuff like the Report Descriptor parser and error registry routine are copied from Linux and I think they are platform independent. Can we create a common directory or hidraw directory in code then put them inside? Have tested by the hidtest program.
I thinjk that is a good idea, but I don't think it really is nesessary to do so in scope of this PR. There are really lots of stuff which I'd like to share among beckends, and I think it is going to be some refactoring after all.
Nice. This will address the following issue.
- https://github.com/libusb/hidapi/issues/543
Oops. I forget we have udev-devd stuff. Maybe we should use udev also?
Oops. I forget we have udev-devd stuff. Maybe we should use udev also?
I lost context here. What for? Seem like you have all the functionality implemented already. Aren't you?
Oops. I forget we have udev-devd stuff. Maybe we should use udev also?
I lost context here. What for? Seem like you have all the functionality implemented already. Aren't you?
Yes, all functionality is fully implemented. I am just thinking if we should use libudev make hidapi more portable.
First test under FreeBSD 14.1 Release, under a physical machine (Chuwi mini PC, Intel J4125 CPU, 8GB RAM, 256GB SSD)
There are a few compiler warnings.
mcuee@freebsd14:~/build/hidapi_pr730 $ uname -a
FreeBSD freebsd14 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64
mcuee@freebsd14:~/build/hidapi_pr730 $ cc -v
FreeBSD clang version 18.1.5 (https://github.com/llvm/llvm-project.git llvmorg-18.1.5-0-g617a15a9eac9)
Target: x86_64-unknown-freebsd14.1
Thread model: posix
InstalledDir: /usr/bin
mcuee@freebsd14:~/build/hidapi_pr730 $ make
make all-recursive
Making all in freebsd
CC hid.lo
hid.c:396:24: warning: passing 'uint8_t[255]' (aka 'unsigned char[255]') to parameter of type 'const char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Wpointer-sign]
396 | mbstowcs(namebuffer, buffer, sizeof(namebuffer));
| ^~~~~~
/usr/include/stdlib.h:107:64: note: passing argument to parameter here
107 | size_t mbstowcs(wchar_t * __restrict , const char * __restrict, size_t);
| ^
hid.c:603:1: warning: non-void function does not return a value [-Wreturn-type]
603 | }
| ^
hid.c:937:7: warning: passing 'const char *' to parameter of type 'void *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
937 | free(dev->device_path);
| ^~~~~~~~~~~~~~~~
/usr/include/stdlib.h:101:18: note: passing argument to parameter here
101 | void free(void *);
| ^
3 warnings generated.
CCLD libhidapi-hidraw.la
Making all in libusb
CC hid.lo
CCLD libhidapi-libusb.la
Making all in hidtest
CC test.o
CCLD hidtest-libusb
CCLD hidtest-hidraw
Fix it:). Forget to fix the warning.
Somehow hidtest-hidraw will seg fault with the Microchip Simple HID example.
mcuee@freebsd14:~/build/hidapi_pr730 $ sudo ./hidtest/hidtest-hidraw
hidapi test/example tool. Compiled with hidapi version 0.15.0, runtime version 0.15.0.
Compile-time version matches runtime version of hidapi.
Segmentation fault
mcuee@freebsd14:~/build/hidapi_pr730 $ sudo ./hidtest/hidtest-libusb
hidapi test/example tool. Compiled with hidapi version 0.15.0, runtime version 0.15.0.
Compile-time version matches runtime version of hidapi.
Device Found
type: 04f2 0760
path: 0-3:1.0
serial_number: (null)
Manufacturer: Chicony
Product: USB Keyboard
Release: 100
Interface: 0
Usage (page): 0x0 (0x0)
Bus type: 1 (USB)
Report Descriptor: (65 bytes)
0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x05, 0x07, 0x19, 0xe0,
0x29, 0xe7, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x08,
0x81, 0x02, 0x95, 0x01, 0x75, 0x08, 0x81, 0x01, 0x95, 0x03,
0x75, 0x01, 0x05, 0x08, 0x19, 0x01, 0x29, 0x03, 0x91, 0x02,
0x95, 0x05, 0x75, 0x01, 0x91, 0x01, 0x95, 0x06, 0x75, 0x08,
0x15, 0x00, 0x26, 0xff, 0x00, 0x05, 0x07, 0x19, 0x00, 0x2a,
0xff, 0x00, 0x81, 0x00, 0xc0,
Device Found
type: 04f2 0760
path: 0-3:1.1
serial_number: (null)
Manufacturer: Chicony
Product: USB Keyboard
Release: 100
Interface: 1
Usage (page): 0x0 (0x0)
Bus type: 1 (USB)
Report Descriptor: (127 bytes)
0x06, 0x01, 0x00, 0x09, 0x80, 0xa1, 0x01, 0x85, 0x01, 0x19,
0x81, 0x29, 0x83, 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75,
0x01, 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, 0xc0,
0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x15, 0x00,
0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x19, 0xb5, 0x29, 0xb8,
0x09, 0xcd, 0x09, 0xe2, 0x09, 0xe9, 0x09, 0xea, 0x81, 0x02,
0x0a, 0x83, 0x01, 0x0a, 0x8a, 0x01, 0x0a, 0x92, 0x01, 0x0a,
0x94, 0x01, 0x0a, 0x21, 0x02, 0x1a, 0x23, 0x02, 0x2a, 0x25,
0x02, 0x81, 0x02, 0x0a, 0x26, 0x02, 0x0a, 0x27, 0x02, 0x0a,
0x2a, 0x02, 0x95, 0x03, 0x81, 0x02, 0x95, 0x05, 0x81, 0x01,
0xc0, 0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x02,
0x25, 0x01, 0x15, 0x00, 0x75, 0x01, 0x95, 0x08, 0x1a, 0xf1,
0x00, 0x2a, 0xf8, 0x00, 0x81, 0x02, 0xc0,
Device Found
type: 1ea7 0064
path: 0-4:1.0
serial_number: (null)
Manufacturer: (null)
Product: 2.4G Mouse
Release: 200
Interface: 0
Usage (page): 0x0 (0x0)
Bus type: 1 (USB)
Report Descriptor: (105 bytes)
0x06, 0xb5, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0xb5, 0x09,
0x02, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x07,
0x81, 0x02, 0x09, 0x02, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75,
0x08, 0x95, 0x07, 0x91, 0x02, 0xc0, 0x05, 0x01, 0x09, 0x02,
0xa1, 0x01, 0x85, 0x02, 0x09, 0x01, 0xa1, 0x00, 0x05, 0x09,
0x19, 0x01, 0x29, 0x08, 0x15, 0x00, 0x25, 0x01, 0x95, 0x08,
0x75, 0x01, 0x81, 0x02, 0x05, 0x01, 0x09, 0x30, 0x09, 0x31,
0x16, 0x01, 0xf8, 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02,
0x81, 0x06, 0x09, 0x38, 0x15, 0x81, 0x25, 0x7f, 0x75, 0x08,
0x95, 0x01, 0x81, 0x06, 0x05, 0x0c, 0x0a, 0x38, 0x02, 0x95,
0x01, 0x81, 0x06, 0xc0, 0xc0,
Device Found
type: 04d8 003f
path: 0-2:1.0
serial_number: (null)
Manufacturer: Microchip Technology Inc.
Product: Simple HID Device Demo
Release: 2
Interface: 0
Usage (page): 0x0 (0x0)
Bus type: 1 (USB)
Report Descriptor: (28 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x19, 0x01, 0x29,
0x40, 0x15, 0x01, 0x25, 0x40, 0x75, 0x08, 0x95, 0x40, 0x81,
0x00, 0x19, 0x01, 0x29, 0x40, 0x91, 0x00, 0xc0,
Manufacturer String: Microchip Technology Inc.
Product String: Simple HID Device Demo
Unable to read serial number string
Serial Number String: (0)
Report Descriptor: (28 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x19, 0x01, 0x29,
0x40, 0x15, 0x01, 0x25, 0x40, 0x75, 0x08, 0x95, 0x40, 0x81,
0x00, 0x19, 0x01, 0x29, 0x40, 0x91, 0x00, 0xc0,
Device Found
type: 04d8 003f
path: 0-2:1.0
serial_number: (null)
Manufacturer: Microchip Technology Inc.
Product: Simple HID Device Demo
Release: 2
Interface: 0
Usage (page): 0x1 (0xff00)
Bus type: 1 (USB)
Indexed String 1: Microchip Technology Inc.
Unable to send a feature report: hid_error is not implemented yet
Unable to get a feature report: hid_error is not implemented yet
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
read() timeout
Fix it:). Forget to fix the warning.
Thanks. The compiler warnings are gone.
The Segfault issue is still there though.
Can you show me where it cause segment fault? You can use something like lldb with (sudo lldb <binary_location>). Then use r to run.
This is with Cmake build. Somehow it only build one version of hidtest.
mcuee@freebsd14:~/build/hidapi_pr730 $ cmake -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHIDAPI_ENABLE_ASAN=ON -DHIDAPI_BUILD_HIDTEST=ON .
-- The C compiler identification is Clang 18.1.5
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- hidapi: v0.15.0
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found PkgConfig: /usr/local/bin/pkg-config (found version "2.2.0")
-- Checking for module 'libusb-1.0>=1.0.9'
-- Found libusb-1.0, version 1.0.13
-- Checking for module 'libusb-1.0>=1.0.9'
-- Found libusb-1.0, version 1.0.13
-- Check for Iconv
-- Performing Test Iconv_IS_BUILT_IN
-- Performing Test Iconv_IS_BUILT_IN - Success
-- Found Iconv: built in to C library
-- Performing Test HIDAPI_ICONV_CONST
-- Performing Test HIDAPI_ICONV_CONST - Failed
-- Building hidtest
-- Configuring done (0.9s)
-- Generating done (0.0s)
-- Build files have been written to: /home/mcuee/build/hidapi_pr730/build
mcuee@freebsd14:~/build/hidapi_pr730 $ cmake --build build
[ 16%] Building C object src/freebsd/CMakeFiles/hidapi_hidraw.dir/hid.c.o
[ 33%] Linking C shared library libhidapi-hidraw.so
[ 33%] Built target hidapi_hidraw
[ 50%] Building C object src/libusb/CMakeFiles/hidapi_libusb.dir/hid.c.o
[ 66%] Linking C shared library libhidapi-libusb.so
[ 66%] Built target hidapi_libusb
[ 83%] Building C object hidtest/CMakeFiles/hidtest.dir/test.c.o
[100%] Linking C executable hidtest
[100%] Built target hidtest
mcuee@freebsd14:~/build/hidapi_pr730/build $ ./hidtest/hidtest
cmake_install.cmake CMakeFiles/ hidtest/ src/
CMakeCache.txt export_generated/ Makefile
mcuee@freebsd14:~/build/hidapi_pr730/build $ ./hidtest/hidtest
hidapi test/example tool. Compiled with hidapi version 0.15.0, runtime version 0.15.0.
Compile-time version matches runtime version of hidapi.
=================================================================
==17517==ERROR: AddressSanitizer: memcpy-param-overlap: memory ranges [0x7fffffffde30,0x802000c87e50) and [0x7fffffffe010, 0x802000c88030) overlap
#0 0x2c64b5 in __asan_memcpy /usr/src/contrib/llvm-project/compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp:63:3
#1 0x80034827d in hid_get_next_from_oid /home/mcuee/build/hidapi_pr730/freebsd/hid.c:535:2
#2 0x80034827d in hid_get_next_from_sysctl_iter /home/mcuee/build/hidapi_pr730/freebsd/hid.c:567:14
#3 0x80034827d in hid_enumerate /home/mcuee/build/hidapi_pr730/freebsd/hid.c:621:8
#4 0x2fbeb3 in main /home/mcuee/build/hidapi_pr730/hidtest/test.c:181:9
#5 0x800474a69 in __libc_start1 (/lib/libc.so.7+0x85a69)
#6 0x24e36f in _start /usr/src/lib/csu/amd64/crt1_s.S:83
Address 0x7fffffffde30 is located in stack of thread T0 at offset 656 in frame
#0 0x800347fbf in hid_enumerate /home/mcuee/build/hidapi_pr730/freebsd/hid.c:607
This frame has 9 object(s):
[32, 128) 'q_name_oid.i.i' (line 510)
[160, 416) 'name_buffer.i.i' (line 511)
[480, 488) 'buffer_size.i.i' (line 512)
[512, 516) 'result.i.i' (line 513)
[528, 624) 'q_next_oid.i.i' (line 529)
[656, 752) 'recv_oid.i.i' (line 529) <== Memory access at offset 656 partially overflows this variable
[784, 792) 'recv_items.i.i' (line 531) <== Memory access at offset 656 partially underflows this variable
[816, 1071) 'buf' (line 611) <== Memory access at offset 656 partially underflows this variable
[1136, 1256) 'iter' (line 614) <== Memory access at offset 656 partially underflows this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
(longjmp and C++ exceptions *are* supported)
Address 0x7fffffffe010 is located in stack of thread T0 at offset 1136 in frame
#0 0x800347fbf in hid_enumerate /home/mcuee/build/hidapi_pr730/freebsd/hid.c:607
This frame has 9 object(s):
[32, 128) 'q_name_oid.i.i' (line 510)
[160, 416) 'name_buffer.i.i' (line 511)
[480, 488) 'buffer_size.i.i' (line 512)
[512, 516) 'result.i.i' (line 513)
[528, 624) 'q_next_oid.i.i' (line 529)
[656, 752) 'recv_oid.i.i' (line 529)
[784, 792) 'recv_items.i.i' (line 531)
[816, 1071) 'buf' (line 611)
[1136, 1256) 'iter' (line 614) <== Memory access at offset 1136 partially overflows this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
(longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: memcpy-param-overlap /home/mcuee/build/hidapi_pr730/freebsd/hid.c:535:2 in hid_get_next_from_oid
==17517==ABORTING
More detailed build log using CMake.
At least the shared version of hidtest will depend on the new FreeBSD hidraw backend.
mcuee@freebsd14:~/build/hidapi_pr730 $ cmake -B build/shared -S . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHIDAPI_ENABLE_ASAN=ON -DCMAKE_INSTALL_PREFIX=install/shared -DHIDAPI_BUILD_HIDTEST=ON
-- The C compiler identification is Clang 18.1.5
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- hidapi: v0.15.0
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found PkgConfig: /usr/local/bin/pkg-config (found version "2.2.0")
-- Checking for module 'libusb-1.0>=1.0.9'
-- Found libusb-1.0, version 1.0.13
-- Checking for module 'libusb-1.0>=1.0.9'
-- Found libusb-1.0, version 1.0.13
-- Check for Iconv
-- Performing Test Iconv_IS_BUILT_IN
-- Performing Test Iconv_IS_BUILT_IN - Success
-- Found Iconv: built in to C library
-- Performing Test HIDAPI_ICONV_CONST
-- Performing Test HIDAPI_ICONV_CONST - Failed
-- Building hidtest
-- Configuring done (0.9s)
-- Generating done (0.0s)
-- Build files have been written to: /home/mcuee/build/hidapi_pr730/build/shared
mcuee@freebsd14:~/build/hidapi_pr730 $ cmake --build build/shared
[ 16%] Building C object src/freebsd/CMakeFiles/hidapi_hidraw.dir/hid.c.o
[ 33%] Linking C shared library libhidapi-hidraw.so
[ 33%] Built target hidapi_hidraw
[ 50%] Building C object src/libusb/CMakeFiles/hidapi_libusb.dir/hid.c.o
[ 66%] Linking C shared library libhidapi-libusb.so
[ 66%] Built target hidapi_libusb
[ 83%] Building C object hidtest/CMakeFiles/hidtest.dir/test.c.o
[100%] Linking C executable hidtest
[100%] Built target hidtest
mcuee@freebsd14:~/build/hidapi_pr730 $ cmake -B build/static -S . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHIDAPI_ENABLE_ASAN=ON -DCMAKE_INSTALL_PREFIX=install/static -DBUILD_SHARED_LIBS=FALSE -DHIDAPI_BUILD_HIDTEST=ON
-- The C compiler identification is Clang 18.1.5
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- hidapi: v0.15.0
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found PkgConfig: /usr/local/bin/pkg-config (found version "2.2.0")
-- Checking for module 'libusb-1.0>=1.0.9'
-- Found libusb-1.0, version 1.0.13
-- Checking for module 'libusb-1.0>=1.0.9'
-- Found libusb-1.0, version 1.0.13
-- Check for Iconv
-- Performing Test Iconv_IS_BUILT_IN
-- Performing Test Iconv_IS_BUILT_IN - Success
-- Found Iconv: built in to C library
-- Performing Test HIDAPI_ICONV_CONST
-- Performing Test HIDAPI_ICONV_CONST - Failed
-- Building hidtest
-- Configuring done (0.9s)
-- Generating done (0.0s)
-- Build files have been written to: /home/mcuee/build/hidapi_pr730/build/static
mcuee@freebsd14:~/build/hidapi_pr730 $ cmake --build build/static
[ 16%] Building C object src/freebsd/CMakeFiles/hidapi_hidraw.dir/hid.c.o
[ 33%] Linking C static library libhidapi-hidraw.a
[ 33%] Built target hidapi_hidraw
[ 50%] Building C object src/libusb/CMakeFiles/hidapi_libusb.dir/hid.c.o
[ 66%] Linking C static library libhidapi-libusb.a
[ 66%] Built target hidapi_libusb
[ 83%] Building C object hidtest/CMakeFiles/hidtest.dir/test.c.o
[100%] Linking C executable hidtest
[100%] Built target hidtest
mcuee@freebsd14:~/build/hidapi_pr730 $ ldd ./build/shared/hidtest/hidtest
./build/shared/hidtest/hidtest:
libhidapi-hidraw.so.0 => /home/mcuee/build/hidapi_pr730/build/shared/src/freebsd/libhidapi-hidraw.so.0 (0x504ab6e1000)
libthr.so.3 => /lib/libthr.so.3 (0x504aaa6f000)
librt.so.1 => /lib/librt.so.1 (0x504aba0e000)
libm.so.5 => /lib/libm.so.5 (0x504abcec000)
libexecinfo.so.1 => /usr/lib/libexecinfo.so.1 (0x504ac03d000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x504ace1c000)
libc.so.7 => /lib/libc.so.7 (0x504aed6d000)
libusb.so.3 => /usr/lib/libusb.so.3 (0x504ada6d000)
libelf.so.2 => /lib/libelf.so.2 (0x504add6c000)
[vdso] (0x504aa327000)
mcuee@freebsd14:~/build/hidapi_pr730 $ ldd ./build/stativ/hidtest/hidtest
ldd: ./build/stativ/hidtest/hidtest: No such file or directory
mcuee@freebsd14:~/build/hidapi_pr730 $ ldd ./build/static/hidtest/hidtest
./build/static/hidtest/hidtest:
libusb.so.3 => /usr/lib/libusb.so.3 (0x1c3e5e8ab000)
libthr.so.3 => /lib/libthr.so.3 (0x1c3e5ee41000)
librt.so.1 => /lib/librt.so.1 (0x1c3e602c6000)
libm.so.5 => /lib/libm.so.5 (0x1c3e5f34c000)
libexecinfo.so.1 => /usr/lib/libexecinfo.so.1 (0x1c3e61301000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x1c3e60f96000)
libc.so.7 => /lib/libc.so.7 (0x1c3e616fe000)
libelf.so.2 => /lib/libelf.so.2 (0x1c3e623b0000)
[vdso] (0x1c3e5da87000)
mcuee@freebsd14:~/build/hidapi_pr730 $ ./build/shared/hidtest/hidtest
hidapi test/example tool. Compiled with hidapi version 0.15.0, runtime version 0.15.0.
Compile-time version matches runtime version of hidapi.
=================================================================
==17789==ERROR: AddressSanitizer: memcpy-param-overlap: memory ranges [0x7fffffffde30,0x802000c87e50) and [0x7fffffffe010, 0x802000c88030) overlap
#0 0x2c64b5 in __asan_memcpy /usr/src/contrib/llvm-project/compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp:63:3
#1 0x80034827d in hid_get_next_from_oid /home/mcuee/build/hidapi_pr730/freebsd/hid.c:535:2
#2 0x80034827d in hid_get_next_from_sysctl_iter /home/mcuee/build/hidapi_pr730/freebsd/hid.c:567:14
#3 0x80034827d in hid_enumerate /home/mcuee/build/hidapi_pr730/freebsd/hid.c:621:8
#4 0x2fbeb3 in main /home/mcuee/build/hidapi_pr730/hidtest/test.c:181:9
#5 0x800474a69 in __libc_start1 (/lib/libc.so.7+0x85a69)
#6 0x24e36f in _start /usr/src/lib/csu/amd64/crt1_s.S:83
Address 0x7fffffffde30 is located in stack of thread T0 at offset 656 in frame
#0 0x800347fbf in hid_enumerate /home/mcuee/build/hidapi_pr730/freebsd/hid.c:607
This frame has 9 object(s):
[32, 128) 'q_name_oid.i.i' (line 510)
[160, 416) 'name_buffer.i.i' (line 511)
[480, 488) 'buffer_size.i.i' (line 512)
[512, 516) 'result.i.i' (line 513)
[528, 624) 'q_next_oid.i.i' (line 529)
[656, 752) 'recv_oid.i.i' (line 529) <== Memory access at offset 656 partially overflows this variable
[784, 792) 'recv_items.i.i' (line 531) <== Memory access at offset 656 partially underflows this variable
[816, 1071) 'buf' (line 611) <== Memory access at offset 656 partially underflows this variable
[1136, 1256) 'iter' (line 614) <== Memory access at offset 656 partially underflows this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
(longjmp and C++ exceptions *are* supported)
Address 0x7fffffffe010 is located in stack of thread T0 at offset 1136 in frame
#0 0x800347fbf in hid_enumerate /home/mcuee/build/hidapi_pr730/freebsd/hid.c:607
This frame has 9 object(s):
[32, 128) 'q_name_oid.i.i' (line 510)
[160, 416) 'name_buffer.i.i' (line 511)
[480, 488) 'buffer_size.i.i' (line 512)
[512, 516) 'result.i.i' (line 513)
[528, 624) 'q_next_oid.i.i' (line 529)
[656, 752) 'recv_oid.i.i' (line 529)
[784, 792) 'recv_items.i.i' (line 531)
[816, 1071) 'buf' (line 611)
[1136, 1256) 'iter' (line 614) <== Memory access at offset 1136 partially overflows this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
(longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: memcpy-param-overlap /home/mcuee/build/hidapi_pr730/freebsd/hid.c:535:2 in hid_get_next_from_oid
==17789==ABORTING
lldb does not seem to give much info.
mcuee@freebsd14:~/build/hidapi_pr730 $ lldb ./build/shared/hidtest/hidtest
(lldb) target create "./build/shared/hidtest/hidtest"
Current executable set to '/home/mcuee/build/hidapi_pr730/build/shared/hidtest/hidtest' (x86_64).
(lldb) r
Process 17816 launched: '/home/mcuee/build/hidapi_pr730/build/shared/hidtest/hidtest' (x86_64)
Process 17816 stopped
* thread #1, name = 'hidtest', stop reason = exec
frame #0: 0x0000000800305de0
-> 0x800305de0: xorq %rbp, %rbp
0x800305de3: subq $0x18, %rsp
0x800305de7: movq %rdi, %r12
0x800305dea: movq %rsp, %rsi
(lldb) bt
* thread #1, name = 'hidtest', stop reason = exec
* frame #0: 0x0000000800305de0
(lldb) quit
Quitting LLDB will kill one or more processes. Do you really want to proceed: [Y/n] Y
After this is fixed, next test will be using hidapitester.
mcuee@freebsd14:~/build/hidapitester $ gmake -f Makefile_pr730_hidraw_freebsd
cc -I/usr/local/include -I ../hidapi_pr730/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" -c ../hidapi_pr730/freebsd/hid.c -o ../hidapi_pr730/freebsd/hid.o
cc -I/usr/local/include -I ../hidapi_pr730/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" -c hidapitester.c -o hidapitester.o
cc -I/usr/local/include -I ../hidapi_pr730/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" ../hidapi_pr730/freebsd/hid.o hidapitester.o -o hidapitester -L/usr/local/lib -lusb -liconv -pthread
I do some small fix. Can you help me on testing this?
No more crashing. But somehow it cannot open any devices.
mcuee@freebsd14:~/build/hidapi_pr730 $ sudo ./hidtest/hidtest-hidraw
hidapi test/example tool. Compiled with hidapi version 0.15.0, runtime version 0.15.0.
Compile-time version matches runtime version of hidapi.
unable to open device
mcuee@freebsd14:~/build/hidapi_pr730 $ sudo ./build/shared/hidtest/hidtest
hidapi test/example tool. Compiled with hidapi version 0.15.0, runtime version 0.15.0.
Compile-time version matches runtime version of hidapi.
unable to open device
mcuee@freebsd14:~/build/hidapi_pr730 $ sudo ./build/static/hidtest/hidtest
hidapi test/example tool. Compiled with hidapi version 0.15.0, runtime version 0.15.0.
Compile-time version matches runtime version of hidapi.
unable to open device
mcuee@freebsd14:~/build/hidapi_pr730 $ sudo ./hidtest/hidtest-libusb
hidapi test/example tool. Compiled with hidapi version 0.15.0, runtime version 0.15.0.
Compile-time version matches runtime version of hidapi.
Device Found
type: 04d8 003f
path: 0-1:1.0
serial_number: (null)
Manufacturer: Microchip Technology Inc.
Product: Simple HID Device Demo
Release: 2
Interface: 0
Usage (page): 0x0 (0x0)
Bus type: 1 (USB)
Report Descriptor: (28 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x19, 0x01, 0x29,
0x40, 0x15, 0x01, 0x25, 0x40, 0x75, 0x08, 0x95, 0x40, 0x81,
0x00, 0x19, 0x01, 0x29, 0x40, 0x91, 0x00, 0xc0,
Device Found
type: 04f2 0760
path: 0-3:1.0
serial_number: (null)
Manufacturer: Chicony
Product: USB Keyboard
Release: 100
Interface: 0
Usage (page): 0x0 (0x0)
Bus type: 1 (USB)
Report Descriptor: (65 bytes)
0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x05, 0x07, 0x19, 0xe0,
0x29, 0xe7, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x08,
0x81, 0x02, 0x95, 0x01, 0x75, 0x08, 0x81, 0x01, 0x95, 0x03,
0x75, 0x01, 0x05, 0x08, 0x19, 0x01, 0x29, 0x03, 0x91, 0x02,
0x95, 0x05, 0x75, 0x01, 0x91, 0x01, 0x95, 0x06, 0x75, 0x08,
0x15, 0x00, 0x26, 0xff, 0x00, 0x05, 0x07, 0x19, 0x00, 0x2a,
0xff, 0x00, 0x81, 0x00, 0xc0,
Device Found
type: 04f2 0760
path: 0-3:1.1
serial_number: (null)
Manufacturer: Chicony
Product: USB Keyboard
Release: 100
Interface: 1
Usage (page): 0x0 (0x0)
Bus type: 1 (USB)
Report Descriptor: (127 bytes)
0x06, 0x01, 0x00, 0x09, 0x80, 0xa1, 0x01, 0x85, 0x01, 0x19,
0x81, 0x29, 0x83, 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75,
0x01, 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, 0xc0,
0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x15, 0x00,
0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x19, 0xb5, 0x29, 0xb8,
0x09, 0xcd, 0x09, 0xe2, 0x09, 0xe9, 0x09, 0xea, 0x81, 0x02,
0x0a, 0x83, 0x01, 0x0a, 0x8a, 0x01, 0x0a, 0x92, 0x01, 0x0a,
0x94, 0x01, 0x0a, 0x21, 0x02, 0x1a, 0x23, 0x02, 0x2a, 0x25,
0x02, 0x81, 0x02, 0x0a, 0x26, 0x02, 0x0a, 0x27, 0x02, 0x0a,
0x2a, 0x02, 0x95, 0x03, 0x81, 0x02, 0x95, 0x05, 0x81, 0x01,
0xc0, 0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x02,
0x25, 0x01, 0x15, 0x00, 0x75, 0x01, 0x95, 0x08, 0x1a, 0xf1,
0x00, 0x2a, 0xf8, 0x00, 0x81, 0x02, 0xc0,
Device Found
type: 1ea7 0064
path: 0-4:1.0
serial_number: (null)
Manufacturer: (null)
Product: 2.4G Mouse
Release: 200
Interface: 0
Usage (page): 0x0 (0x0)
Bus type: 1 (USB)
Report Descriptor: (105 bytes)
0x06, 0xb5, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0xb5, 0x09,
0x02, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x07,
0x81, 0x02, 0x09, 0x02, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75,
0x08, 0x95, 0x07, 0x91, 0x02, 0xc0, 0x05, 0x01, 0x09, 0x02,
0xa1, 0x01, 0x85, 0x02, 0x09, 0x01, 0xa1, 0x00, 0x05, 0x09,
0x19, 0x01, 0x29, 0x08, 0x15, 0x00, 0x25, 0x01, 0x95, 0x08,
0x75, 0x01, 0x81, 0x02, 0x05, 0x01, 0x09, 0x30, 0x09, 0x31,
0x16, 0x01, 0xf8, 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02,
0x81, 0x06, 0x09, 0x38, 0x15, 0x81, 0x25, 0x7f, 0x75, 0x08,
0x95, 0x01, 0x81, 0x06, 0x05, 0x0c, 0x0a, 0x38, 0x02, 0x95,
0x01, 0x81, 0x06, 0xc0, 0xc0,
Manufacturer String: Microchip Technology Inc.
Product String: Simple HID Device Demo
Unable to read serial number string
Serial Number String: (0)
Report Descriptor: (28 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x19, 0x01, 0x29,
0x40, 0x15, 0x01, 0x25, 0x40, 0x75, 0x08, 0x95, 0x40, 0x81,
0x00, 0x19, 0x01, 0x29, 0x40, 0x91, 0x00, 0xc0,
Device Found
type: 04d8 003f
path: 0-1:1.0
serial_number: (null)
Manufacturer: Microchip Technology Inc.
Product: Simple HID Device Demo
Release: 2
Interface: 0
Usage (page): 0x1 (0xff00)
Bus type: 1 (USB)
Indexed String 1: Microchip Technology Inc.
Unable to send a feature report: hid_error is not implemented yet
Unable to get a feature report: hid_error is not implemented yet
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
read() timeout
Please load the hidraw driver first by
sudo kldload hidraw
Please load the hidraw driver first by
sudo kldload hidraw
I have done that but somehow the HID devices are not recognized by hidraw driver, only by ugen and uhid.
mcuee@freebsd14:~/build $ sudo kldload hidraw
kldload: can't load hidraw: module already loaded or in kernel
mcuee@freebsd14:~/build $ sudo kldstat | grep hid
4 1 0xffffffff8270e000 7928 hidraw.ko
5 3 0xffffffff82716000 7868 hidbus.ko
16 1 0xffffffff83441000 3360 uhid.ko
17 1 0xffffffff83445000 33c0 usbhid.ko
mcuee@freebsd14:~/build $ cat /boot/loader.conf
kern.geom.label.disk_ident.enable="0"
kern.geom.label.gptid.enable="0"
cryptodev_load="YES"
zfs_load="YES"
hidraw_load="YES"
mcuee@freebsd14:~/build $ sudo lsusb
Bus /dev/usb Device /dev/ugen0.3: ID 0925:1234 Lakeview Research
Bus /dev/usb Device /dev/ugen0.2: ID 04d8:003f Microchip Technology, Inc.
Bus /dev/usb Device /dev/ugen0.6: ID 13d3:3503 IMC Networks
Bus /dev/usb Device /dev/ugen0.5: ID 1ea7:0064 SHARKOON Technologies GmbH 2.4GHz Wireless rechargeable vertical mouse [More&Better]
Bus /dev/usb Device /dev/ugen0.4: ID 04f2:0760 Chicony Electronics Co., Ltd Acer KU-0760 Keyboard
Bus /dev/usb Device /dev/ugen0.1: ID 0000:0000
mcuee@freebsd14:~/build $ sudo ls -la /dev/uhid*
crw-r--r-- 1 root operator 0x69 Mar 30 18:44 /dev/uhid0
crw-r--r-- 1 root operator 0x187 Mar 30 18:31 /dev/uhid1
crw-r--r-- 1 root operator 0x6b Mar 30 18:50 /dev/uhid2
mcuee@freebsd14:~/build $ sudo ls -la /dev/hidraw*
ls: /dev/hidraw*: No such file or directory
mcuee@freebsd14:~/build $ uname -a
FreeBSD freebsd14 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64
mcuee@freebsd14:~/build/hidapi_pr730 $ sudo ./hidtest/hidtest-libusb
hidapi test/example tool. Compiled with hidapi version 0.15.0, runtime version 0.15.0.
Compile-time version matches runtime version of hidapi.
Device Found
type: 04f2 0760
path: 0-3:1.0
serial_number: (null)
Manufacturer: Chicony
Product: USB Keyboard
Release: 100
Interface: 0
Usage (page): 0x0 (0x0)
Bus type: 1 (USB)
Report Descriptor: (65 bytes)
0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x05, 0x07, 0x19, 0xe0,
0x29, 0xe7, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x08,
0x81, 0x02, 0x95, 0x01, 0x75, 0x08, 0x81, 0x01, 0x95, 0x03,
0x75, 0x01, 0x05, 0x08, 0x19, 0x01, 0x29, 0x03, 0x91, 0x02,
0x95, 0x05, 0x75, 0x01, 0x91, 0x01, 0x95, 0x06, 0x75, 0x08,
0x15, 0x00, 0x26, 0xff, 0x00, 0x05, 0x07, 0x19, 0x00, 0x2a,
0xff, 0x00, 0x81, 0x00, 0xc0,
Device Found
type: 04f2 0760
path: 0-3:1.1
serial_number: (null)
Manufacturer: Chicony
Product: USB Keyboard
Release: 100
Interface: 1
Usage (page): 0x0 (0x0)
Bus type: 1 (USB)
Report Descriptor: (127 bytes)
0x06, 0x01, 0x00, 0x09, 0x80, 0xa1, 0x01, 0x85, 0x01, 0x19,
0x81, 0x29, 0x83, 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75,
0x01, 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, 0xc0,
0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x15, 0x00,
0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x19, 0xb5, 0x29, 0xb8,
0x09, 0xcd, 0x09, 0xe2, 0x09, 0xe9, 0x09, 0xea, 0x81, 0x02,
0x0a, 0x83, 0x01, 0x0a, 0x8a, 0x01, 0x0a, 0x92, 0x01, 0x0a,
0x94, 0x01, 0x0a, 0x21, 0x02, 0x1a, 0x23, 0x02, 0x2a, 0x25,
0x02, 0x81, 0x02, 0x0a, 0x26, 0x02, 0x0a, 0x27, 0x02, 0x0a,
0x2a, 0x02, 0x95, 0x03, 0x81, 0x02, 0x95, 0x05, 0x81, 0x01,
0xc0, 0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x02,
0x25, 0x01, 0x15, 0x00, 0x75, 0x01, 0x95, 0x08, 0x1a, 0xf1,
0x00, 0x2a, 0xf8, 0x00, 0x81, 0x02, 0xc0,
Device Found
type: 1ea7 0064
path: 0-4:1.0
serial_number: (null)
Manufacturer: (null)
Product: 2.4G Mouse
Release: 200
Interface: 0
Usage (page): 0x0 (0x0)
Bus type: 1 (USB)
Report Descriptor: (105 bytes)
0x06, 0xb5, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0xb5, 0x09,
0x02, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x07,
0x81, 0x02, 0x09, 0x02, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75,
0x08, 0x95, 0x07, 0x91, 0x02, 0xc0, 0x05, 0x01, 0x09, 0x02,
0xa1, 0x01, 0x85, 0x02, 0x09, 0x01, 0xa1, 0x00, 0x05, 0x09,
0x19, 0x01, 0x29, 0x08, 0x15, 0x00, 0x25, 0x01, 0x95, 0x08,
0x75, 0x01, 0x81, 0x02, 0x05, 0x01, 0x09, 0x30, 0x09, 0x31,
0x16, 0x01, 0xf8, 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02,
0x81, 0x06, 0x09, 0x38, 0x15, 0x81, 0x25, 0x7f, 0x75, 0x08,
0x95, 0x01, 0x81, 0x06, 0x05, 0x0c, 0x0a, 0x38, 0x02, 0x95,
0x01, 0x81, 0x06, 0xc0, 0xc0,
Device Found
type: 04d8 003f
path: 0-1:1.0
serial_number: (null)
Manufacturer: Microchip Technology Inc.
Product: Simple HID Device Demo
Release: 2
Interface: 0
Usage (page): 0x0 (0x0)
Bus type: 1 (USB)
Report Descriptor: (28 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x19, 0x01, 0x29,
0x40, 0x15, 0x01, 0x25, 0x40, 0x75, 0x08, 0x95, 0x40, 0x81,
0x00, 0x19, 0x01, 0x29, 0x40, 0x91, 0x00, 0xc0,
Device Found
type: 0925 1234
path: 0-2:1.0
serial_number: (null)
Manufacturer: CYPRESS
Product: EZ-USB FX2 HID USBHIDIO
Release: 0
Interface: 0
Usage (page): 0x0 (0x0)
Bus type: 1 (USB)
Report Descriptor: (52 bytes)
0x06, 0xa0, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x09, 0x02, 0xa1,
0x00, 0x06, 0xa1, 0xff, 0x09, 0x03, 0x09, 0x04, 0x15, 0x80,
0x25, 0x7f, 0x35, 0x00, 0x45, 0xff, 0x75, 0x08, 0x95, 0x80,
0x81, 0x02, 0x09, 0x05, 0x09, 0x06, 0x15, 0x80, 0x25, 0x7f,
0x35, 0x00, 0x45, 0xff, 0x75, 0x08, 0x95, 0x80, 0x91, 0x02,
0xc0, 0xc0,
Manufacturer String: Microchip Technology Inc.
Product String: Simple HID Device Demo
Unable to read serial number string
Serial Number String: (0)
Report Descriptor: (28 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x19, 0x01, 0x29,
0x40, 0x15, 0x01, 0x25, 0x40, 0x75, 0x08, 0x95, 0x40, 0x81,
0x00, 0x19, 0x01, 0x29, 0x40, 0x91, 0x00, 0xc0,
Device Found
type: 04d8 003f
path: 0-1:1.0
serial_number: (null)
Manufacturer: Microchip Technology Inc.
Product: Simple HID Device Demo
Release: 2
Interface: 0
Usage (page): 0x1 (0xff00)
Bus type: 1 (USB)
Indexed String 1: Microchip Technology Inc.
Unable to send a feature report: hid_error is not implemented yet
Unable to get a feature report: hid_error is not implemented yet
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
read() timeout
mcuee@freebsd14:~/build/hidapi_pr730 $ sudo ./hidtest/hidtest-hidraw
hidapi test/example tool. Compiled with hidapi version 0.15.0, runtime version 0.15.0.
Compile-time version matches runtime version of hidapi.
unable to open device
I found the reason. There are two usb hid driver in FreeBSD. One is uhid, another is usbhid. Only usbhid is compatible with hidraw. Also, unload and try to load usbhid is useless. The effective way to enable usbhid is through
sudo sysctl hw.usb.usbhid.enable=1
Then when next time it is auto-loaded, the usbhid will replace the uhid:
sudo kldunload uhid.
If uhid is not auto reload:
sudo kldload uhid
Oops. I forget we have udev-devd stuff. Maybe we should use udev also?
I lost context here. What for? Seem like you have all the functionality implemented already. Aren't you?
Yes, all functionality is fully implemented. I am just thinking if we should use libudev make hidapi more portable.
If udev is generally available on FreeBSD and can be used in a similar way as in Linux/hidraw - it is probably a good idea to do so. And probably linux shouldn't be used in that case at all. But I imagine that is a large change to this PR, so it is up to you.
I found the reason. There are two usb hid driver in FreeBSD. One is uhid, another is usbhid. Only usbhid is compatible with hidraw. Also, unload and try to load usbhid is useless. The effective way to enable usbhid is through
sudo sysctl hw.usb.usbhid.enable=1Then when next time it is auto-loaded, the usbhid will replace the uhid:
sudo kldunload uhid.If uhid is not auto reload:
sudo kldload uhid
Thanks. This method works to get hidraw to bound to the device.
mcuee@freebsd14:~/build/hidapi_pr730 $ sudo ls -la /dev/uhid*
ls: /dev/uhid*: No such file or directory
mcuee@freebsd14:~/build/hidapi_pr730 $ sudo ls -la /dev/hidraw*
crw------- 1 root operator 0x17f Mar 31 21:08 /dev/hidraw0
crw------- 1 root operator 0x180 Mar 31 21:08 /dev/hidraw1
mcuee@freebsd14:~/build/hidapi_pr730 $ sudo ./hidtest/hidtest-libusb
hidapi test/example tool. Compiled with hidapi version 0.15.0, runtime version 0.15.0.
Compile-time version matches runtime version of hidapi.
Device Found
type: 04d8 003f
path: 0-2:1.0
serial_number: (null)
Manufacturer: Microchip Technology Inc.
Product: Simple HID Device Demo
Release: 2
Interface: 0
Usage (page): 0x0 (0x0)
Bus type: 1 (USB)
Report Descriptor: (28 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x19, 0x01, 0x29,
0x40, 0x15, 0x01, 0x25, 0x40, 0x75, 0x08, 0x95, 0x40, 0x81,
0x00, 0x19, 0x01, 0x29, 0x40, 0x91, 0x00, 0xc0,
Device Found
type: 1ea7 0064
path: 0-3:1.0
serial_number: (null)
Manufacturer: (null)
Product: 2.4G Mouse
Release: 200
Interface: 0
Usage (page): 0x0 (0x0)
Bus type: 1 (USB)
Report Descriptor: (105 bytes)
0x06, 0xb5, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0xb5, 0x09,
0x02, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x07,
0x81, 0x02, 0x09, 0x02, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75,
0x08, 0x95, 0x07, 0x91, 0x02, 0xc0, 0x05, 0x01, 0x09, 0x02,
0xa1, 0x01, 0x85, 0x02, 0x09, 0x01, 0xa1, 0x00, 0x05, 0x09,
0x19, 0x01, 0x29, 0x08, 0x15, 0x00, 0x25, 0x01, 0x95, 0x08,
0x75, 0x01, 0x81, 0x02, 0x05, 0x01, 0x09, 0x30, 0x09, 0x31,
0x16, 0x01, 0xf8, 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02,
0x81, 0x06, 0x09, 0x38, 0x15, 0x81, 0x25, 0x7f, 0x75, 0x08,
0x95, 0x01, 0x81, 0x06, 0x05, 0x0c, 0x0a, 0x38, 0x02, 0x95,
0x01, 0x81, 0x06, 0xc0, 0xc0,
Device Found
type: 04f2 0760
path: 0-4:1.0
serial_number: (null)
Manufacturer: Chicony
Product: USB Keyboard
Release: 100
Interface: 0
Usage (page): 0x0 (0x0)
Bus type: 1 (USB)
Report Descriptor: (65 bytes)
0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x05, 0x07, 0x19, 0xe0,
0x29, 0xe7, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x08,
0x81, 0x02, 0x95, 0x01, 0x75, 0x08, 0x81, 0x01, 0x95, 0x03,
0x75, 0x01, 0x05, 0x08, 0x19, 0x01, 0x29, 0x03, 0x91, 0x02,
0x95, 0x05, 0x75, 0x01, 0x91, 0x01, 0x95, 0x06, 0x75, 0x08,
0x15, 0x00, 0x26, 0xff, 0x00, 0x05, 0x07, 0x19, 0x00, 0x2a,
0xff, 0x00, 0x81, 0x00, 0xc0,
Device Found
type: 04f2 0760
path: 0-4:1.1
serial_number: (null)
Manufacturer: Chicony
Product: USB Keyboard
Release: 100
Interface: 1
Usage (page): 0x0 (0x0)
Bus type: 1 (USB)
Report Descriptor: (127 bytes)
0x06, 0x01, 0x00, 0x09, 0x80, 0xa1, 0x01, 0x85, 0x01, 0x19,
0x81, 0x29, 0x83, 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75,
0x01, 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, 0xc0,
0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x15, 0x00,
0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x19, 0xb5, 0x29, 0xb8,
0x09, 0xcd, 0x09, 0xe2, 0x09, 0xe9, 0x09, 0xea, 0x81, 0x02,
0x0a, 0x83, 0x01, 0x0a, 0x8a, 0x01, 0x0a, 0x92, 0x01, 0x0a,
0x94, 0x01, 0x0a, 0x21, 0x02, 0x1a, 0x23, 0x02, 0x2a, 0x25,
0x02, 0x81, 0x02, 0x0a, 0x26, 0x02, 0x0a, 0x27, 0x02, 0x0a,
0x2a, 0x02, 0x95, 0x03, 0x81, 0x02, 0x95, 0x05, 0x81, 0x01,
0xc0, 0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x02,
0x25, 0x01, 0x15, 0x00, 0x75, 0x01, 0x95, 0x08, 0x1a, 0xf1,
0x00, 0x2a, 0xf8, 0x00, 0x81, 0x02, 0xc0,
Manufacturer String: Microchip Technology Inc.
Product String: Simple HID Device Demo
Unable to read serial number string
Serial Number String: (0)
Report Descriptor: (28 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x19, 0x01, 0x29,
0x40, 0x15, 0x01, 0x25, 0x40, 0x75, 0x08, 0x95, 0x40, 0x81,
0x00, 0x19, 0x01, 0x29, 0x40, 0x91, 0x00, 0xc0,
Device Found
type: 04d8 003f
path: 0-2:1.0
serial_number: (null)
Manufacturer: Microchip Technology Inc.
Product: Simple HID Device Demo
Release: 2
Interface: 0
Usage (page): 0x1 (0xff00)
Bus type: 1 (USB)
Indexed String 1: Microchip Technology Inc.
Unable to send a feature report: hid_error is not implemented yet
Unable to get a feature report: hid_error is not implemented yet
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
read() timeout
However, hidtest-hidraw is still problematic --> it cannot be stopped and keep repeating with the test device.
mcuee@freebsd14:~/build/hidapi_pr730 $ sudo ./hidtest/hidtest-hidraw > hidraw_freebsd_hidtest.txt
^C
mcuee@freebsd14:~/build/hidapi_pr730 $ head -200 hidraw_freebsd_hidtest.txt
hidapi test/example tool. Compiled with hidapi version 0.15.0, runtime version 0.15.0.
Compile-time version matches runtime version of hidapi.
Device Found
type: 04f2 0760
path: /dev/hidraw1
serial_number: (null)
Manufacturer: Chicony
Product: Chicony USB Keyboard
Release: 100
Interface: 1
Usage (page): 0x80 (0x1)
Bus type: 1 (USB)
Report Descriptor: (127 bytes)
0x06, 0x01, 0x00, 0x09, 0x80, 0xa1, 0x01, 0x85, 0x01, 0x19,
0x81, 0x29, 0x83, 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75,
0x01, 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, 0xc0,
0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x15, 0x00,
0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x19, 0xb5, 0x29, 0xb8,
0x09, 0xcd, 0x09, 0xe2, 0x09, 0xe9, 0x09, 0xea, 0x81, 0x02,
0x0a, 0x83, 0x01, 0x0a, 0x8a, 0x01, 0x0a, 0x92, 0x01, 0x0a,
0x94, 0x01, 0x0a, 0x21, 0x02, 0x1a, 0x23, 0x02, 0x2a, 0x25,
0x02, 0x81, 0x02, 0x0a, 0x26, 0x02, 0x0a, 0x27, 0x02, 0x0a,
0x2a, 0x02, 0x95, 0x03, 0x81, 0x02, 0x95, 0x05, 0x81, 0x01,
0xc0, 0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x02,
0x25, 0x01, 0x15, 0x00, 0x75, 0x01, 0x95, 0x08, 0x1a, 0xf1,
0x00, 0x2a, 0xf8, 0x00, 0x81, 0x02, 0xc0,
Device Found
type: 04f2 0760
path: /dev/hidraw1
serial_number: (null)
Manufacturer: Chicony
Product: Chicony USB Keyboard
Release: 100
Interface: 1
Usage (page): 0x1 (0xc)
Bus type: 1 (USB)
Report Descriptor: (127 bytes)
0x06, 0x01, 0x00, 0x09, 0x80, 0xa1, 0x01, 0x85, 0x01, 0x19,
0x81, 0x29, 0x83, 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75,
0x01, 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, 0xc0,
0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x15, 0x00,
0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x19, 0xb5, 0x29, 0xb8,
0x09, 0xcd, 0x09, 0xe2, 0x09, 0xe9, 0x09, 0xea, 0x81, 0x02,
0x0a, 0x83, 0x01, 0x0a, 0x8a, 0x01, 0x0a, 0x92, 0x01, 0x0a,
0x94, 0x01, 0x0a, 0x21, 0x02, 0x1a, 0x23, 0x02, 0x2a, 0x25,
0x02, 0x81, 0x02, 0x0a, 0x26, 0x02, 0x0a, 0x27, 0x02, 0x0a,
0x2a, 0x02, 0x95, 0x03, 0x81, 0x02, 0x95, 0x05, 0x81, 0x01,
0xc0, 0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x02,
0x25, 0x01, 0x15, 0x00, 0x75, 0x01, 0x95, 0x08, 0x1a, 0xf1,
0x00, 0x2a, 0xf8, 0x00, 0x81, 0x02, 0xc0,
Device Found
type: 04f2 0760
path: /dev/hidraw1
serial_number: (null)
Manufacturer: Chicony
Product: Chicony USB Keyboard
Release: 100
Interface: 1
Usage (page): 0x1 (0xff00)
Bus type: 1 (USB)
Report Descriptor: (127 bytes)
0x06, 0x01, 0x00, 0x09, 0x80, 0xa1, 0x01, 0x85, 0x01, 0x19,
0x81, 0x29, 0x83, 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75,
0x01, 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, 0xc0,
0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x15, 0x00,
0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x19, 0xb5, 0x29, 0xb8,
0x09, 0xcd, 0x09, 0xe2, 0x09, 0xe9, 0x09, 0xea, 0x81, 0x02,
0x0a, 0x83, 0x01, 0x0a, 0x8a, 0x01, 0x0a, 0x92, 0x01, 0x0a,
0x94, 0x01, 0x0a, 0x21, 0x02, 0x1a, 0x23, 0x02, 0x2a, 0x25,
0x02, 0x81, 0x02, 0x0a, 0x26, 0x02, 0x0a, 0x27, 0x02, 0x0a,
0x2a, 0x02, 0x95, 0x03, 0x81, 0x02, 0x95, 0x05, 0x81, 0x01,
0xc0, 0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x02,
0x25, 0x01, 0x15, 0x00, 0x75, 0x01, 0x95, 0x08, 0x1a, 0xf1,
0x00, 0x2a, 0xf8, 0x00, 0x81, 0x02, 0xc0,
Device Found
type: 04d8 003f
path: /dev/hidraw0
serial_number: (null)
Manufacturer: Microchip Technology Inc.
Product: Microchip Technology Inc. Simple HID Device Demo
Release: 2
Interface: 0
Usage (page): 0x1 (0xff00)
Bus type: 1 (USB)
Report Descriptor: (28 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x19, 0x01, 0x29,
0x40, 0x15, 0x01, 0x25, 0x40, 0x75, 0x08, 0x95, 0x40, 0x81,
0x00, 0x19, 0x01, 0x29, 0x40, 0x91, 0x00, 0xc0,
Manufacturer String: Microchip Technology Inc.
Product String: Microchip Technology Inc. Simple HID Device Demo
Serial Number String: (0)
Report Descriptor: (28 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x19, 0x01, 0x29,
0x40, 0x15, 0x01, 0x25, 0x40, 0x75, 0x08, 0x95, 0x40, 0x81,
0x00, 0x19, 0x01, 0x29, 0x40, 0x91, 0x00, 0xc0,
Device Found
type: 04d8 003f
path: /dev/hidraw0
serial_number: (null)
Manufacturer: Microchip Technology Inc.
Product: Microchip Technology Inc. Simple HID Device Demo
Release: 2
Interface: 0
Usage (page): 0x1 (0xff00)
Bus type: 1 (USB)
Device Found
type: 04d8 003f
path: /dev/hidraw0
serial_number: (null)
Manufacturer: Microchip Technology Inc.
Product: Microchip Technology Inc. Simple HID Device Demo
Release: 2
Interface: 0
Usage (page): 0x1 (0xff00)
Bus type: 1 (USB)
Device Found
type: 04d8 003f
path: /dev/hidraw0
serial_number: (null)
Manufacturer: Microchip Technology Inc.
Product: Microchip Technology Inc. Simple HID Device Demo
Release: 2
Interface: 0
Usage (page): 0x1 (0xff00)
Bus type: 1 (USB)
Device Found
type: 04d8 003f
path: /dev/hidraw0
serial_number: (null)
Manufacturer: Microchip Technology Inc.
Product: Microchip Technology Inc. Simple HID Device Demo
Release: 2
Interface: 0
Usage (page): 0x1 (0xff00)
Bus type: 1 (USB)
Device Found
type: 04d8 003f
path: /dev/hidraw0
serial_number: (null)
Manufacturer: Microchip Technology Inc.
Product: Microchip Technology Inc. Simple HID Device Demo
Release: 2
Interface: 0
Usage (page): 0x1 (0xff00)
Bus type: 1 (USB)
Device Found
type: 04d8 003f
path: /dev/hidraw0
serial_number: (null)
Manufacturer: Microchip Technology Inc.
Product: Microchip Technology Inc. Simple HID Device Demo
Release: 2
Interface: 0
Usage (page): 0x1 (0xff00)
Bus type: 1 (USB)
Device Found
type: 04d8 003f
path: /dev/hidraw0
serial_number: (null)
Manufacturer: Microchip Technology Inc.
Product: Microchip Technology Inc. Simple HID Device Demo
Release: 2
Interface: 0
Usage (page): 0x1 (0xff00)
Bus type: 1 (USB)
Device Found
type: 04d8 003f
path: /dev/hidraw0
serial_number: (null)
Manufacturer: Microchip Technology Inc.
Product: Microchip Technology Inc. Simple HID Device Demo
Release: 2
Interface: 0
Usage (page): 0x1 (0xff00)
Bus type: 1 (USB)
Device Found
type: 04d8 003f
path: /dev/hidraw0
serial_number: (null)
Manufacturer: Microchip Technology Inc.
Product: Microchip Technology Inc. Simple HID Device Demo
Release: 2
Interface: 0
Usage (page): 0x1 (0xff00)
Bus type: 1 (USB)
Device Found
If I unlug the test device and plug in another device, then it is working.
mcuee@freebsd14:~/build/fx2hid/fx2hid_128bytes_report/fx2hid_128bytes $ sudo fxload -t fx2lp -I fx2hid.hex -D vid=0x04b4,pid=0x8613
mcuee@freebsd14:~/build/fx2hid/fx2hid_128bytes_report/fx2hid_128bytes $ sudo lsusb
Bus /dev/usb Device /dev/ugen0.2: ID 0925:1234 Lakeview Research
Bus /dev/usb Device /dev/ugen0.5: ID 13d3:3503 IMC Networks
Bus /dev/usb Device /dev/ugen0.4: ID 04f2:0760 Chicony Electronics Co., Ltd Acer KU-0760 Keyboard
Bus /dev/usb Device /dev/ugen0.3: ID 1ea7:0064 SHARKOON Technologies GmbH 2.4GHz Wireless rechargeable vertical mouse [More&Better]
Bus /dev/usb Device /dev/ugen0.1: ID 0000:0000
mcuee@freebsd14:~/build/fx2hid/fx2hid_128bytes_report/fx2hid_128bytes $ sudo ls -la /dev/hidraw*
crw------- 1 root operator 0x191 Mar 31 21:29 /dev/hidraw0
crw------- 1 root operator 0x180 Mar 31 21:08 /dev/hidraw1
mcuee@freebsd14:~/build/hidapi_pr730 $ sudo ./hidtest/hidtest-libusb
hidapi test/example tool. Compiled with hidapi version 0.15.0, runtime version 0.15.0.
Compile-time version matches runtime version of hidapi.
Device Found
type: 1ea7 0064
path: 0-3:1.0
serial_number: (null)
Manufacturer: (null)
Product: 2.4G Mouse
Release: 200
Interface: 0
Usage (page): 0x0 (0x0)
Bus type: 1 (USB)
Report Descriptor: (105 bytes)
0x06, 0xb5, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0xb5, 0x09,
0x02, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x07,
0x81, 0x02, 0x09, 0x02, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75,
0x08, 0x95, 0x07, 0x91, 0x02, 0xc0, 0x05, 0x01, 0x09, 0x02,
0xa1, 0x01, 0x85, 0x02, 0x09, 0x01, 0xa1, 0x00, 0x05, 0x09,
0x19, 0x01, 0x29, 0x08, 0x15, 0x00, 0x25, 0x01, 0x95, 0x08,
0x75, 0x01, 0x81, 0x02, 0x05, 0x01, 0x09, 0x30, 0x09, 0x31,
0x16, 0x01, 0xf8, 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02,
0x81, 0x06, 0x09, 0x38, 0x15, 0x81, 0x25, 0x7f, 0x75, 0x08,
0x95, 0x01, 0x81, 0x06, 0x05, 0x0c, 0x0a, 0x38, 0x02, 0x95,
0x01, 0x81, 0x06, 0xc0, 0xc0,
Device Found
type: 04f2 0760
path: 0-4:1.0
serial_number: (null)
Manufacturer: Chicony
Product: USB Keyboard
Release: 100
Interface: 0
Usage (page): 0x0 (0x0)
Bus type: 1 (USB)
Report Descriptor: (65 bytes)
0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x05, 0x07, 0x19, 0xe0,
0x29, 0xe7, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x08,
0x81, 0x02, 0x95, 0x01, 0x75, 0x08, 0x81, 0x01, 0x95, 0x03,
0x75, 0x01, 0x05, 0x08, 0x19, 0x01, 0x29, 0x03, 0x91, 0x02,
0x95, 0x05, 0x75, 0x01, 0x91, 0x01, 0x95, 0x06, 0x75, 0x08,
0x15, 0x00, 0x26, 0xff, 0x00, 0x05, 0x07, 0x19, 0x00, 0x2a,
0xff, 0x00, 0x81, 0x00, 0xc0,
Device Found
type: 04f2 0760
path: 0-4:1.1
serial_number: (null)
Manufacturer: Chicony
Product: USB Keyboard
Release: 100
Interface: 1
Usage (page): 0x0 (0x0)
Bus type: 1 (USB)
Report Descriptor: (127 bytes)
0x06, 0x01, 0x00, 0x09, 0x80, 0xa1, 0x01, 0x85, 0x01, 0x19,
0x81, 0x29, 0x83, 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75,
0x01, 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, 0xc0,
0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x15, 0x00,
0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x19, 0xb5, 0x29, 0xb8,
0x09, 0xcd, 0x09, 0xe2, 0x09, 0xe9, 0x09, 0xea, 0x81, 0x02,
0x0a, 0x83, 0x01, 0x0a, 0x8a, 0x01, 0x0a, 0x92, 0x01, 0x0a,
0x94, 0x01, 0x0a, 0x21, 0x02, 0x1a, 0x23, 0x02, 0x2a, 0x25,
0x02, 0x81, 0x02, 0x0a, 0x26, 0x02, 0x0a, 0x27, 0x02, 0x0a,
0x2a, 0x02, 0x95, 0x03, 0x81, 0x02, 0x95, 0x05, 0x81, 0x01,
0xc0, 0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x02,
0x25, 0x01, 0x15, 0x00, 0x75, 0x01, 0x95, 0x08, 0x1a, 0xf1,
0x00, 0x2a, 0xf8, 0x00, 0x81, 0x02, 0xc0,
Device Found
type: 0925 1234
path: 0-2:1.0
serial_number: (null)
Manufacturer: CYPRESS
Product: EZ-USB FX2 HID USBHIDIO
Release: 0
Interface: 0
Usage (page): 0x0 (0x0)
Bus type: 1 (USB)
Report Descriptor: (52 bytes)
0x06, 0xa0, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x09, 0x02, 0xa1,
0x00, 0x06, 0xa1, 0xff, 0x09, 0x03, 0x09, 0x04, 0x15, 0x80,
0x25, 0x7f, 0x35, 0x00, 0x45, 0xff, 0x75, 0x08, 0x95, 0x80,
0x81, 0x02, 0x09, 0x05, 0x09, 0x06, 0x15, 0x80, 0x25, 0x7f,
0x35, 0x00, 0x45, 0xff, 0x75, 0x08, 0x95, 0x80, 0x91, 0x02,
0xc0, 0xc0,
unable to open device
mcuee@freebsd14:~/build/hidapi_pr730 $ sudo ./hidtest/hidtest-hidraw
hidapi test/example tool. Compiled with hidapi version 0.15.0, runtime version 0.15.0.
Compile-time version matches runtime version of hidapi.
Device Found
type: 0925 1234
path: /dev/hidraw0
serial_number: (null)
Manufacturer: CYPRESS
Product: CYPRESS EZ-USB FX2 HID USBHIDIO
Release: 0
Interface: 0
Usage (page): 0x1 (0xffa0)
Bus type: 1 (USB)
Report Descriptor: (52 bytes)
0x06, 0xa0, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x09, 0x02, 0xa1,
0x00, 0x06, 0xa1, 0xff, 0x09, 0x03, 0x09, 0x04, 0x15, 0x80,
0x25, 0x7f, 0x35, 0x00, 0x45, 0xff, 0x75, 0x08, 0x95, 0x80,
0x81, 0x02, 0x09, 0x05, 0x09, 0x06, 0x15, 0x80, 0x25, 0x7f,
0x35, 0x00, 0x45, 0xff, 0x75, 0x08, 0x95, 0x80, 0x91, 0x02,
0xc0, 0xc0,
Device Found
type: 04f2 0760
path: /dev/hidraw1
serial_number: (null)
Manufacturer: Chicony
Product: Chicony USB Keyboard
Release: 100
Interface: 1
Usage (page): 0x80 (0x1)
Bus type: 1 (USB)
Report Descriptor: (127 bytes)
0x06, 0x01, 0x00, 0x09, 0x80, 0xa1, 0x01, 0x85, 0x01, 0x19,
0x81, 0x29, 0x83, 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75,
0x01, 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, 0xc0,
0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x15, 0x00,
0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x19, 0xb5, 0x29, 0xb8,
0x09, 0xcd, 0x09, 0xe2, 0x09, 0xe9, 0x09, 0xea, 0x81, 0x02,
0x0a, 0x83, 0x01, 0x0a, 0x8a, 0x01, 0x0a, 0x92, 0x01, 0x0a,
0x94, 0x01, 0x0a, 0x21, 0x02, 0x1a, 0x23, 0x02, 0x2a, 0x25,
0x02, 0x81, 0x02, 0x0a, 0x26, 0x02, 0x0a, 0x27, 0x02, 0x0a,
0x2a, 0x02, 0x95, 0x03, 0x81, 0x02, 0x95, 0x05, 0x81, 0x01,
0xc0, 0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x02,
0x25, 0x01, 0x15, 0x00, 0x75, 0x01, 0x95, 0x08, 0x1a, 0xf1,
0x00, 0x2a, 0xf8, 0x00, 0x81, 0x02, 0xc0,
Device Found
type: 04f2 0760
path: /dev/hidraw1
serial_number: (null)
Manufacturer: Chicony
Product: Chicony USB Keyboard
Release: 100
Interface: 1
Usage (page): 0x1 (0xc)
Bus type: 1 (USB)
Report Descriptor: (127 bytes)
0x06, 0x01, 0x00, 0x09, 0x80, 0xa1, 0x01, 0x85, 0x01, 0x19,
0x81, 0x29, 0x83, 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75,
0x01, 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, 0xc0,
0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x15, 0x00,
0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x19, 0xb5, 0x29, 0xb8,
0x09, 0xcd, 0x09, 0xe2, 0x09, 0xe9, 0x09, 0xea, 0x81, 0x02,
0x0a, 0x83, 0x01, 0x0a, 0x8a, 0x01, 0x0a, 0x92, 0x01, 0x0a,
0x94, 0x01, 0x0a, 0x21, 0x02, 0x1a, 0x23, 0x02, 0x2a, 0x25,
0x02, 0x81, 0x02, 0x0a, 0x26, 0x02, 0x0a, 0x27, 0x02, 0x0a,
0x2a, 0x02, 0x95, 0x03, 0x81, 0x02, 0x95, 0x05, 0x81, 0x01,
0xc0, 0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x02,
0x25, 0x01, 0x15, 0x00, 0x75, 0x01, 0x95, 0x08, 0x1a, 0xf1,
0x00, 0x2a, 0xf8, 0x00, 0x81, 0x02, 0xc0,
Device Found
type: 04f2 0760
path: /dev/hidraw1
serial_number: (null)
Manufacturer: Chicony
Product: Chicony USB Keyboard
Release: 100
Interface: 1
Usage (page): 0x1 (0xff00)
Bus type: 1 (USB)
Report Descriptor: (127 bytes)
0x06, 0x01, 0x00, 0x09, 0x80, 0xa1, 0x01, 0x85, 0x01, 0x19,
0x81, 0x29, 0x83, 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75,
0x01, 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, 0xc0,
0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x15, 0x00,
0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x19, 0xb5, 0x29, 0xb8,
0x09, 0xcd, 0x09, 0xe2, 0x09, 0xe9, 0x09, 0xea, 0x81, 0x02,
0x0a, 0x83, 0x01, 0x0a, 0x8a, 0x01, 0x0a, 0x92, 0x01, 0x0a,
0x94, 0x01, 0x0a, 0x21, 0x02, 0x1a, 0x23, 0x02, 0x2a, 0x25,
0x02, 0x81, 0x02, 0x0a, 0x26, 0x02, 0x0a, 0x27, 0x02, 0x0a,
0x2a, 0x02, 0x95, 0x03, 0x81, 0x02, 0x95, 0x05, 0x81, 0x01,
0xc0, 0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x02,
0x25, 0x01, 0x15, 0x00, 0x75, 0x01, 0x95, 0x08, 0x1a, 0xf1,
0x00, 0x2a, 0xf8, 0x00, 0x81, 0x02, 0xc0,
unable to open device
@aokblast
Looks like it is getting close. To reproduce the above issue, you can probably change hidtest example to open one of your HID device instead of 04d8:003f.
Using hidapitester and the FX2HID example to test.
Unfortunately the new hidraw backend does not work. The old libusb backend has the issue mentioned in #274.
mcuee@freebsd14:~/build/hidapitester $ gmake -f Makefile_pr730_hidraw_freebsd
cc -I/usr/local/include -I ../hidapi_pr730/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" -c ../hidapi_pr730/freebsd/hid.c -o ../hidapi_pr730/freebsd/hid.o
cc -I/usr/local/include -I ../hidapi_pr730/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" -c hidapitester.c -o hidapitester.o
cc -I/usr/local/include -I ../hidapi_pr730/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" ../hidapi_pr730/freebsd/hid.o hidapitester.o -o hidapitester -L/usr/local/lib -lusb -liconv -pthread
mcuee@freebsd14:~/build/hidapitester $ mv hidapitester hidapitester_freebsd_hidraw_pr730
mcuee@freebsd14:~/build/hidapitester $ gmake -f Makefile_pr730_hidraw_freebsd clean
rm -f ../hidapi_pr730/freebsd/hid.o hidapitester.o
rm -f hidapitester
mcuee@freebsd14:~/build/hidapitester $ gmake -f Makefile_pr730
cc -I/usr/local/include -I ../hidapi_pr730/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" -c hidapitester.c -o hidapitester.o
cc -I/usr/local/include -I ../hidapi_pr730/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" ../hidapi_pr730/libusb/hid.o hidapitester.o -o hidapitester -L/usr/local/lib -lusb -liconv -pthread
mcuee@freebsd14:~/build/hidapitester $ mv hidapitester hidapitester_freebsd_libusb_pr730
mcuee@freebsd14:~/build/hidapitester $ gmake -f Makefile_pr730 clean
rm -f ../hidapi_pr730/libusb/hid.o hidapitester.o
rm -f hidapitester
mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_freebsd_libusb_pr730 --vidpid 0925:1234 --open --buflen 256 -l 129 --send-output 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128 --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 129-bytes...wrote 129 bytes:
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
80
Reading up to 129-byte input report, 250 msec timeout...read 64 bytes:
41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 60
61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F 80
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00
Closing device
mcuee@freebsd14:~/build/hidapitester $ sudo ./hidapitester_freebsd_hidraw_pr730 --vidpid 0925:1234 --open --buflen 256 -l 129 --send-output 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128 --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 129-bytes...wrote 129 bytes:
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
80
Reading up to 129-byte input report, 250 msec timeout...read 0 bytes:
Closing device
The loop problem should be fix. Still investigate the read error.
Emm I cannot reproduce the problem. If the hid interrupt sucessfully triggered. I can receive the event by hid_read. At least I have tested with my keyboard.
The loop problem should be fix. Still investigate the read error.
Yes this has been fixed.
mcuee@freebsd14:~/build/hidapi_pr730 $ sudo sysctl hw.usb.usbhid.enable=1
hw.usb.usbhid.enable: 0 -> 1
mcuee@freebsd14:~/build/hidapi_pr730 $ sudo kldunload uhid
mcuee@freebsd14:~/build/hidapi_pr730 $ sudo lsusb
Bus /dev/usb Device /dev/ugen0.6: ID 04d8:003f Microchip Technology, Inc.
Bus /dev/usb Device /dev/ugen0.5: ID 13d3:3503 IMC Networks
Bus /dev/usb Device /dev/ugen0.4: ID 04f2:0760 Chicony Electronics Co., Ltd Acer KU-0760 Keyboard
Bus /dev/usb Device /dev/ugen0.3: ID 1ea7:0064 SHARKOON Technologies GmbH 2.4GHz Wireless rechargeable vertical mouse [More&Better]
Bus /dev/usb Device /dev/ugen0.2: ID 04b4:8613 Cypress Semiconductor Corp. CY7C68013 EZ-USB FX2 USB 2.0 Development Kit
Bus /dev/usb Device /dev/ugen0.1: ID 0000:0000
mcuee@freebsd14:~/build/hidapi_pr730 $ ls -la /dev/hid*
crw------- 1 root operator 0x185 Apr 1 07:16 /dev/hidraw0
crw------- 1 root operator 0x18d Apr 1 07:16 /dev/hidraw1
mcuee@freebsd14:~/build/hidapi_pr730 $ sudo ./hidtest/hidtest-hidraw
hidapi test/example tool. Compiled with hidapi version 0.15.0, runtime version 0.15.0.
Compile-time version matches runtime version of hidapi.
Device Found
type: 04f2 0760
path: /dev/hidraw1
serial_number: (null)
Manufacturer: Chicony
Product: Chicony USB Keyboard
Release: 100
Interface: 1
Usage (page): 0x80 (0x1)
Bus type: 1 (USB)
Report Descriptor: (127 bytes)
0x06, 0x01, 0x00, 0x09, 0x80, 0xa1, 0x01, 0x85, 0x01, 0x19,
0x81, 0x29, 0x83, 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75,
0x01, 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, 0xc0,
0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x15, 0x00,
0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x19, 0xb5, 0x29, 0xb8,
0x09, 0xcd, 0x09, 0xe2, 0x09, 0xe9, 0x09, 0xea, 0x81, 0x02,
0x0a, 0x83, 0x01, 0x0a, 0x8a, 0x01, 0x0a, 0x92, 0x01, 0x0a,
0x94, 0x01, 0x0a, 0x21, 0x02, 0x1a, 0x23, 0x02, 0x2a, 0x25,
0x02, 0x81, 0x02, 0x0a, 0x26, 0x02, 0x0a, 0x27, 0x02, 0x0a,
0x2a, 0x02, 0x95, 0x03, 0x81, 0x02, 0x95, 0x05, 0x81, 0x01,
0xc0, 0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x02,
0x25, 0x01, 0x15, 0x00, 0x75, 0x01, 0x95, 0x08, 0x1a, 0xf1,
0x00, 0x2a, 0xf8, 0x00, 0x81, 0x02, 0xc0,
Device Found
type: 04f2 0760
path: /dev/hidraw1
serial_number: (null)
Manufacturer: Chicony
Product: Chicony USB Keyboard
Release: 100
Interface: 1
Usage (page): 0x1 (0xc)
Bus type: 1 (USB)
Report Descriptor: (127 bytes)
0x06, 0x01, 0x00, 0x09, 0x80, 0xa1, 0x01, 0x85, 0x01, 0x19,
0x81, 0x29, 0x83, 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75,
0x01, 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, 0xc0,
0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x15, 0x00,
0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x19, 0xb5, 0x29, 0xb8,
0x09, 0xcd, 0x09, 0xe2, 0x09, 0xe9, 0x09, 0xea, 0x81, 0x02,
0x0a, 0x83, 0x01, 0x0a, 0x8a, 0x01, 0x0a, 0x92, 0x01, 0x0a,
0x94, 0x01, 0x0a, 0x21, 0x02, 0x1a, 0x23, 0x02, 0x2a, 0x25,
0x02, 0x81, 0x02, 0x0a, 0x26, 0x02, 0x0a, 0x27, 0x02, 0x0a,
0x2a, 0x02, 0x95, 0x03, 0x81, 0x02, 0x95, 0x05, 0x81, 0x01,
0xc0, 0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x02,
0x25, 0x01, 0x15, 0x00, 0x75, 0x01, 0x95, 0x08, 0x1a, 0xf1,
0x00, 0x2a, 0xf8, 0x00, 0x81, 0x02, 0xc0,
Device Found
type: 04f2 0760
path: /dev/hidraw1
serial_number: (null)
Manufacturer: Chicony
Product: Chicony USB Keyboard
Release: 100
Interface: 1
Usage (page): 0x1 (0xff00)
Bus type: 1 (USB)
Report Descriptor: (127 bytes)
0x06, 0x01, 0x00, 0x09, 0x80, 0xa1, 0x01, 0x85, 0x01, 0x19,
0x81, 0x29, 0x83, 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75,
0x01, 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, 0xc0,
0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x15, 0x00,
0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x19, 0xb5, 0x29, 0xb8,
0x09, 0xcd, 0x09, 0xe2, 0x09, 0xe9, 0x09, 0xea, 0x81, 0x02,
0x0a, 0x83, 0x01, 0x0a, 0x8a, 0x01, 0x0a, 0x92, 0x01, 0x0a,
0x94, 0x01, 0x0a, 0x21, 0x02, 0x1a, 0x23, 0x02, 0x2a, 0x25,
0x02, 0x81, 0x02, 0x0a, 0x26, 0x02, 0x0a, 0x27, 0x02, 0x0a,
0x2a, 0x02, 0x95, 0x03, 0x81, 0x02, 0x95, 0x05, 0x81, 0x01,
0xc0, 0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x02,
0x25, 0x01, 0x15, 0x00, 0x75, 0x01, 0x95, 0x08, 0x1a, 0xf1,
0x00, 0x2a, 0xf8, 0x00, 0x81, 0x02, 0xc0,
Device Found
type: 04d8 003f
path: /dev/hidraw0
serial_number: (null)
Manufacturer: Microchip Technology Inc.
Product: Microchip Technology Inc. Simple HID Device Demo
Release: 2
Interface: 0
Usage (page): 0x1 (0xff00)
Bus type: 1 (USB)
Report Descriptor: (28 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x19, 0x01, 0x29,
0x40, 0x15, 0x01, 0x25, 0x40, 0x75, 0x08, 0x95, 0x40, 0x81,
0x00, 0x19, 0x01, 0x29, 0x40, 0x91, 0x00, 0xc0,
Manufacturer String: Microchip Technology Inc.
Product String: Microchip Technology Inc. Simple HID Device Demo
Serial Number String: (0)
Report Descriptor: (28 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x19, 0x01, 0x29,
0x40, 0x15, 0x01, 0x25, 0x40, 0x75, 0x08, 0x95, 0x40, 0x81,
0x00, 0x19, 0x01, 0x29, 0x40, 0x91, 0x00, 0xc0,
Device Found
type: 04d8 003f
path: /dev/hidraw0
serial_number: (null)
Manufacturer: Microchip Technology Inc.
Product: Microchip Technology Inc. Simple HID Device Demo
Release: 2
Interface: 0
Usage (page): 0x1 (0xff00)
Bus type: 1 (USB)
Unable to read indexed string 1
Indexed String 1:
Unable to send a feature report: ioctl (SFEATURE): Input/output error
Unable to get a feature report: ioctl (GFEATURE): Input/output error
Unable to write(): Invalid argument
Unable to write()/2: Invalid argument
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
read() timeout