Changeset 122
- Timestamp:
- 07/05/08 13:32:38 (5 years ago)
- Location:
- branches/atorf/RWTHMindstormsNXT
- Files:
-
- 1 modified
- 3 copied
-
NXT_Get_Firmware_Version.m (copied) (copied from branches/behrens/RWTHMindstormsNXT/NXT_Get_Firmware_Version.m) (7 diffs)
-
NXT_PlaySoundFile.m (copied) (copied from branches/behrens/RWTHMindstormsNXT/NXT_PlaySoundFile.m) (3 diffs)
-
NXT_StopSoundPlayback.m (copied) (copied from branches/behrens/RWTHMindstormsNXT/NXT_StopSoundPlayback.m) (4 diffs)
-
private/name2commandbytes.m (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/atorf/RWTHMindstormsNXT/NXT_Get_Firmware_Version.m
r74 r122 14 14 % Bluetooth connection |handle|. This should be a serial handle on a PC system and a file handle on a Linux system. 15 15 % 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. 17 17 % 18 18 % Examples … … 22 22 %+ [protocol_version firmware_version] = NXT_Get_Firmware_Version(bt_handle); 23 23 % 24 % See also: BT_GetDefaultHandle24 % See also: COM_GetDefaultHandle 25 25 % 26 26 % Signature … … 49 49 % check if bluetooth handle is given; if not use default one 50 50 if 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}; 56 52 else 57 handle = BT_GetDefaultHandle;53 handle = COM_GetDefaultHandle; 58 54 end%if 59 55 … … 78 74 % check if bluetooth handle is given; if not use default one 79 75 if 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}; 85 77 else 86 handle = BT_GetDefaultHandle;78 handle = COM_GetDefaultHandle; 87 79 end%if 88 80 … … 93 85 94 86 %% Pack bluetooth packet 95 packet = BT_CreatePacket(type, cmd, 'reply', []);87 packet = COM_CreatePacket(type, cmd, 'reply', []); 96 88 textOut(sprintf('+ Requesting firmware version...\n')); 97 89 98 90 99 91 %% Send bluetooth packet 100 BT_SendPacket(packet, handle);92 COM_SendPacket(packet, handle); 101 93 102 94 end % end function … … 115 107 % check if bluetooth handle is given; if not use default one 116 108 if 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}; 122 110 else 123 handle = BT_GetDefaultHandle;111 handle = COM_GetDefaultHandle; 124 112 end%if 125 113 … … 129 117 130 118 %% Collect bluetooth packet 131 [type cmd status content] = BT_CollectPacket(handle);119 [type cmd status content] = COM_CollectPacket(handle); 132 120 133 121 %% Check if packet is the right one -
branches/atorf/RWTHMindstormsNXT/NXT_PlaySoundFile.m
r74 r122 16 16 % This should be a serial handle on a PC system and a file handle on a Linux system. 17 17 % 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. 19 19 % 20 20 % For more details see the official LEGO Mindstorms communication protocol. … … 53 53 % check if bluetooth handle is given. if not use default one 54 54 if 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}; 60 56 else 61 handle = BT_GetDefaultHandle;57 handle = COM_GetDefaultHandle; 62 58 end%if 63 59 … … 106 102 107 103 %% Pack bluetooth packet 108 packet = BT_CreatePacket(type, cmd, 'dontreply', payload);104 packet = COM_CreatePacket(type, cmd, 'dontreply', payload); 109 105 textOut(sprintf('+ Playing sound file: %s \n', filename)); 110 106 111 107 112 108 %% Send bluetooth packet 113 BT_SendPacket(packet, handle);109 COM_SendPacket(packet, handle); 114 110 115 111 end%function -
branches/atorf/RWTHMindstormsNXT/NXT_StopSoundPlayback.m
r74 r122 13 13 % Bluetooth |handle| (serial handle (PC) / file handle (Linux)). 14 14 % 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. 16 16 % 17 17 % For more details see the official LEGO Mindstorms communication protocol. … … 23 23 %+ NXT_StopSoundPlayback(bt_handle); 24 24 % 25 % See also: NXT_PlaySoundFile, NXT_PlayTone, BT_GetDefaultHandle25 % See also: NXT_PlaySoundFile, NXT_PlayTone, COM_GetDefaultHandle 26 26 % 27 27 % Signature … … 50 50 % check if bluetooth handle is given; if not use default one 51 51 if 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}; 57 53 else 58 handle = BT_GetDefaultHandle;54 handle = COM_GetDefaultHandle; 59 55 end%if 60 56 … … 68 64 69 65 %% Pack bluetooth packet 70 packet = BT_CreatePacket(type, cmd, 'dontreply', content);66 packet = COM_CreatePacket(type, cmd, 'dontreply', content); 71 67 textOut(sprintf('+ Stop sound playback...\n')); 72 68 73 69 74 70 %% Send bluetooth packet 75 BT_SendPacket(packet, handle);71 COM_SendPacket(packet, handle); 76 72 77 73 end%function -
branches/atorf/RWTHMindstormsNXT/private/name2commandbytes.m
r45 r122 39 39 40 40 NXT__READ_IO_MAP = [1; 148]; %#ok<NASGU> %hex2dec(['01'; '94']); 41 41 NXT__WRITE_IO_MAP = [1; 149]; %#ok<NASGU> %hex2dec(['01'; '95']); 42 42 43 43 %% Direct commands
