usb_read()

Reads data from USB device and prints its size to output window.

Syntax

usb_read(path);
usb_read(path, size);
usb_read(path, size, timeout);

Parameters

path USB device path.
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

Read 8 bytes of data:

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

result:

8

Read USB packet size:

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

result:

14

Read data until buffer is full:

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

result:

266

See also

usb_readdata, usb_readarray