btBrickIO
(varargin)¶Bluetooth interface between MATLAB and the brick
Notes
Connects to the bluetooth module on the host through a serial connection. Hence be sure that a serial connection to the bluetooth module can be made. Also be sure that the bluetooth module has been paired to the brick before trying to connect.
For general information, see also BrickIO
.
debug
¶bool – If true, each open/close/read/write-call will be shown in the console. Defaults to false.
serialPort
¶string – Path to the serial-port object. Only needed when using MATLAB's serial class (i.e. on linux/mac). Defaults to '/dev/rfcomm0'.
deviceName
¶string – Name of the BT-device = the brick. Only needed when using the Instrument Control toolbox (i.e. on windows). Defaults to 'EV3'.
channel
¶numeric > 0 – BT-channel of the connected BT-device. Only needed when using the Instrument Control toolbox (i.e. on windows). Defaults to 1.
timeOut
¶numeric >= 0 – seconds after which a timeout-error occurs if no packet could be read. Defaults to 10.
backend
¶'serial'|'instrumentControl' – Backend this implementation is based on. Is automatically chosen depending on the OS. Defaults to 'serial' on linux/mac systems, and to 'instrumentControl' on windows systems.
Examples
% Connecting on windows
commHandle = btBrickIO('deviceName', 'MyEV3', 'channel', 1); %
% Connecting on windows using MATLABs default serial port implementation for testing
commHandle = btBrickIO('deviceName', 'MyEV3', 'channel', 1, 'backend', 'serial'); %
% Connecting on mac/linux
commHandle = btBrickIO('serPort', '/dev/rfcomm0'); %
close
(brickIO)¶Closes the bluetooth connection the brick using fclose.
open
(brickIO)¶Opens the bluetooth connection to the brick using fopen.
read
(brickIO)¶Reads data from the brick through bluetooth via fread and returns the data in uint8 format.
setProperties
(brickIO, varargin)¶Sets multiple btBrickIO properties at once using MATLAB's inputParser.
The syntax is as follows: commHandle.setProperties('propertyName1', propertyValue1, 'propertyName2', propertyValue2, ...). Valid, optional properties are: debug, serPort, deviceName, channel, timeout.
See also BTBRICKIO.DEBUG, BTBRICKIO.SERIALPORT, BTBRICKIO.DEVICENAME, BTBRICKIO.CHANNEL, BTBRICKIO.TIMEOUT
write
(brickIO, wmsg)¶Writes data to the brick through bluetooth via fwrite.
Parameters: | wmsg (uint8 array) – Data to be written to the brick via bluetooth |
---|