Skip to content

Commit ba1df6c

Browse files
committed
Add ability to add bossdevice target in class constructor.
Remove need to open the SLRT Explorer. Updated main instructions.
1 parent 5caffa3 commit ba1df6c

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

README.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,15 @@ sync2brain's bossdevice RESEARCH Application Programmable Interface (API) for MA
1010
- Bossdevice firmware (MLDATX file)
1111

1212
## Initial configuration
13-
1. Open Simulink Real-Time Explorer, running `slrtExplorer` in the MATLAB command window
14-
2. In the list of target computers, select the default entry and in the Target Configurat tab
15-
1. Enter `bossdevice` into the name field
16-
2. Enter your bossdevice IP address. By default, this value is `192.168.7.5`
17-
5. Click on the Update Software button
13+
1. Install the bossdevice API from MATLAB with double click on `bossdevice-api-installer.mltbx`.
14+
2. In the MATLAB Command Window, call `bd = bossdevice` to add the bossdevice with the default settings to the list of targets. It will also try to establish connection. If you want to change either the name of the bossdevice or its default IP address in your local MATLAB settings, call `bd = bossdevice('myBossdevice','192.168.7.5')`.
15+
3. Click on the update command if prompted to update the software dependencies on the bossdevice.
1816

1917
## Get started
20-
1. Start MATLAB project with double-click on Bossdeviceapimatlab.prj
21-
2. Move or copy `mainmodel.mldatx` real-time application file into the work folder
22-
3. Create an instance of the main control class bossdevice `bd = bossdevice`
23-
4. Start firmware with `bd.start`
24-
5. Explore examples and methods available in the bossdevice object
18+
1. Create an instance of the main control class bossdevice `bd = bossdevice` in the MATLAB command window.
19+
2. If not found in the MATLAB path, please select `mainmodel.mldatx` real-time application.
20+
3. Start firmware with `bd.start`.
21+
4. Explore examples and methods available in the bossdevice object.
2522

2623
## User manual
2724
For a more detailed technical guidance about how to use the API, including installation, first steps and API description, please visit our [User manual](https://usermanual.sync2brain.com/).

toolbox/bossdevice.m

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,32 @@
3535
end
3636

3737
methods
38-
function obj = bossdevice(targetName)
38+
function obj = bossdevice(targetName, ipAddress, overwrite)
3939
%BOSSDEVICE Construct an instance of this class
4040
arguments
41-
targetName {mustBeTextScalar} = '';
41+
targetName {mustBeTextScalar} = 'bossdevice';
42+
ipAddress {mustBeTextScalar} = '192.168.7.5';
43+
overwrite logical {mustBeNumericOrLogical} = false;
4244
end
4345

4446
% Use default target if not passing any input argument
45-
if isempty(targetName)
46-
tgs = slrealtime.Targets;
47-
targetName = tgs.getDefaultTargetName;
47+
tgs = slrealtime.Targets;
48+
if ~contains(tgs.getTargetNames,targetName,'IgnoreCase',true)
49+
tgs.addTarget(targetName);
50+
isTargetNew = true;
51+
else
52+
isTargetNew = false;
4853
end
4954

5055
% Initialize and connect to the bossdevice
5156
obj.targetObject = slrealtime(targetName);
57+
if isTargetNew
58+
obj.targetObject.TargetSettings.address = ipAddress;
59+
fprintf('Added new target configuration for "%s" with IP address "%s".\n',targetName,ipAddress);
60+
elseif overwrite && ~strcmp(obj.targetObject.TargetSettings.address,ipAddress)
61+
obj.targetObject.TargetSettings.address = ipAddress;
62+
fprintf('Set new IP address "%s" on "%s".\n',ipAddress,targetName);
63+
end
5264
obj.targetObject.connect; % May ask to update if versions do not match
5365

5466
% Search firmware binary and prompt user if not found in MATLAB path

0 commit comments

Comments
 (0)