Changeset 122

Show
Ignore:
Timestamp:
07/05/08 13:32:38 (5 years ago)
Author:
behrens
Message:

add NXT_Get_Firmware_Version.m, add NXT_PlaySoundFile.m, add NXT_StopSoundPlayback.m (COM_* version)
add LUT entry NXTWRITE_IO_MAP (not supported yet)

Location:
branches/atorf/RWTHMindstormsNXT
Files:
1 modified
3 copied

Legend:

Unmodified
Added
Removed
  • branches/atorf/RWTHMindstormsNXT/NXT_Get_Firmware_Version.m

    r74 r122  
    1414%   Bluetooth connection |handle|. This should be a serial handle on a PC system and a file handle on a Linux system. 
    1515% 
    16 %   If no Bluetooth |handle| is specified the default one (|BT_GetDefaultHandle|) is used. 
     16%   If no Bluetooth |handle| is specified the default one (|COM_GetDefaultHandle|) is used. 
    1717% 
    1818% Examples 
     
    2222%+   [protocol_version firmware_version] = NXT_Get_Firmware_Version(bt_handle); 
    2323% 
    24 % See also: BT_GetDefaultHandle 
     24% See also: COM_GetDefaultHandle 
    2525% 
    2626% Signature 
     
    4949% check if bluetooth handle is given; if not use default one 
    5050if nargin > 0 
    51     if (ispc && isa(varargin{1}, 'serial')) || (isunix && isscalar(varargin{1})) 
    52         handle = varargin{1}; 
    53     else 
    54         error('MATLAB:RWTHMindstormsNXT:Bluetooth:invalidHandle', 'Optional NXT bluetooth handle specified, but not a valid serial port handle'); 
    55     end%if 
     51    handle = varargin{1}; 
    5652else 
    57     handle = BT_GetDefaultHandle; 
     53    handle = COM_GetDefaultHandle; 
    5854end%if 
    5955 
     
    7874% check if bluetooth handle is given; if not use default one 
    7975if nargin > 0 
    80     if (ispc && isa(varargin{1}, 'serial')) || (isunix && isscalar(varargin{1})) 
    81         handle = varargin{1}; 
    82     else 
    83         error('MATLAB:RWTHMindstormsNXT:Bluetooth:invalidHandle', 'Optional NXT bluetooth handle specified, but not a valid serial port handle'); 
    84     end%if 
     76    handle = varargin{1}; 
    8577else 
    86     handle = BT_GetDefaultHandle; 
     78    handle = COM_GetDefaultHandle; 
    8779end%if 
    8880 
     
    9385 
    9486%% Pack bluetooth packet 
    95 packet = BT_CreatePacket(type, cmd, 'reply', []);  
     87packet = COM_CreatePacket(type, cmd, 'reply', []);  
    9688textOut(sprintf('+ Requesting firmware version...\n')); 
    9789 
    9890 
    9991%% Send bluetooth packet 
    100 BT_SendPacket(packet, handle); 
     92COM_SendPacket(packet, handle); 
    10193 
    10294end % end function 
     
    115107% check if bluetooth handle is given; if not use default one 
    116108if nargin > 0 
    117     if (ispc && isa(varargin{1}, 'serial')) || (isunix && isscalar(varargin{1})) 
    118         handle = varargin{1}; 
    119     else 
    120         error('MATLAB:RWTHMindstormsNXT:Bluetooth:invalidHandle', 'Optional NXT bluetooth handle specified, but not a valid serial port handle'); 
    121     end%if 
     109   handle = varargin{1}; 
    122110else 
    123     handle = BT_GetDefaultHandle; 
     111    handle = COM_GetDefaultHandle; 
    124112end%if 
    125113 
     
    129117 
    130118%% Collect bluetooth packet 
    131 [type cmd status content] = BT_CollectPacket(handle); 
     119[type cmd status content] = COM_CollectPacket(handle); 
    132120 
    133121%% Check if packet is the right one 
  • branches/atorf/RWTHMindstormsNXT/NXT_PlaySoundFile.m

    r74 r122  
    1616%   This should be a serial handle on a PC system and a file handle on a Linux system.  
    1717% 
    18 %   If no Bluetooth |bt_handle| is specified the default one (|BT_GetDefaultHandle|) is used. 
     18%   If no Bluetooth |bt_handle| is specified the default one (|COM_GetDefaultHandle|) is used. 
    1919% 
    2020% For more details see the official LEGO Mindstorms communication protocol. 
     
    5353% check if bluetooth handle is given. if not use default one 
    5454if nargin > 2 
    55     if (ispc && isa(varargin{1}, 'serial')) || (isunix && isscalar(varargin{1})) 
    56         handle = varargin{1}; 
    57     else 
    58         error('MATLAB:RWTHMindstormsNXT:Bluetooth:invalidHandle', 'Optional NXT bluetooth handle specified, but not a valid serial port handle'); 
    59     end%if 
     55    handle = varargin{1}; 
    6056else 
    61     handle = BT_GetDefaultHandle; 
     57    handle = COM_GetDefaultHandle; 
    6258end%if 
    6359 
     
    106102 
    107103%% Pack bluetooth packet 
    108 packet = BT_CreatePacket(type, cmd, 'dontreply', payload);  
     104packet = COM_CreatePacket(type, cmd, 'dontreply', payload);  
    109105textOut(sprintf('+ Playing sound file: %s \n', filename)); 
    110106 
    111107 
    112108%% Send bluetooth packet 
    113 BT_SendPacket(packet, handle); 
     109COM_SendPacket(packet, handle); 
    114110 
    115111end%function 
  • branches/atorf/RWTHMindstormsNXT/NXT_StopSoundPlayback.m

    r74 r122  
    1313%   Bluetooth |handle| (serial handle (PC) / file handle (Linux)). 
    1414% 
    15 %   If no Bluetooth |handle| is specified the default one (|BT_GetDefaultHandle|) is used. 
     15%   If no Bluetooth |handle| is specified the default one (|COM_GetDefaultHandle|) is used. 
    1616% 
    1717% For more details see the official LEGO Mindstorms communication protocol. 
     
    2323%+   NXT_StopSoundPlayback(bt_handle); 
    2424% 
    25 % See also: NXT_PlaySoundFile, NXT_PlayTone, BT_GetDefaultHandle 
     25% See also: NXT_PlaySoundFile, NXT_PlayTone, COM_GetDefaultHandle 
    2626% 
    2727% Signature 
     
    5050% check if bluetooth handle is given; if not use default one 
    5151if nargin > 0 
    52     if (ispc && isa(varargin{1}, 'serial')) || (isunix && isscalar(varargin{1})) 
    53         handle = varargin{1}; 
    54     else 
    55         error('MATLAB:RWTHMindstormsNXT:Bluetooth:invalidHandle', 'Optional NXT bluetooth handle specified, but not a valid serial port handle'); 
    56     end%if 
     52    handle = varargin{1}; 
    5753else 
    58     handle = BT_GetDefaultHandle; 
     54    handle = COM_GetDefaultHandle; 
    5955end%if 
    6056 
     
    6864 
    6965%% Pack bluetooth packet 
    70 packet = BT_CreatePacket(type, cmd, 'dontreply', content);  
     66packet = COM_CreatePacket(type, cmd, 'dontreply', content);  
    7167textOut(sprintf('+ Stop sound playback...\n')); 
    7268 
    7369 
    7470%% Send bluetooth packet 
    75 BT_SendPacket(packet, handle); 
     71COM_SendPacket(packet, handle); 
    7672 
    7773end%function 
  • branches/atorf/RWTHMindstormsNXT/private/name2commandbytes.m

    r45 r122  
    3939 
    4040NXT__READ_IO_MAP            = [1; 148];  %#ok<NASGU> %hex2dec(['01'; '94']); 
    41  
     41NXT__WRITE_IO_MAP           = [1; 149];  %#ok<NASGU> %hex2dec(['01'; '95']); 
    4242 
    4343%% Direct commands