root/branches/atorf/RWTHMindstormsNXT/private/name2commandbytes.m @ 45

Revision 45, 4.2 KB (checked in by atorf, 5 years ago)

Updated / synced HTML help (FunctionsOverview etc) in trunk and branch

Line 
1function [type cmd bytes] = name2commandbytes(name)
2% Determines command bytes from given command name
3%
4% Syntax
5%   |[type cmd bytes] = name2commandbytes(name)|
6%
7% Description
8%   The function names are directly taken from the LEGO
9%   Mindstorms Bluetooth SDK and Direct Commands Appendix
10%
11% Signature
12%   Author: Linus Atorf (see AUTHORS)
13%   Date: 2007/10/14
14%   Copyright: 2007, RWTH Aachen University
15%
16;
17%
18% ***********************************************************************************************
19% *  This file is part of the RWTH - Mindstorms NXT Toolbox.                                    *
20% *                                                                                             *
21% *  The RWTH - Mindstorms NXT Toolbox is free software: you can redistribute it and/or modify  *
22% *  it under the terms of the GNU General Public License as published by the Free Software     *
23% *  Foundation, either version 3 of the License, or (at your option) any later version.        *
24% *                                                                                             *
25% *  The RWTH - Mindstorms NXT Toolbox is distributed in the hope that it will be useful,       *
26% *  but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS  *
27% *  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
28% *                                                                                             *
29% *  You should have received a copy of the GNU General Public License along with the           *
30% *  RWTH - Mindstorms NXT Toolbox. If not, see <http://www.gnu.org/licenses/>.                 *
31% ***********************************************************************************************
32
33%% System commands
34NXT__GET_FIRMWARE_VERSION   = [1; 136]; %#ok<NASGU> %hex2dec(['01'; '88']);
35NXT__SET_BRICK_NAME         = [1; 152]; %#ok<NASGU> %hex2dec(['01'; '98']);
36NXT__GET_DEVICE_INFO        = [1; 155]; %#ok<NASGU> %hex2dec(['01'; '9B']);
37NXT__POLL_COMMAND_LENGTH    = [1; 161]; %#ok<NASGU> %hex2dec(['01'; 'A1']);
38NXT__POLL_COMMAND           = [1; 162]; %#ok<NASGU> %hex2dec(['01'; 'A2']);
39
40NXT__READ_IO_MAP            = [1; 148];  %#ok<NASGU> %hex2dec(['01'; '94']);
41
42
43%% Direct commands
44NXT__STARTPROGRAM           = [0; 0];   %#ok<NASGU> %hex2dec(['00'; '00']);
45NXT__STOPPROGRAM            = [0; 1];   %#ok<NASGU> %hex2dec(['00'; '01']);
46NXT__PLAYSOUNDFILE          = [0; 2];   %#ok<NASGU> %hex2dec(['00'; '02']);
47NXT__PLAYTONE               = [0; 3];   %#ok<NASGU> %hex2dec(['00'; '03']);
48NXT__SETOUTPUTSTATE         = [0; 4];   %#ok<NASGU> %hex2dec(['00'; '04']);
49NXT__SETINPUTMODE           = [0; 5];   %#ok<NASGU> %hex2dec(['00'; '05']);
50NXT__GETOUTPUTSTATE         = [0; 6];   %#ok<NASGU> %hex2dec(['00'; '06']);
51NXT__GETINPUTVALUES         = [0; 7];   %#ok<NASGU> %hex2dec(['00'; '07']);
52NXT__RESETINPUTSCALEDVALUE  = [0; 8];   %#ok<NASGU> %hex2dec(['00'; '08']);
53NXT__MESSAGEWRITE           = [0; 9];   %#ok<NASGU> %hex2dec(['00'; '09']);
54NXT__RESETMOTORPOSITION     = [0; 10];  %#ok<NASGU> %hex2dec(['00'; '0A']);
55NXT__GETBATTERYLEVEL        = [0; 11];  %#ok<NASGU> %hex2dec(['00'; '0B']);
56NXT__STOPSOUNDPLAYBACK      = [0; 12];  %#ok<NASGU> %hex2dec(['00'; '0C']);
57NXT__KEEPALIVE              = [0; 13];  %#ok<NASGU> %hex2dec(['00'; '0D']);
58NXT__LSGETSTATUS            = [0; 14];  %#ok<NASGU> %hex2dec(['00'; '0E']);
59NXT__LSWRITE                = [0; 15];  %#ok<NASGU> %hex2dec(['00'; '0F']);
60NXT__LSREAD                 = [0; 16];  %#ok<NASGU> %hex2dec(['00'; '10']);
61NXT__GETCURRENTPROGRAMNAME  = [0; 17];  %#ok<NASGU> %hex2dec(['00'; '11']);
62NXT__MESSAGEREAD            = [0; 19];  %#ok<NASGU> %hex2dec(['00'; '13']);
63
64
65%% Parameter check
66%NOTE this error-check can be ommitted for a little speedup: about 1ms for
67%every 10 calls... so probably not worth it...
68if ~exist(['NXT__' name], 'var') || ~isvector(['NXT__' name])
69    error('MATLAB:RWTHMindstormsNXT:invalidNXTCommandName', 'Unknown NXT function or direct command "%s". See inside this method (private/name2commandbytes.m) for a list.', name)
70end%if
71
72
73%% Determine command bytes
74bytes = eval(['NXT__' name]);
75type  = bytes(1);
76cmd   = bytes(2);
77
78end%function
Note: See TracBrowser for help on using the browser.