<< readusb USB Basic's commands writeusb >>

USB Comunication Toolbox for Scilab >> Scilab Macros > USB Basic's commands > write_timeoutusb

write_timeoutusb

Scilab macro's for bulk_write_timeout

Calling Sequence

write_success=writeusb(txBuff,_size,comu_type)

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
comu_type
: Comunication protocol comunication. This string identify which protocol use. HID, Bulk, Isochronous or CDC "hid", "bulk", "iso" and "cdc" respectively
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 to HID USB Device. Scilab macro's for hid_write

This is a macro designed to use the hid_write

The "bulk", "iso" and "cdc" implementantion are missing

Examples

n=5
txBuff=init_buff(n);
for i=1:n
    txBuff=setBuffValue(txBuff,i,i);
end
init_success=initusb("hid");
if ( init_success < 0 ) then
   disp("unable to initialize the HIDAPI Library");
   return
else
   disp("HIDAPI Library initialized");
end
open_success=openusb("04D8","010B","hid");
if ( open_success < 0 ) then
   disp("unable to open device");
   return
else
   disp("device open");
end
write_success=writeusb(txBuff,n,"hid");
if ( write_success < 0 ) then
   disp("unable to write device");
else
   disp("device have been  written");
end
close_success=closeusb("hid");  
if ( close_success < 0 ) then
   disp("unable to closed device");
else
   disp("device closed");
end
exit_success=exitusb("hid");
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

<< readusb USB Basic's commands writeusb >>