Write or transfer a buffer to an USB Device
write_success=bulk_write(txBuff,_size);
Write USB 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="0204"; VendorID=uint16(hex2dec(VendorID)); ProductID=uint16(hex2dec(ProductID)); enpIn=1; enpOut=1; enpIn=uint16(enpIn); enpOut=uint16(enpOut); timeout=100; timeout=int32(timeout); n=uint8(n) init_success=bulk_init(); if ( init_success < 0 ) then disp("unable to initialize the Libusb-1.0 Library"); return else disp("Libusb-1.0 Library initialized"); end open_success=bulk_open(VendorID,ProductID); if ( open_success < 0 ) then disp("unable to open device"); return else disp("device open"); end endP_success=bulk_set_endpoint(enpIn,enpOut); if ( endP_success < 0 ) then disp("unable to set end points"); else disp("end points has been set"); end write_success=bulk_write_timeout(txBuff,n,timeout); if ( write_success < 0 ) then disp("unable to write device"); else disp("device have been written"); end close_success=bulk_close(); if ( close_success < 0 ) then disp("unable to closed device"); else disp("device closed"); end exit_success=bulk_exit(); if ( init_success < 0 ) then disp("unable to free static data associated with Libusb-1.0 Library"); return else disp("Libusb-1.0 Library have been freed all of the static data associated"); end | ![]() | ![]() |