<< openusb USB Basic's commands readusb >>

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

read_timeoutusb

Scilab macro's for hid_read_timeout

Calling Sequence

[rxBuff,read_success]=readusb(_size,_timeout,comu_type)

Parameters

rxBuff
: Buffer to be read 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 be read into the USB HID Device. The type of _size has to be unsigned integer of 8 bits
_timeout
: milliseconds timeout in milliseconds or -1 for blocking wait.
comu_type
: Comunication protocol comunication. This string identify which protocol use. HID, Bulk, Isochronous or CDC "hid", "bulk", "iso" and "cdc" respectively
read_success
: retun 0 if device has been read and -1 if the device can not be read. Check the USB HID device is properly connected to the host computer and properly opened.

Description

Read or receive a buffer from an USB HID Device. Scilab macro's for hid_read_timeout

This is a macro designed to use the hid_read_timeout

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
[rxBuff,read_timeout_success]=read_timeoutusb(n,100,"hid");
if ( read_timeout_success < 0 ) then
   disp("unable to read device");
else
   disp("device have been read");
   disp(rxBuff);
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

<< openusb USB Basic's commands readusb >>