<< hid_get_feature_report HID Device Reports HID Device Strings >>

USB Comunication Toolbox for Scilab >> HIDAPI Library > HID Device Reports > hid_send_feature_report

hid_send_feature_report

Send a Feature report to the device.

Calling Sequence

send_feature_success=hid_send_feature_report(txBuff,_sized)

Parameters

txBuff
: The data to send, including the report number as the first byte. The type of the data in the buffer has to be unsigned integer of 8 bits
_size
: Size of the buffer to send into the USB HID Device. The type of _size has to be unsigned integer of 8 bits
send_feature_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

Send a Feature report to the device.

Examples

clc
n=5
txBuff=init_buff(n)
for i=1:n
    txBuff=setBuffValue(txBuff,i,i)
end
txBuff=setBuffValue(txBuff,1,hex2dec("00"))
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
nonblocking_success=hid_set_nonblocking(%t);
if ( nonblocking_success < 0 ) then
   disp("unable to set nonblocking");
else
   disp("device have been set nonblocking");
end
send_feature_success=hid_send_feature_report(txBuff,uint8(n)) 
if ( send_feature_success < 0 ) then
   disp("unable to send the feature report");
else
   disp("feature report sent");
end
[rxBuff,get_feature_success]=hid_get_feature_report(uint8(n));
if ( get_feature_success < 0 ) then
   disp("unable to get the feature report");
else
   disp("feature report received");
   disp(rxBuff);
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 ( exit_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
The result will be the next:
HIDAPI Library initialized   
Device Open
device have been set nonblocking
feature report sent
feature report received
0  0  241  0  0
device closed
HIDAPI Library have been freed all of the static data associated

See Also

Authors

<< hid_get_feature_report HID Device Reports HID Device Strings >>