Changeset 21057

Show
Ignore:
Timestamp:
02/29/08 15:43:01 (9 months ago)
Author:
patrick
Message:

MF22 r21056: Fixed a crash caused by hardware having sensors with FBB

addresses that are not in a zero-based, monotonically increasing
order. A case has been observed where a MotionStar? chassis has N
birds with FBB addresses in the range [2, N + 1]. The previous
code assumed that FBB addresses were always in the range [0, N).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • juggler/trunk/modules/gadgeteer/drivers/Ascension/MotionStar/MotionStarStandalone.cpp

    r20974 r21057  
    12161216      mNumSensors = 0; 
    12171217      mAddrToSensorIdMap.clear(); 
    1218       mAddrToSensorIdMap.resize(flock_number, -1); 
    12191218 
    12201219      for ( std::vector<FBB::Device*>::iterator b = m_birds.begin(); 
     
    12741273            cur_dev->addr = i + 1; 
    12751274 
     1275            // If the device has a sensor, map its FBB address to a 
     1276            // zero-based, sequential value. 
    12761277            if ( cur_dev->has_sensor ) 
    12771278            { 
  • juggler/trunk/modules/gadgeteer/drivers/Ascension/MotionStar/MotionStarStandalone.h

    r20974 r21057  
    3434 
    3535#include <vpr/vpr.h> 
     36 
     37// VPR_HAVE_HASH_MAP will be defined to 1 or 0 by vpr/vprConfig.h which is 
     38// included by vpr/vpr.h. 
     39#if VPR_HAVE_HASH_MAP 
     40#  include VPR_HASH_MAP_INCLUDE 
     41#else 
     42#  include <map> 
     43#endif 
     44 
    3645#include <vpr/IO/Socket/InetAddr.h> 
    3746#include <vpr/IO/Socket/Socket.h> 
     
    15311540   std::vector<FBB::Device*> m_birds;   /**< Vector of all devices (birds) 
    15321541                                             connected to the server chassis */ 
    1533    std::vector<int> mAddrToSensorIdMap; 
     1542 
     1543   /** 
     1544    * Define the type for \c mAddrToSensorIdMap. We use an actual map here 
     1545    * rather than, say, a vector because the range of FBB addresses is not 
     1546    * necessarily [0,n] for n birds. Indeed, a case has been encountered where 
     1547    * four birds have addresses 2, 3, 4, and 5. In that case, the size of the 
     1548    * container would be 5 (the extra is to account for the ERT), but we would 
     1549    * be trying to access (zero-based) index 5 as the largest rahter than 
     1550    * index 4. 
     1551    */ 
     1552#if VPR_HAVE_HASH_MAP 
     1553#  if defined(_MSC_VER) 
     1554   typedef stdext::hash_map<int, int> addr_sensor_map_t; 
     1555#  else 
     1556   typedef std::hash_map<int, int> addr_sensor_map_t; 
     1557#  endif 
     1558#else 
     1559   typedef std::map<int, int> addr_sensor_map_t; 
     1560#endif 
     1561 
     1562   /** 
     1563    * Mapping of FBB address (which can be anything greater than or equal to 
     1564    * zero) to a zero-based, sequential range of integer identifiers. 
     1565    */ 
     1566   addr_sensor_map_t mAddrToSensorIdMap; 
    15341567   std::vector<gmtl::Matrix44f> mSampleData; 
    15351568