<< hid_set_nonblocking HID Basic's commands HID Device Enumeration >>

USB Comunication Toolbox for Scilab >> HIDAPI Library > HID Basic's commands > hid_write

hid_write

Write or transfer a buffer to an USB HID Device

Calling Sequence

write_success=hid_write(txBuff,_size);

Parameters

txBuff
: Buffer to be write or transfer to the USB HID Device. The type of the data in the buffer has to be unsigned integer of 8 bits
_size
: Size of the buffer to write into the USB HID Device. The type of _size has to be unsigned integer of 8 bits
write_success
: retun 0 if device has been written and -1 if the device can not be written. Check the USB HID device is properly connected to the host computer and properly opened.

Description

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.

Examples

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

See Also

Authors

<< hid_set_nonblocking HID Basic's commands HID Device Enumeration >>