Changeset 135

Show
Ignore:
Timestamp:
07/11/08 17:03:25 (5 years ago)
Author:
atorf
Message:

Added warning for not-supported system commands under Windows/USB (Fantom)

Location:
branches/atorf/RWTHMindstormsNXT
Files:
5 modified

Legend:

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

    r128 r135  
    257257 
    258258 
    259     % if length(packet) > 1 && packet(2) == 0 && packet(1) > 1 
    260     %     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     %     return 
    263     % end%if 
    264  
    265259    NoReplyBit = 128; % hardcoded the old hex2dec('80') version for performance improvement 
     260    % find out if packet requests a reply 
    266261    NeedReply = (bitand(packet(1), NoReplyBit) == 0); 
    267262 
     263    % preallocate reply buffer 
    268264    if NeedReply 
    269265        reply = uint8(zeros(getReplyLengthFromCmdByte(packet(2)), 1)); % need to know the reply packet size 
     
    272268    end%if 
    273269 
     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 
    274279 
    275280    [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  
    5252    f_resp_hex = num2str(dec2hex(f_resp, 2)); 
    5353    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 
    5461        case '20' 
    5562            err_message = 'Pending communication transaction in progress'; 
     
    8794            err_message = 'Bad arguments'; 
    8895        otherwise 
    89             err_message= 'Unknown Error'; 
     96            err_message = 'Unknown Error'; 
    9097    end 
    9198     
  • branches/atorf/RWTHMindstormsNXT/doc/programming/ToolboxVer2Guidelines.html

    r134 r135  
    1212      <title>RWTH - Mindstorms NXT Toolbox Version 2.00 beta Guidelines</title> 
    1313      <meta name="generator" content="MATLAB 7.5"> 
    14       <meta name="date" content="2008-07-10"> 
     14      <meta name="date" content="2008-07-11"> 
    1515      <meta name="m-file" content="ToolboxVer2Guidelines"><style> 
    1616 
     
    125125         <p>The handle contains some function-handles (to store dynamic information using the principle of function closures). However 
    126126            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). 
    128128         </p> 
    129129         <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 
     
    254254% using the principle of function closures). However they are not to be 
    255255% 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 
    257257% sent or received). 
    258258 
  • branches/atorf/RWTHMindstormsNXT/doc/programming/ToolboxVer2Guidelines.m

    r134 r135  
    6464% using the principle of function closures). However they are not to be 
    6565% 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 
    6767% sent or received). 
    6868 
  • branches/atorf/RWTHMindstormsNXT/private/getReplyLengthFromCmdByte.m

    r124 r135  
    4040%% Check parameter 
    4141if (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... 
    4349    len = 0; 
    4450    return