Read or receive a buffer from an USB HID Device with timeout
[rxBuff,read_success]=hid_read_timeout(_size,_timeout);
Read an HID USB Device
Read the data buffer sent by the USB HID Device
Keep in mind that USB 2.0 and older are a master/slave protocol. The USB device will send data only if the master (the host, its mean the computer), asked for it.
n=5; txBuff=init_buff(n); for i=1:n txBuff=setBuffValue(txBuff,i,i); end VendorID="04D8"; ProductID="010B"; VendorID=uint16(hex2dec(VendorID)); ProductID=uint16(hex2dec(ProductID)); init_success=hid_init(); if ( init_success < 0 ) then disp("unable to initialize the HIDAPI Library"); return else disp("HIDAPI Library initialized"); end open_success=hid_open(VendorID,ProductID); if ( open_success < 0 ) then disp("unable to open device"); return else disp("device open"); end write_success=hid_write(txBuff,uint8(n)); if ( write_success < 0 ) then disp("unable to write device"); else disp("device have been written"); end [rxBuff,read_success]=hid_read(uint8(n),int32(100)); if ( read_success < 0 ) then disp("unable to read device"); else disp("device have been read"); disp(rxBuff); end close_success=hid_close(); if ( close_success < 0 ) then disp("unable to closed device"); else disp("device closed"); end exit_success=hid_exit(); if ( init_success < 0 ) then disp("unable to free static data associated with HIDAPI Library"); return else disp("HIDAPI Library have been freed all of the static data associated"); end | ![]() | ![]() |