usbBrickIO¶
-
class
usbBrickIO
(varargin)¶ - List of methods:
USB interface between MATLAB and the brick
Notes
- Uses the hid library implementation in hidapi.m
- The default parameters should always work when you try to connect to an EV3 brick, so in nearly all use-cases, the constructor does not need any parameters (besides ‘debug’ eventually).
-
debug
¶ If true, each open/close/read/write-call will be noted in the console. Defaults to false.
Type: bool
-
vendorID
¶ Vendor-ID of the USB device. Defaults to 0x694 (EV3 vendor ID).
Type: numeric
-
productID
¶ Product-ID of the USB device. Defaults to 0x0005 (EV3 product ID).
Type: numeric
-
nReadBuffer
¶ Read-buffer size in bytes. Defaults to 1024.
Type: numeric
-
nWriteBuffer
¶ Write-buffer size in bytes. Needs to be 1 Byte bigger than actual packet. Defaults to 1025 (EV3 USB maximum packet size = 1024).
Type: numeric
-
timeOut
¶ Milliseconds after which a timeout-error occurs if no packet could be read. Defaults to 10000.
Type: numeric >= 0
Examples: % Connecting via USB commHandle = usbBrickIO(); % Connecting via USB with enabled debug output commHandle = usbBrickIO('debug', true);
-
close
(brickIO)¶ Closes the usb connection the brick through the hidapi interface.
-
open
(brickIO)¶ Opens the usb connection to the brick through the hidapi interface.
-
read
(brickIO)¶ Reads data from the brick through usb using the hidapi interface and returns the data in uint8 format.
-
setProperties
(brickIO, varargin)¶ Sets multiple usbBrickIO properties at once using MATLAB’s inputParser.
The syntax is as follows: commHandle.setProperties(‘propertyName1’, propertyValue1, ‘propertyName2’, propertyValue2, …). Valid, optional properties are: debug, vendorID, productID, nReadBuffer, nWriteBuffer, timeOut.
See also USBBRICKIO.DEBUG, USBBRICKIO.VENDORID, USBBRICKIO.PRODUCTID, USBBRICKIO.NREADBUFFER, USBBRICKIO.NWRITEBUFFER, USBBRICKIO.TIMEOUT
-
write
(brickIO, wmsg)¶ Writes data to the brick through usb using the hidapi interface.
Parameters: wmsg (uint8 array) – Data to be written to the brick via usb