Write or transfer a buffer to an USB HID Device
write_success=hid_write(txBuff,_size);
Write USB HID Device
Thi function write or tranfers a buffer to the HID USB Device. The device has te be conncted and properly open before the writting.
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 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 | ![]() | ![]() |