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

bool – If true, each open/close/read/write-call will be noted in the console. Defaults to false.

vendorID

numeric – Vendor-ID of the USB device. Defaults to 0x694 (EV3 vendor ID).

productID

numeric – Product-ID of the USB device. Defaults to 0x0005 (EV3 product ID).

nReadBuffer

numeric – Read-buffer size in bytes. Defaults to 1024.

nWriteBuffer

numeric – Write-buffer size in bytes. Needs to be 1 Byte bigger than actual packet. Defaults to 1025 (EV3 USB maximum packet size = 1024).

timeOut

numeric >= 0 – Milliseconds after which a timeout-error occurs if no packet could be read. Defaults to 10000.

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