Changeset 135
- Timestamp:
- 07/11/08 17:03:25 (5 years ago)
- Location:
- branches/atorf/RWTHMindstormsNXT
- Files:
-
- 5 modified
-
COM_SendPacket.m (modified) (2 diffs)
-
checkStatusByte.m (modified) (2 diffs)
-
doc/programming/ToolboxVer2Guidelines.html (modified) (3 diffs)
-
doc/programming/ToolboxVer2Guidelines.m (modified) (1 diff)
-
private/getReplyLengthFromCmdByte.m (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/atorf/RWTHMindstormsNXT/COM_SendPacket.m
r128 r135 257 257 258 258 259 % if length(packet) > 1 && packet(2) == 0 && packet(1) > 1260 % warning('MATLAB:RWTHMindstormsNXT:USB:usingBTPacketForUSB', 'Seems like you are calling USB_SendAndCollectPacket with Bluetooth packet-data (containing two length bytes at the beginning not needed for USB). Ignoring this call...')261 % reply = [];262 % return263 % end%if264 265 259 NoReplyBit = 128; % hardcoded the old hex2dec('80') version for performance improvement 260 % find out if packet requests a reply 266 261 NeedReply = (bitand(packet(1), NoReplyBit) == 0); 267 262 263 % preallocate reply buffer 268 264 if NeedReply 269 265 reply = uint8(zeros(getReplyLengthFromCmdByte(packet(2)), 1)); % need to know the reply packet size … … 272 268 end%if 273 269 270 % find out if we've got a system or direct command 271 % remember: direct commands: 0x00, 0x80 (reply needed) 272 % system command: 0x01, 0x81 (reply needed) 273 % so check the least significant bit 274 if bitand(packet(1), 1) == 1 275 % the reason: at the moment we cannot send system commands! 276 warning('MATLAB:RWTHMindstormsNXT:notYetImplementedWarning', 'Cannot send system command (not yet implemented). At the moment only direct commands can be sent via USB on Windows. Use Bluetooth on Windows or Linux. Discarding packet, trying to continue...'); 277 return 278 end%if 274 279 275 280 [whatever command reply status] = calllib('fantom', 'nFANTOM100_iNXT_sendDirectCommand', h.Handle, NeedReply, packet(2:end)', length(packet), reply, length(reply), 0); -
branches/atorf/RWTHMindstormsNXT/checkStatusByte.m
r123 r135 52 52 f_resp_hex = num2str(dec2hex(f_resp, 2)); 53 53 switch (f_resp_hex) 54 % we introduce this 0x01 custom error (NOT from LEGO Mindstorms 55 % Documentation). It happens when we try to collect a packet but 56 % there were no data received (the statusbyte is then still 57 % initialized to 1): 58 case '01' 59 err_message = 'Empty packet: no data received'; 60 % standard errors from NXT documentation 54 61 case '20' 55 62 err_message = 'Pending communication transaction in progress'; … … 87 94 err_message = 'Bad arguments'; 88 95 otherwise 89 err_message = 'Unknown Error';96 err_message = 'Unknown Error'; 90 97 end 91 98 -
branches/atorf/RWTHMindstormsNXT/doc/programming/ToolboxVer2Guidelines.html
r134 r135 12 12 <title>RWTH - Mindstorms NXT Toolbox Version 2.00 beta Guidelines</title> 13 13 <meta name="generator" content="MATLAB 7.5"> 14 <meta name="date" content="2008-07-1 0">14 <meta name="date" content="2008-07-11"> 15 15 <meta name="m-file" content="ToolboxVer2Guidelines"><style> 16 16 … … 125 125 <p>The handle contains some function-handles (to store dynamic information using the principle of function closures). However 126 126 they are not to be used by normal users! It will later be explained to the advanced user how to retrieve connection statistics 127 (how many bytes and packets wer sent or received).127 (how many bytes and packets were sent or received). 128 128 </p> 129 129 <p>For now, the message is: We have got a huge handle struct, look at it if you want, but do not modify it. It does not matter … … 254 254 % using the principle of function closures). However they are not to be 255 255 % used by normal users! It will later be explained to the advanced user 256 % how to retrieve connection statistics (how many bytes and packets wer 256 % how to retrieve connection statistics (how many bytes and packets were 257 257 % sent or received). 258 258 -
branches/atorf/RWTHMindstormsNXT/doc/programming/ToolboxVer2Guidelines.m
r134 r135 64 64 % using the principle of function closures). However they are not to be 65 65 % used by normal users! It will later be explained to the advanced user 66 % how to retrieve connection statistics (how many bytes and packets wer 66 % how to retrieve connection statistics (how many bytes and packets were 67 67 % sent or received). 68 68 -
branches/atorf/RWTHMindstormsNXT/private/getReplyLengthFromCmdByte.m
r124 r135 40 40 %% Check parameter 41 41 if (byte < 0) || (byte > 20) 42 warning('MATLAB:RWTHMindstormsNXT:invalidCommandByte', 'CommandByte must be between 0 and 20, trying to continue...'); 42 % the warning below is correct, direct commands that need replies are 43 % indeed between bytes 0 and 20, but system commands are different, 44 % so we do not use this warning at the moment! 45 %warning('MATLAB:RWTHMindstormsNXT:invalidCommandByte', 'CommandByte must be between 0 and 20, trying to continue...'); 46 47 % no reply needed means length = 0, but this might change when 48 % implementing NXT_GetFirmwareVersion correctly... 43 49 len = 0; 44 50 return
