usb_readarray()

Reads data of USB device and saves it to array.

Syntax

usb_readarray(path, hnd);
usb_readarray(path, hnd, size);
usb_readarray(path, hnd, size, timeout);

Parameters

path USB device path.
hnd Array handle.
size Number of bytes to read. Special values are: (optional)
0 - USB packet size.
-1 - USB packets are read without interruption, data is read until buffer is full.
timeout Timeout value in milliseconds. After time is elapsed, any incoming USB data will not be read. (optional)
Return Value Number of bytes read.

Examples

hnd = array_new();
path = "\\?\hid#vid_045e&pid_028e&ig_00#8&1fa5fd5b&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}";
result = usb_readarray(path, hnd, 8, 100);
array_printdata(hnd);
array_delete(hnd);

result:

8; 0x00, 0x80, 0xFF, 0x7F, 0x00, 0x80, 0xFF, 0x7F

hnd = array_new();
path = "\\?\hid#vid_045e&pid_028e&ig_00#8&1fa5fd5b&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}";
result = usb_readarray(path, hnd, 0, 100);
array_printdata(hnd);
array_delete(hnd);

result:

14; 0x00, 0x80, 0xFF, 0x7F, 0x00, 0x80, 0xFF, 0x7F,0x00, 0x80, 0x00, 0x00, 0x00, 0x00

See also

usb_read, usb_readdata, array_new, array_delete, array_printdata